Best solution to draw custom mouse pointer


I’d like to draw some beautiful mouse pointer instead of native, but drawing texture at current cursor’s position feels laggy within 60 fps.
Can anyone give a solution to handle that?

I encountered this issue, in a break out game, to draw the paddle…

…(of coarse only modifying the X-pos pf the paddle from mouse input)…

And I always felt it was a little off, perhaps laggy. -But the best answers I could find anywhere were pretty disappointing.

There isnt much to do it seems. Regular cursors use dedicated hardware, appearantly, which is why you can still move and see your cursor sometimes when your system crashes…
-So the sprite-position from cursor-location will always be that little bit slower than the cursor-position itself.

You can see this when you draw the cursor along with the sprite, the sprite will be a frame or so behind the cursor.

I dont think I found a good fix, and I remember numerous people saying it was normal and that players were used to it.
-Anyways it was small enough that I never heard anyone complaints, from the few who ever played it…

There is a way to get custom cursor, but only if you are willing to compile from source. Currently we are in process of replacing OpenTK with SDL2, and one of the things that is done on that branch is add an ability for setting custom cursor or changing it to one of the system cursors (it wasn’t possible with OpenTK backend because it didn’t support it).

The topic:

The PR and branch that is used for it:

The file:

The code for setting the custom cursor if you decide on using the branch:

Mouse.SetCursor(MouseCursor.FromTexture2D(tex, 0, 0));

If you don’t want to bother with compiling from source, then you can wait till MonoGame 3.6 release, which should be somewhere in june.

thanks for the reply!

Cool, so with SetCursor() its possible to simply replace the cursor then after all?

What about texture size?

and can it be dynamically replaced in realtime / updated rendertarget to draw a 3d cursor, say…

Yes, but you need the SDL branch build.

No limit.

I have no idea what you meant by 3d cursor…

I’m pretty sure he meant like, draw say a entire 3d object on a rendertarget, then dynamically at runetime,possibly every frame set the cursors texture to the rendertarget?

Thanks for the clarification.

The code for setting cursor only sets system cursor image, and does nothing more.

Thanks, and yes,

I meant rendering a 3d object to a rendertarget, and then drawing that rendertarget as a cursor :slight_smile:

…Whether the cursor texture can be replaced/overwritten in real-time…?

Also, this SDL branch build, what is that? Another version of monogame I need to install? Or an add-on of sorts?
-I’m at a ‘user’ level of understanding only, I dont know anything about the technicalities that makes my Express editor spit out executables from the code I type… Is it a library? -And will using it effect the distribution of my games? Thanks-

Wait for MonoGame 3.6

I’m a little confused. Are you simply ending the conversation, or telling me that these things are ACTUALLY a part of 3.6…?
That would be great! Any kind of ETA?

Both actually.

It will be part of 3.6 which is scheduled for June (as I said it above).

And you seem very nooby so I want to avoid explaining multiple steps that are needed to get SDL branch running (one of the steps is compiling SDL from source… you can see my point…).

Thanks :slight_smile: That was very helpfull!