Hi all,
I’ve noticed a small issue with SpriteBatch rendering on WindowsGL platform (does not occur on Windows DX nor XNA 4.0). When drawing a sprite that moves at constant speed, the animation “stutters” and is not smooth, even though the program runs at 60fps. It seems that sometimes the sprite is not drawn at the position it should be.
Here’s a very simple example to reproduce the bug (the texture red is just a 64x64 red texture):
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
namespace MonogameTest
{
public class Game1 : Game
{
public Game1()
{
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
IsFixedTimeStep = true;
}
////////////////////////////////////////////////////////////////////////// Override Methods
protected override void LoadContent()
{
_spriteBatch = new SpriteBatch(GraphicsDevice);
_texture = Content.Load<Texture2D>("red");
_pos = Point.Zero;
}
protected override void Update(GameTime gameTime)
{
if (Keyboard.GetState().IsKeyDown(Keys.Space))
{
_pos.X = 0;
}
_pos.X += 6;
base.Update(gameTime);
}
protected override void Draw(GameTime gameTime)
{
GraphicsDevice.Clear(Color.CornflowerBlue);
_spriteBatch.Begin();
_spriteBatch.Draw(_texture, _pos.ToVector2(), Color.White);
_spriteBatch.End();
base.Draw(gameTime);
}
////////////////////////////////////////////////////////////////////////// Private Members
private GraphicsDeviceManager _graphics;
private SpriteBatch _spriteBatch;
private Texture2D _texture;
private Point _pos;
}
}
I’ve reproduced it Monogame 3.4 and also with the last unstable version (currently 3.5.0.703). Thanks in advance!
Martin