Hi.
I have added OpenGL to a window.
Now, if i move the window, the OpenGL animation and such, stops for a while, untill i release my window again.
This is not good in a game, where time should not be stopped. How to fix?
Hi.
I have added OpenGL to a window.
Now, if i move the window, the OpenGL animation and such, stops for a while, untill i release my window again.
This is not good in a game, where time should not be stopped. How to fix?
http://livebad.com/nuka
Da-Nuka
Handle the WM_MOVING message and call your drawing function from there.
CProgramming FAQ
Caution: this person may be a carrier of the misinformation virus.
It worked..allmost..
But if I click it, and not move it, the propblem still occurs.
The same if i rightclick on the program-icon down in the taskbar.
http://livebad.com/nuka
Da-Nuka
Its to do with the PeekMessage() loop.
When there is a constant stream of messages the DrawGL function will not get called (unless DrawGL is called in one of the messages ie your WM_PAINT handler).
Write a handler for those that you think need it.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Wow, is that the only way?
It sounds resource-demanding... What if I include, for example program or game-logic as well.. It will be very big for so little...
http://livebad.com/nuka
Da-Nuka
Another way is to limit frame rate. This will cause other issues though.
Check if another frame is needed after each message has been processed and while idle (no messages). If sufficent time has passed call DrawGL.
Depending on speed you may need to use QueryPerformanceCounter() (and Frequency) as WM_TIMER msg's are very low accuracy (low priority in the msg que) or use GetTickCount()
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Hmm..I think it is something else which is the problem... Maybe some windows related stuff...
Cuz I can solve that problem, by adding a loop OVER my MessageLoop, and end that loop if the messageloop contains WM_QUIT. Then I add the Game-Logic over there, so the game logic should be ran for every single message, without any more coding.
I did, and it worked, but still, when I GRAB the window, og clicks in its menu, the game stops. Why? and how to solve?
http://livebad.com/nuka
Da-Nuka
Well, it is kind of hard to answer specific program problems without seeing any code.
It sounds like the game is stopping for the same reason everyone has been stating on this post previously. AKA your render functions are not getting called when windows is handling a message. Understand that if your windows callback procedure is passing all unhandled messages to DefWindowProc then WINDOWS is actually doing something and while that is going on your game "stops".
You could try to put a call to your render function right before your
statement at the end of your windows callback function.Code:return DefWindowProc(..)
However like I said it is hard to help without code
while(!done) {
DrawGL();
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)) {
if(msg.message==WM_QUIT) {
done=true;
} else {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
return msg.wParam;
}
-wont that work as well?
(well, I tried, and it dont)
http://livebad.com/nuka
Da-Nuka
OK this loop only calls DrawGL() at the beginning prior to checking to see if there is a message. What about if there is a message? You need to call DrawGL() from within your window callback procedure to handle these things. Such as using the WM_MOVING message as suggested earlier. I would also use the WM_PAINT message as well.