Skip to main content
gamedev.net
🔒 Locked

Subtle mouse input delay

Started by JshMRsn 3 replies 1.6k views
Original Post
JshMRsn
JshMRsn
Hello, I am using SDL/OpenGL. There seems to be a subtle delay in the mouse movement. I was thinking it could just be the FPS is lower than the update speed of the mouse, but it is running at 300fps so I don't think that is it. SDL_Event event; while ( SDL_PollEvent (&event) ) { switch (event.type) { case SDL_MOUSEMOTION: int mx, my; SDL_GetRelativeMouseState(&mx, &my); cursor.location += IDVector2(mx,my); //add the delta (velocity) break; } } Any ideas?
Redien
Redien
I was having the same problem myself and as it turns out, disabling vertical-sync did the job. But obviously now I get this awful tearing so it doesn't quite help me.

Anyway, if you'd like to turn off vsync you can use SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 ); before you set the video mode.

I'm still looking for a better solution though if anyone's got an idea. :)
Kylotan
Kylotan
Have you tried just dropping those mouse events and instead just polling the position prior to rendering?
Redien
Redien
I did try that with SDL_GetMouseState() but it gave me the same delay.

Edit: I also tried to SDL_PumpEvents() before polling the events but that didn't help either.
squidlarkin
squidlarkin
This is sounding suspiciously like my problem: http://www.gamedev.net/community/forums/topic.asp?topic_id=457373

A few questions. What kind of CPU are you using? Have you tried running your program on someone else's machine? Also, I just discovered that the slowdown doesn't occur if I'm holding either mouse button, even if I'm not processing mousebutton events. Try that.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.