Advertisement Jump to content
Sign in to follow this  

SDL_ShowCursor(SDL_DISABLE) and SDL_WarpMouse - anomaly

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I am currently having trouble with the SDL_ShowCursor(SDL_DISABLE) command. When I set this SDL state, my cursor disappears as requested. I then want to warp the mouse position to SDL_WarpMouse(width/2, height/2). The problem I encounter is that the mouse warp does not seem to register correctly. For example, SDL_ShowCursor(SDL_DISABLE); SDL_WarpMouse(960, 600); The next very slight mouse motion would generate a mouse position of, say, 508,530. However, // SDL_ShowCursor(SDL_DISABLE); SDL_WarpMouse(960, 600); would generate a mouse position of 961, 600 after the same slight movement of the mouse. All mouse motions that occur after the initial strange position seem to be correct. Is there anyway to avoid this anomaly? Could anyone be kind enough to take the time to enlighten me? Thanks.

Share this post

Link to post
Share on other sites
I was able to correct this problem by surrounding all my setup code with:


// setup all game and opengl state


while(1) {
// message pump
// draw screen

It appears that a mouse motion event was being generated during the initialization calls.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!