Sign in to follow this  

Mouse Motion causes Frame skip? SDL 1.2.13 ,Opengl

This topic is 3631 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 there, I've got an odd problem where the main loop (which is vsynched based on the times im measuring) skips frames whenever the mouse is moved across the window. Normally each loop takes 16ms (corresponding to screen refresh), but when mouse is moved they seem to miss synchs, and alternate between ~33ms and 0ms. I've used both sdl_getticks as well as the window queryperformancecounter methods to check the time, and see the same thing, so pretty sure its not a timer accuracy issue. I've concluded that it probably isn't due to my mousemotion event processing(I use it to mouselook); since even if I comment out my handling code it still occurs. Considered the possibility that the warpmouse which i use to keep the cursor inside the window might be an issue, but doesnt seem to be the problem; when switching to the new grabinput method of doing this theres no change. Occurs in both windowed and fullscreen mode. When in windowed mode, even if I alt-tab away from the game window and bring some other app to the front, if the cursor passes across the gamewindow(now in background) it still skips frames. ?seems to indicate something relating to messages? (using windows xp) So, I'm running out of ideas on what might be causing this. Anyone have any thoughts on possible causes and solutions? If more info needed just ask, not too sure what might be relevant. Thanks EDIT: did some tests... made two squares that move across the screen at const velocity one updates on the physics loop based on ticktiming one updates on the main loop ignoring time measurements the physics one stutters when mouse in motion -expected since the timer measures wierd frame times the non-physics one appears smooth regardless of mouse motions this seems to imply that I'm not *really* skipping frames when the mouse moves, but instead the time measurements are being messed up still in the dark as to why this should be though. any suggestions? [Edited by - haphazardlynamed on January 7, 2008 1:15:32 AM]

Share this post


Link to post
Share on other sites
...And so that final clue about its really the timer's messing up leads me to solve this problem myself.

Turns out I was doing things in this order:

pollevents
check time
physics
render
wait for vsynch


changing it to:

check time
pollevents
physics
render
wait for vsynch


solves the problem
apparantly polling for events takes up time, not enough to miss a vsynch, but enough to offset to point within the 16ms frame where my check time line was located depending on what events were being passed
lesson: measure the time Before doing All processing work


I guess I'll leave this thread up, as an example.

Share this post


Link to post
Share on other sites

This topic is 3631 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this