SpriteBatch rendering is not smooth (WindowsGL)

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

I’ve seen the same problem in a basic 3D project I made where a cube moved around the screen. And I used the code you provided and was able to reproduce the bug.

Honestly, I’d say just use DirectX, unless you’re planning on targeting platforms that don’t support DirectX. However, since this is more than just a small issue, it’s actually a pretty major one, I’d say it might not be a bad idea to submit an issue on Github.

bousquetm - where are you getting your MonoGame assembly from?

Last night I switched mine from my local build to use the version that ships through nuget. I found my game appeared to stutter as my textures moved around though I also found my framerate appeared consistent. I’m also running GL. Switching back to my local build fixed the issue. I was planning on posting this evening after some more investigation - feels like it could be the same issue.

Hi matt,

I’m getting the dlls directly from the windows installer (from the server build). I tried to switch to a local built assembly, but it doesn"t seem to fix the issue for me. Anyway, I’ll file a bug report on github.