Not DirectInput this time...
Hi...
I posted a question a little earlier, but my problem wasn''t what I thought then. It is as follows...
My problem arises when I do a lot of blits ("DDSurface->Blt()"). Windows seems to be terrible slowed down by this. I can''t se why because my app are running like hell (about 300-1300 FPS). Is it that my app steals all CPU time or what???? Are there some message I don''t handle or something. It dosen''t matter if I run my program in fullscreen or windowed mode.
Please help, I don''t understand this...
// Javelin
-- Why do something today when you can do it tomorrow... --
what does your main game loop look like??
ie
you NEED to be nice to windows and share execution time with it, otherwise very strange things begin to happen...(ie. Windows gets MAD)
ie
ZeroMemory( &msg, sizeof(msg) );while( msg.message != WM_QUIT ){ if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else { if(m_bIsActive){ // Update players updateGame(1.0f); // render the scene renderGame(); } }}
you NEED to be nice to windows and share execution time with it, otherwise very strange things begin to happen...(ie. Windows gets MAD)
Thanks for your answers, but I think I should have said that I'm using DirctDraw7. I'm also using Visual C++ and the standard Windows API (not MFC).
I looked up the DoEvent thing, but does it exist in C++? I noticed that when I add a simple wait in my code everything runs smooth, but it can't be ritght that I should have to add a wait in my main loop to make my app nice...
My main loop
while(true)
{
while(clock() [less than] last+1);
last=clock();
scrn.PutGfx(splash); // Put something on my surface
scrn.Flip(); // Make a blit (not a flip)
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if( 0 == GetMessage(&msg, NULL, 0, 0 ) )
return (int)msg.wParam;
if( 0 == TranslateAccelerator( hWnd, hAccel, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
WaitMessage();
}
Hmmm... it seems that you can't type every character in here like the 'less than' sign.
I would be happy for some more answers...
// Javelin
-- Why do something today when you can do it tomorrow... --
Edited by - Javelin on January 3, 2002 9:05:37 AM
Edited by - Javelin on January 3, 2002 9:09:12 AM
I looked up the DoEvent thing, but does it exist in C++? I noticed that when I add a simple wait in my code everything runs smooth, but it can't be ritght that I should have to add a wait in my main loop to make my app nice...
My main loop
while(true)
{
while(clock() [less than] last+1);
last=clock();
scrn.PutGfx(splash); // Put something on my surface
scrn.Flip(); // Make a blit (not a flip)
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if( 0 == GetMessage(&msg, NULL, 0, 0 ) )
return (int)msg.wParam;
if( 0 == TranslateAccelerator( hWnd, hAccel, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
WaitMessage();
}
Hmmm... it seems that you can't type every character in here like the 'less than' sign.
I would be happy for some more answers...
// Javelin
-- Why do something today when you can do it tomorrow... --
Edited by - Javelin on January 3, 2002 9:05:37 AM
Edited by - Javelin on January 3, 2002 9:09:12 AM
DoEvents is a VB command that I''m guessing is equivalent to:
if( GetMessage(...) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
Just your typical message processing loop.
-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
if( GetMessage(...) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
Just your typical message processing loop.
-----------------------------
The sad thing about artificial intelligence is that it lacks artifice and therefore intelligence.
quote:Original post by Javelin
Thanks for your answers, but I think I should have said that I''m using DirctDraw7. I''m also using Visual C++ and the standard Windows API (not MFC).
I looked up the DoEvent thing, but does it exist in C++? I noticed that when I add a simple wait in my code everything runs smooth, but it can''t be ritght that I should have to add a wait in my main loop to make my app nice...
My main loop
while(true)
{
while(clock() [less than] last+1);
last=clock();
scrn.PutGfx(splash); // Put something on my surface
scrn.Flip(); // Make a blit (not a flip)
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
{
if( 0 == GetMessage(&msg, NULL, 0, 0 ) )
return (int)msg.wParam;
if( 0 == TranslateAccelerator( hWnd, hAccel, &msg ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
else
WaitMessage();
}
Hmmm... it seems that you can''t type every character in here like the ''less than'' sign.
I would be happy for some more answers...
// Javelin
-- Why do something today when you can do it tomorrow... --
Edited by - Javelin on January 3, 2002 9:05:37 AM
Edited by - Javelin on January 3, 2002 9:09:12 AM
NOt sure if that would solve your problem but instead of:
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
you should do:
while( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
if makes sure that all messages are processed before continuing... Again, I cna''t say for sure if that''s the problem but I just thought I''d point that out...
"And that''s the bottom line cause I said so!"
Cyberdrek
Resist Windows XP''s Invasive Production Activation Technology!
"gitty up" -- Kramer
/(bb|[^b]{2})/ that is the Question -- ThinkGeek.com
Hash Bang Slash bin Slash Bash -- #!/bin/bash
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement