Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MtSMox

Frame rate too high???

This topic is 6094 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 you all, yes it''s another fps message, but this one is (I think) different. I know I can let the fps go and still get good timing, but my problem now is, that the fps is too high. I had two programs that are almost the same. They both used DirectDraw 7 and where just a little gaphics sample. One also used GetDC the other didn''t. I used the PeekMessage() to see if there are any messages for the window and if not did the game stuff (including drawing). So both programs did this, but the weird thing is that one sort of locked the system. Everything got slow (except the fps of the game: about 1500 or so). So I thought it should be doing fine... the messageloop is run 1500 times a second so it should process the messages fine. But it wasn''t. I later found out that if I lowered fps, it worked fine (I think the other prog was already slowed down by the GetDC, etc.). But I don''t want to lower fps, I want it as high as it can get. I hope you understand the problem and can help me, thanks in advance... Mox

Share this post


Link to post
Share on other sites
Advertisement
Hmm. I get a similar problem. The message loop is running, but it doesn''t seem to notice when I press a key - I have to hold it down. I''ve no idea what causes it.

''Nuff said. I''ll enjoy watching you live, demon.

Share this post


Link to post
Share on other sites
Make that 3 of us, i hold down any keys and nothing happens. Eventually i have enough of it and press ESCAPE several times until suddenly all my other keystokes are processed in super-fast time before the exit command is processed and the whole thing shuts down.

Definately something to do with the message processing loop, i just don''t know what it is yet.

zipless

Share this post


Link to post
Share on other sites
This is my message loop:
  
while (true)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
break;
}
else
DoGame();
}


It seems correct, but the weird thing is it works fine if I do nothing in DoGame. But if I use DirectDraw to erase the backbuffer and flip it (or blt it to the screen), it slows down. And if I put a GetDC call in it, the fps drop and the program (and other windows) respond correctly.
What is going on here? Why wouldn''t this messageloop work if it is traversed really fast?

Mox

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I''ve had that problem before, you could do a wait for vertical retrace to fix it

Share this post


Link to post
Share on other sites
Yeah, you need to make it while(PeekMessage(...))
Handle all the messages, then render another frame.

I calculate the framerate, and if/when it exceeds 200fps, I call Sleep(1). This gives other running processes and threads a chance to do something.

Share this post


Link to post
Share on other sites
I''ll try to use the while (PeekMessage()).
But shouldn''t windows or whatever, because it''s multithreaded, devide the processor time to all the threads. So why should it matter how intens your program is?

Share this post


Link to post
Share on other sites

  • 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!