You can only have one primary surface in DirectDraw, since that is the surface that represents the image which gets rendered to the screen. You would have to use a secondary surface. Is that what you meant by back/front?
As an alternative, you could make your own double buffer using an array of RGB values (or palette entries if you're using 8-bit colour) the same size as the screen. You don't get the benefit of hardware acceleration this way though. It's probably best to use a secondary surface.
In C/C++ you would create a secondary surface like this, if it helps:
Code:// assuming directdraw object etc set up... DDSURFACEDESC ddsd; // surface description structure LPDIRECTDRAWSURFACE4 lpddsprimary = NULL; // primary surface LPDIRECTDRAWSURFACE4 lpddsback = NULL; // back buffer (secondary surface) memset(&ddsd, 0, sizeof(ddsd); // clear out the description ddsd.dwSize = sizeof(ddsd); // initialise it so it can be used // now set up the description for primary surface ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; ddsd.dwBackBufferCount = 1 // 1 back buffer ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | // set up the DDSCAPS_COMPLEX | // properties DDSCAPS_FLIP; // of the surface // now create the primary surface if (FAILED(lpdd4->CreateSurface(&ddsd, &lpddsprimary, NULL))) return(0) // if failure return error, otherwise... // now edit the surface description for the next function call... ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; // and add a back buffer to the primary surface's flipping chain if (FAILED(lpddsprimary->GetAttachedSurface(&ddsd.ddsCaps, &lpddsback))) return(0) // if failure return error, otherwise... // now you are ready to use the back buffer.




Reply With Quote