Hello guys,
I 've found a tutorial to use some bloom effect in my game. The tuto can be found here.
But I encounter an strange error. Actually, Visual Studio tell me that
Build : 1 succeeded, 0 failed, 0 skipped but no window appear …
If you put the line 34 in comment, the code still build successfull and a window appear but without the bloom effect ( it’s normal because we put the line 34 in comment).
So why when the line 34 is not in comment, the project build well but no window appear ?
Thanks in advance to the time you’ll give me
This is the code :
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using BloomPostprocess;
namespace TestNeon
{
///
/// This is the main type for your game.
///
public class Game1 : Game
{
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
Texture2D space_Sprite;
Texture2D player_Sprite;
BloomComponent bloom;
public Game1() { graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content";
graphics.PreferredBackBufferWidth = 1280; graphics.PreferredBackBufferHeight = 720;
bloom = new BloomComponent(this); Components.Add(bloom); bloom.Settings = new BloomSettings(null, 0.25f, 4, 2, 10, 1.5f, 1);
}
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // TODO: Add your initialization logic here
base.Initialize(); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice);
player_Sprite = Content.Load<Texture2D>("geometryShip"); space_Sprite = Content.Load<Texture2D>("spaceSprite");
// TODO: use this.Content to load your game content here }
/// <summary> /// UnloadContent will be called once per game and is the place to unload /// game-specific content. /// </summary> protected override void UnloadContent() { // TODO: Unload any non ContentManager content here }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) Exit();
// TODO: Add your update logic here
base.Update(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); spriteBatch.Draw(space_Sprite, new Vector2(0, 0), Color.White); spriteBatch.End(); bloom.BeginDraw(); spriteBatch.Begin(SpriteSortMode.Texture, BlendState.Additive); // TODO: Add your drawing code here Rectangle sourceRectangle = new Rectangle(0, 0, player_Sprite.Width, player_Sprite.Height); Vector2 origin2 = new Vector2(player_Sprite.Width / 2, player_Sprite.Height / 2); spriteBatch.Draw(player_Sprite, new Vector2(50,50), sourceRectangle, Color.White, 0, origin2, 0.5f, SpriteEffects.None, 1);
spriteBatch.End();
base.Draw(gameTime); } }
}