Jump to content
  • Advertisement
Sign in to follow this  
squidlarkin

SDL: mouse motion slows my event loop

This topic is 4125 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

My game gets perfectly smooth framerates, until I start moving the mouse, at which point the event queue clogs up and things get all stuttery. I tried taking the mouse handling out of the event loop, but the MOUSEMOTION events are still being caught and slowing things down. The loop looks like this, for the record:
     while (SDL_PollEvent(&event)){
	switch(event.type) {
        ...
        }
     }

Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Are you sure the way you handle mouse events aren't causing this problem. Always assume it's your fault, not the library's or something.

Share this post


Link to post
Share on other sites
Quote:
Original post by Jaiminho
Are you sure the way you handle mouse events aren't causing this problem. Always assume it's your fault, not the library's or something.


Of course! But right now I've got everything having to do with the mouse commented out, and nudging the mouse still makes my framerate drop. I'm mystified.

Share this post


Link to post
Share on other sites
That problem must be related to the OS. Check for the most recent stable release of SDL and see if it corrects that (which you probably have, but it's worth trying and reminding).

Else, I'm out of options to give.

Share this post


Link to post
Share on other sites
Curiouser and curiouser. I've tested it on a couple other machines and they don't have the problem I'm describing at all. So I suppose this isn't actually a programming problem, but I'd still like to hear theories! This is a Core 2 Duo running WinXP with all the latest drivers installed, as far as I'm aware.

Share this post


Link to post
Share on other sites
Quote:
Original post by squidlarkin
Curiouser and curiouser. I've tested it on a couple other machines and they don't have the problem I'm describing at all. So I suppose this isn't actually a programming problem, but I'd still like to hear theories! This is a Core 2 Duo running WinXP with all the latest drivers installed, as far as I'm aware.


SDL version?

Share this post


Link to post
Share on other sites
I think the event queue is full of MOUSEMOTION.I suppose,the reason you get no problem on other machines is that your machine is Core 2 Duo.Maybe SDL takes the advanture of extra Core,to fill the event queue more quickly.
I just guess this is the problem.

I suggest that use direct mode to read the MOUSEMOTION event.
It just get a snapshot of the current device state.
you can use:
SDL_PumpEvents
SDL_GetMouseState
SDL_GetRelativeMouseState
you can find all on :
http://www.libsdl.org/cgi/docwiki.cgi/SDL_20API

hope it help

Share this post


Link to post
Share on other sites
I don't think it's because of being a Core 2 Duo processor. I got one and I don't have any problems with slow mouse events or any other slow events.

Share this post


Link to post
Share on other sites
Can you post the source to a bare-bone program that compiles and still exhibits the mousemotion slowdown? Have you tried setting CPU affinity? How many mousemotion events on average are you getting in the while-pollevent loop? Is all event handling done outside this loop?

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net 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!