Archived

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

weird problem with directdraw

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

im having a weird problem with a windowed ddraw app, is something like this: i this is my main loop
      
	while(app.MsgHandling() && windowclosed == false)
	{
		}
			Edraw.BackBufferFlip();
		}
	}
  
Edraw.BackBufferFlip() is defined as:
  
bool EasyDDraw::BackBufferFlip()
{
	error =	DDSprimary->Blt(NULL,DDSback,NULL,DDBLT_WAIT,NULL);
	if(FAILED(error))
	{
		MessageBox(hwnd, "error in Blt(Wnd)", ErrorToString(error), MB_OK | MB_ICONEXCLAMATION);
		return DAMN;
	}
	DDSback->Blt(NULL,NULL,NULL,DDBLT_WAIT|DDBLT_COLORFILL,&bltfx);
	return OK;
}
  
DDSprimary is the main surface, and DDSback is a plain off screen surface with the same size as the primary one that i use for backbuffer well when i execute the app it the windows completely freezes and even though that i can still move the mouse clicking dont works. but if i keep pressing the X button of the app or alt+tab"ing" eventualy it exits the program and that only happens in my computer. but if a change the main loop to:
        
	while(app.MsgHandling() && windowclosed == false)
	{
		}
                        Sleep(30);
			Edraw.BackBufferFlip();
		}
	}
      
the app runs without any problem. well i dont have any $%$&&*! idea of what is happening does anyone knows what may be happening? ------------------------------- MOTHERSHIP!!! hahaha! very funny! now take me outta here!!!!! [edited by - The Alchemist on June 4, 2002 1:44:25 AM]

Share this post


Link to post
Share on other sites
You need you app to do more than flip a buffer every frame. Windows messages work on a thread seperate of your app. That''s why WinProc is never expressly called in your app and messages are "Dispatched" and not "Processed." They''re just put in a message que.

You use the WAIT flag when you flip but in windowed mode, that doesn''t do anything. So basically your app, when just doing flips, is too busy drawing for the thread with the message que to be handled in a timely manner making it "lock up." You just have to do ANYTHING besides flip and it''ll work fine.

There''s nothing wrong with your code. It''s a feature of Windows programming.

Ben


IcarusIndie.com [ The Rabbit Hole | The Labyrinth | Programming | Gang Wars | The Wall | Hosting]

Share this post


Link to post
Share on other sites