Jump to content
  • Advertisement

Archived

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

idinkin

message loop

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

while(!bDone)
	{
		if(PeekMessage(&msg,NULL,0,0,PM_NOREMOVE))
		{
			if(msg.message==WM_QUIT)
			{
				bDone=TRUE;
			}
			else
			{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else
		{
			if(keys[VK_ESCAPE]) //<------- o_O
			{
				bDone=TRUE;
			}
			else
			{
				DrawScene();
				SwapBuffers(hDC);
			}
		}
	}
 
The problem is the program never gets to the pointed line. And when I start the application it uses 90% of my CPU... The only way not to get there is to have an infinite number of messages in the queue but why????

It does not matter what you will reach in your life, but the way you will reach it

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Are you removing messages somewhere else? With the current flag PM_NOREMOVE they will always stay in the queue.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You are sending WM_QUIT message to your process somewhere, right?

Share this post


Link to post
Share on other sites
With PM_NOREMOVE you''ll be handling the same message - whichever is sent to the applications various message queues first - forever. With a NULL HWND parameter, there''s no need to test msg.message separately; use the return value of PeekMessage to determine when to exit the loop.

Obviously, because PeekMessage returns a non-zero value when there''s a message waiting, that portion of the loop will always get executed while the else clause never does.

As for using 99% of CPU, PeekMessage doesn''t block. Any insistently executing loop will max out CPU load.

Share this post


Link to post
Share on other sites
Thanks, now it works...
But I have another problem - I have got very low fps...
I think 0.1 fps and I don't draw anything. Why?



It does not matter what you will reach in your life, but the way you will reach it

[edited by - idinkin on May 7, 2004 3:17:47 PM]

Share this post


Link to post
Share on other sites
I tried running the glExtensionViewer tests and I have got 0 fps in each of them. I've seen only the first frames of those. NeHe tutorials are running the same. What might be the problem?

[edited by - idinkin on May 8, 2004 1:22:55 AM]

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!