• Popular Now

• 14
• 12
• 9
• 10
• 13

Archived

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

Frame rate too high???

This topic is 5979 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

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 on other sites
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 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 on other sites
Make sure the message que is being checked and handled every frame. There should be something like a

if(PeekMessage)
TranslateMessage
else
RenderLoop

When you exit PostQuitMessage(0) is put at the end of the que and the previous messages are handled before the exit command is hit.

Ben

[Icarus Independent | Jump Down The Rabbithole | Tombstone: Vendetta ]

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 on other sites
I''ve had that problem before, you could do a wait for vertical retrace to fix it

Share on other sites
try this

  while (GetMessage(&msg, NULL, NULL, NULL)) { TranslateMessage(&msg); DispatchMessage(&msg); }

There may just be more messages being put in the que than are being taken out every frame.

Ben

[Icarus Independent | Jump Down The Rabbithole | Tombstone: Vendetta ]

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 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 on other sites
Windows is multithreaded but your program isn''t. Keyboard presses are put into the que at any time but aren''t handled until your program gets around to it.

Ben

[Icarus Independent | Jump Down The Rabbithole | Tombstone: Vendetta ]