Hiding the Cursor / Warp Mouse (SDL 1.3)
I've been unable to hide the mouse cursor (properly) using SDL. I am using Ubuntu 10.10 and have been using the following:
SDL_ShowCursor( SDL_DISABLE );
SDL_WarpMouse( x, y );
Neither of which function properly at all; it would appear to have no visual effect, there is however a triggered mouse motion event as the documentation states, but the mouse does not move in any or disappear on screen.
The SDL Window is created (via SDL_CreateWindow) with the f开发者_JS百科lags SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN. Fullscreen has no effect on the outcome.
Running the window at low resolutions in fullscreen mode (such as 640x480), does provide the desired effect of the commands; but the cursor bleeds through from the underlying windows. Around 1024x768, it has a completely different cursor icon. As I get higher in resolution, it stops bleeding through and just acts as though its a window (the Gnome cursor). With no effect of above commands.
Any ideas?
I know this question is old, but it's still actual.
Here's the solution:
Where you want to hide the cursor, write this:
SDL_Cursor *cursor; /* Make this variable visible in the point
where you exit the program */
int32_t cursorData[2] = {0, 0};
cursor = SDL_CreateCursor((Uint8 *)cursorData, (Uint8 *)cursorData, 8, 8, 4, 4);
SDL_SetCursor(cursor);
Where you exit the program:
SDL_FreeCursor(cursor);
*Yes, cursors are not yet implemented in SDL 1.3. I'm sort of intentionally leaving them unimplemented as a reminder that 1.3 isn't ready yet. *
Quote by Sam Lantinga, an SDL Developer; therefore this question is simply an SDL bug (soon to be fixed).
精彩评论