Jump to content
  • Advertisement

Archived

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

JohnyB

Setting up DirectDraw

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

I'm trying to set up a window using ddraw with this article but I can't get it to work here's my code...
LPDIRECTDRAW7 lpDD = NULL;
LPDIRECTDRAWSURFACE7 lpDDSPrimary;
LPDIRECTDRAWSURFACE7 lpDDSBack;

DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;

BOOL Init(HWND hwnd)
{
	if(FAILED(DirectDrawCreateEx(NULL,
			 (LPVOID*)&lpDD,
			 IID_IDirectDraw7,NULL)))
	return FALSE;

	if(FAILED(lpDD->SetCooperativeLevel(hwnd,DDSCL_EXCLUSIVE|
										DDSCL_FULLSCREEN|
										DDSCL_ALLOWREBOOT)))
	return FALSE;

	if(FAILED(lpDD->SetDisplayMode(800,600,16,0,0))) 
          return FALSE;

	ZeroMemory(&ddsd,sizeof(ddsd));
	ddsd.dwSize = sizeof(ddsd);
	ddsd.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
	ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|					DDSCAPS_FLIP|DDSCAPS_COMPLEX;
	ddsd.dwBackBufferCount = 1;

     if(FAILED(lpDD->CreateSurface(&ddsd,&lpDDSPrimary,NULL)))    return FALSE;

	if(FAILED(lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack)))
		return FALSE;

	return TRUE;
}
It compiles without any problems but it fails on the GetAttachedSurface() function. It's pretty much the same as in the article but I might have missed something. Thanks in advance for any help [edited by - JohnyB on September 22, 2003 10:54:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
Try this:

if(FAILED(lpDD->CreateSurface(&ddsd,&lpDDSPrimary,NULL)))
{
return FALSE;
}
//

//Setup ddscaps

//

ZeroMemory(&ddscaps, sizeof(ddscaps));
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
//

if(FAILED(lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack)))
{
return FALSE;
}


-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

Share this post


Link to post
Share on other sites
Yup that did it thanks UltimaX

I got another question where can I find good tutorials on DirectDraw 7, and what books do you recommend?

Share this post


Link to post
Share on other sites
You''re welcome. (Matt must have left that part out...)

Anyway, one book I learned a lot from is this one. Look at the contents to the book. Ian goes through and creates a game from scratch using DirectDraw and explains everything. Worth the money. That''s the only book I have that deals with DirectDraw alone. The other books I have just show little bits of DirectDraw.

You could check out my DirectDraw tutorial. You need Visual Basic though. I made a long time ago, but people seem to like it?

Best of luck.

-UltimaX-

"You wished for a white christmas... Now go shovel your wishes!"

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!