Archived

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

beehorf

process timing

Recommended Posts

Hi, I use simple message loop which is nearly the same in the SDK samples. Following is my message loop. When I run the program when winamp is running, CPU usage of winamp goes to %30 and my program looses its smoothness( Its like it does not draw some of the frames). Interestingly if Visual C is running at the same time no such thing happens. I installed last version and patches Winamp and VC nothing changed. If you encounter such a problem please help me. I dont want to debug my code for hours to find the problem...
    // Enter the message loop

    MSG msg;
    ZeroMemory( &msg, sizeof(msg) );
    while( msg.message!=WM_QUIT )
    {
        if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
        {
             TranslateMessage( &msg );
             DispatchMessage( &msg );
        }
        else
            if (game.active) 
			{
				game.StepGame();
			}
			else 
			{
				game.timer.stop();
				WaitMessage();
			}
    }
be yourself.

Share this post


Link to post
Share on other sites
How about something like this:

// Enter the message loop

MSG msg;
ZeroMemory( &msg, sizeof(msg) );
while( 1 )
{
if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) )
{
if (msg.message == WM_QUIT)
return 0;

TranslateMessage( &msg );
DispatchMessage( &msg );
}
else
if (game.active)
{
game.StepGame();
}
else
{
game.timer.stop();
}
}


[edited by - adiash on October 9, 2003 2:56:38 AM]

Share this post


Link to post
Share on other sites
I think it does not change anything.
you only reorganized the code but no addition ,no change.

Btw, I added some Sleep(1) function in the game.StepGame()
function the problem doesnt appears but with the half frame rate .
I think there is some CPU time fighting with winamp.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What type of optimization are you using? adiash''s code is missing WaitMessage() and I''m not sure having the check later on would really cause 30% more cpu usage.

Share this post


Link to post
Share on other sites
I tried it but it does not solve my problem.
Also it is only called when my program is
deactivated. So in main rendering loop it is
never called.

I use the optimization of maximize
speed in Visual C++ 6.0.

Share this post


Link to post
Share on other sites
I actully thought that waitmessage is the problem. If you have a game loop, then you definitely do not want to wait for a message. Rather, you want to keep a steady pace of rendering (e.g. 30 FPS). Anyway, sorry I can''t help more.

Share this post


Link to post
Share on other sites
What I do not understand is when I run Visual C once , the problem never appears again even if I close VC. Until I reboot of course.

btw I see %53 cpu usage of winamp. But when I close my program it drops to %0-1. It makes me nervous.

[edited by - beehorf on October 9, 2003 5:02:04 AM]

Share this post


Link to post
Share on other sites
Are you using any visul plugins with Winamp? I''ve noticed that some DX apps don''t "play nice" when run concurrently.

For example, if I have my 3d model converter open (which uses a D3D preview window) while I try to run my game, I notice about a %15-%30 percent drop in framerate -- even if the converter is minimized.

---
http://www.gapingwolf.com

Share this post


Link to post
Share on other sites
hi,
quote:
Are you using any visul plugins with Winamp? I''ve noticed that some DX apps don''t "play nice" when run concurrently.

For example, if I have my 3d model converter open (which uses a D3D preview window) while I try to run my game, I notice about a %15-%30 percent drop in framerate -- even if the converter is minimized.

---
http://www.gapingwolf.com


Yes it was my problem. Winamp uses directx to display visual plugins i think. I tryed it with windowed direcx sdk examples they suffered from this problem too.
Minimizing winamp or some application like Visual C++ that hides winamp solves the problem. That is why when running under VC the problem is not observed.

Thanks all...

be yourself.

Share this post


Link to post
Share on other sites