Dealing with WM_Input Mouse bus rate

Started by
1 comment, last by Gegenki 16 years, 3 months ago
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.
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.
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
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.

This topic is closed to new replies.

Advertisement