Jump to content
  • Advertisement
Sign in to follow this  
Gegenki

Dealing with WM_Input Mouse bus rate

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

After doing some lengthy research into input methods for my mouse I started to implement WM_Input. The problem i am having is that: I'm running a single thread. My program renders at 60 frames per second and I'd like to keep it that way to avoid tearing. This leaves the windows callback stack to be checked 60 times per second. My mouse is running at 200hz. 10 seconds of mouse movement - gives 33 seconds of on screen movement I believe because the mouse messages have been queued up (I did the math). I found it strange that I could queue so much mouse movement and then cause a WM_Destroy (programmed for escape key) which happens instantly but I'm guessing that is given priority. My two initial idea to get around this was to increase the rate at which the messages were checked. My current temporary work around is to use 'D3DPRESENT_INTERVAL_IMMEDIATE' which puts me up to a very high framerate but gives alot of tearing and won't hold when I start rendering more things or running it on a different system and the framerate drops below 200fps. My other idea was to create a 2nd thread. At first I considered making a different thread to check the messages but it would be much simpler to leave the message checking the way it is and make a seperate render thread. The problem is that I didn't want to do this because I then have to start thinking about critcal sections and such.

Share this post


Link to post
Share on other sites
Advertisement
Can't you separate your rendering from your message checking?

Either:
* do not render untill all messages are dispatched
or
* loop as many times as humanly possible checking for messages each loop, but call the render function only once every 1/60th of a second (or whatever your desired frame rate is).

Sorry if I misunderstood your question and this isn't what you're looking for.

Share this post


Link to post
Share on other sites
Thanks Koobazaur
Thought about not rendering until all messages are dispatched.
I looked up peekmessage on msdn to see if their was a way to check if there were more messages and realised that peekmessage returns 0 when there are no messages so I changed my
if peekmessage....
to a
while peekmessage....

so when there are no messages left it returns 0 and breaks out of the while loop and only then it renders.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!