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


DDraw Windowed

Recommended Posts

Yo yo, DDraw in fullscreen mode is easy. But I cant figure out windowed mode! Microsoft documentation sucks, they use CDisplay or something... I dont want to use that, and Im sure theres a way to set it up differently to go windowed. Here is my code to set up DDraw fullscreen mode, and all I could use is a modification of it to go windowed.
//STEP 1: Create Direct Draw Object

if(DirectDrawCreate(NULL, &m_Reg_Members.lpDD, NULL)!=DD_OK)
	return E_FAIL;
//STEP 2: Set Cooperative Level with Windows

if(m_Reg_Members.lpDD->SetCooperativeLevel(hwnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN)!=DD_OK)
	return E_FAIL;
//STEP 3: Set Dispay Mode

	if(m_Reg_Members.lpDD->SetDisplayMode(m_ScreenX, m_ScreenY, m_ScreenDepth)!=DD_OK)
		return E_FAIL;
//STEP 4: Set Up Primary Surface

ddsd.dwSize = sizeof(ddsd);
ddsd.dwBackBufferCount = 1;
//STEP 5: Create Primary Surface

if(m_Reg_Members.lpDD->CreateSurface(&ddsd, &m_Reg_Members.lpPrimary, NULL)!=DD_OK)
	return E_FAIL;
//STEP 8: Attach Secondary Surface to Primary Surface

DDSCAPS ddscaps;
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
if(m_Reg_Members.lpPrimary->GetAttachedSurface(&ddscaps, &m_Reg_Members.lpSecondary)!=DD_OK)
	return E_FAIL;
//STEP 11: Create and attach clipper to Secondary

if(m_Reg_Members.lpDD->CreateClipper(NULL, &lpClipper, NULL)!=DD_OK)
	return E_FAIL;
if(lpClipper->SetHWnd(NULL, hwnd)!=DD_OK)
	return E_FAIL;
	return E_FAIL;
[edited by - Mafian on October 18, 2002 6:14:10 PM]

Share this post

Link to post
Share on other sites
A few key differences between windowed and exclusive (fullscreen) DirectDraw is that you must set the cooperation level to DDSCL_NORMAL, you can't set the display mode (you have to use the user's desktop's display mode) and you can't have a backbuffer (at least not the conventional kind you can Flip (), but you can make your own).

As for the actual code, here is a good article by null_pointer:

Part1 -
Part2 -

Good luck!

[edited by - JonWoyame on October 18, 2002 6:34:33 PM]

Share this post

Link to post
Share on other sites
No backbuffer??? Woa!

Read again. You *CAN* have a backbuffer in windowed mode.

However the backbuffer can''t be part of a flip chain or be flipped in the same way as it can in fullscreen mode. When you consider that the whole of the desktop is the primary buffer in windowed mode this makes perfect sense.

What you do in windowed mode is Blt() from your backbuffer (simply an offscreen surface) to the primary buffer.
Since the Blt() will overwrite what''s already on the primary surface, the behaviour is different, but that should only be an issue for you if your app relies on the back buffer containing the previous primary buffer contents.
Instead it simply contains the previous backbuffer contents.

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites