Jump to content
  • Advertisement

Archived

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

mmwl

No Back Surface?!

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

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

Share this post


Link to post
Share on other sites
Advertisement
Both lpdds and lpddsback have already been declared as LPDIRECTDRAWSURFACE7.

I''m also not getting any compiler errors. So yeah, I''m pretty stumped....


Share this post


Link to post
Share on other sites
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;-)

Share this post


Link to post
Share on other sites
Remember the shortcut...

DDSCAPS2 ddsd = {sizeof(ddsd)};

This initializes AND zeroes it out in the same step.

Share this post


Link to post
Share on other sites
Remember the shortcut...

DDSCAPS2 ddsd = {sizeof(ddsd)};

This initializes AND zeroes it out in the same step.

Share this post


Link to post
Share on other sites
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

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!