emacinnes's picture

Chanigng the default cursor flickers a lot

I'm trying to use the System.Windows.Forms.Cursor.Current to change the current cursror, but every time the mouse moves in the GameWindow, it gets reset back to the default cursor. If the mouse is stationery it's fine, but the moment it moves the pointer is reset. In a very high frame rate situation it's not noticeable, but the moment the framerate drops to <180FPS for example, then the change back to the default cursor is noticeable.

Anybody got it to work properly and completely?

I'm changing the cursor to the custom one every UpdateFrame AND renderFrame (one or the other and the flicker is worse).


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
emacinnes's picture

Solved this with a change to OpenTK. OpenTK's windows platform was setting the window internally to have a default Arrow cursor, and with no exposed value to override this. I tried using windows messages to circumvent the issue, but the only way around was to modify OpenTK to stop it from setting the default cursor for the window, then I only need to set the cursor once, (and on resizing) not every frame.

The line to change is:

OpenTK\Platform\Windows\WinGLNative.cs, line 778 (in release build 1.1)

Change:

wc.Cursor = Functions.LoadCursor(CursorName.Arrow);

to

wc.Cursor = IntPtr.Zero;

This is important for a 3D app as it is a hardware cursor, not an in-game cursor that would be lagging behind the input and feel sluggish, such that the game continues to look responsive.

Cheers,

Euan

Icarus Scene Engine. OpenTK-based 3D simulation & games solution, for Win, Linux, Mac, iOS, Droid:
http://icarus.pointscape.com.sg

See Icarus videos on

the Fiddler's picture

@emaccines: PR #106 is now merged, so you no longer need to modify OpenTK.

Custom hardware cursors are mostly implemented, they will hopefully land very soon now. See issue #9