No Back Surface?!
Hi,
I wrote a procedure to create a complex, primary surface w/ 1 attached back buffer surface.
However, when I query for the back buffer surface using GetAttachedSurface, it returns with DDERR_NOTFOUND. Any idea what''s going on? The relevant code section is below (it''s short).
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
//Resets memory and size
memset(&ddsd, 0, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
//Sets flags for complex, flippable surface w/ back buffer
ddsd.dwFlags = DDSD_CAPS / DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE /
DDSCAPS_FLIP /
DDSCAPS_COMPLEX;
ddsd.dwBackBufferCount = 1;
//Creates the initial surface
if(lpdd->CreateSurface(&ddsd, &lpdds, NULL) != DD_OK)
return(NULL);
//Queries for back surface
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
lpdds->GetAttachedSurface(&ddscaps, &lpddsback);
//The above line returns with DDERR_NOTFOUND
Thanks
You have already declared LPDIRECTDRAWSURFACE lpdds and LPDIRECTDRAWSURFACE lpddsback, right?
Both lpdds and lpddsback have already been declared as LPDIRECTDRAWSURFACE7.
I''m also not getting any compiler errors. So yeah, I''m pretty stumped....
I''m also not getting any compiler errors. So yeah, I''m pretty stumped....
I think the problem is that you don''t fill the DDSCAPS2 structure with zeros before you call the GetAttachedSurface function. Remember to initialize it''s size;-)
Remember the shortcut...
DDSCAPS2 ddsd = {sizeof(ddsd)};
This initializes AND zeroes it out in the same step.
DDSCAPS2 ddsd = {sizeof(ddsd)};
This initializes AND zeroes it out in the same step.
Remember the shortcut...
DDSCAPS2 ddsd = {sizeof(ddsd)};
This initializes AND zeroes it out in the same step.
DDSCAPS2 ddsd = {sizeof(ddsd)};
This initializes AND zeroes it out in the same step.
Here is how I created mine:
LPDIRECTDRAW7 lpDD=NULL;
LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL;
LPDIRECTDRAWSURFACE7 lpDDSBack=NULL;
////////////////////////////////////////////////////////////////////////
// Create the primary surface
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
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;
ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL );
if (ddrval!=DD_OK)
{
ErrStr=Err_CreatePrimarySurf;
return FALSE;
}
// Create the primary back buffer interface
ddscaps.dwCaps=DDSCAPS_BACKBUFFER;
ddrval=lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack);
if (ddrval!= DD_OK)
{
ErrStr=Err_CreateBackSurf;
return FALSE;
}
////////////////////////////////////////////////////////////////////////
and then to blit to the back surface, use:
lpDDSBack->BltFast (x_pos, y_pos, image_surf, &rct, DDBLTFAST_WAIT / DDBLTFAST_SRCCOLORKEY);
and then at the end of all your blitting, use:
lpDDSPrimary->Flip (NULL, DDFLIP_WAIT);
Possibility
LPDIRECTDRAW7 lpDD=NULL;
LPDIRECTDRAWSURFACE7 lpDDSPrimary=NULL;
LPDIRECTDRAWSURFACE7 lpDDSBack=NULL;
////////////////////////////////////////////////////////////////////////
// Create the primary surface
DDSURFACEDESC2 ddsd;
DDSCAPS2 ddscaps;
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;
ddrval = lpDD->CreateSurface( &ddsd, &lpDDSPrimary, NULL );
if (ddrval!=DD_OK)
{
ErrStr=Err_CreatePrimarySurf;
return FALSE;
}
// Create the primary back buffer interface
ddscaps.dwCaps=DDSCAPS_BACKBUFFER;
ddrval=lpDDSPrimary->GetAttachedSurface(&ddscaps,&lpDDSBack);
if (ddrval!= DD_OK)
{
ErrStr=Err_CreateBackSurf;
return FALSE;
}
////////////////////////////////////////////////////////////////////////
and then to blit to the back surface, use:
lpDDSBack->BltFast (x_pos, y_pos, image_surf, &rct, DDBLTFAST_WAIT / DDBLTFAST_SRCCOLORKEY);
and then at the end of all your blitting, use:
lpDDSPrimary->Flip (NULL, DDFLIP_WAIT);
Possibility
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement