Sign in to follow this  
Zero107314

DirectDraw BackBuffer Problem

Recommended Posts

I've got a problem. The last call (GetAttachedSurface) always return an error. Why? Can anyone help me, please?
LPDIRECTDRAW7			lpDD = NULL;				// DirectDraw-Objekt
LPDIRECTDRAWSURFACE7	lpDDSPrimary = NULL;		// FrontBuffer
LPDIRECTDRAWSURFACE7	lpDDSBack = NULL;			// BackBuffer
bool DirectDrawInit(HWND hWnd)
{
	DDSURFACEDESC2 ddsd;
	DDSCAPS2 ddscaps;

	if (FAILED( DirectDrawCreateEx(NULL, (LPVOID*)&lpDD, IID_IDirectDraw7, NULL) )) 
		return(false);
	
	if (FAILED( lpDD->SetCooperativeLevel(hWnd, DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN) )) 
		return(false);
	
	if (FAILED( lpDD->SetDisplayMode(SCREEN_X, SCREEN_Y, SCREEN_D, 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);

	ddscaps.dwCaps = DDSCAPS_BACKBUFFER;

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

	return(true);
}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this