Simplified problem:
I try to show cyclic 4 surfaces: black, red, green and blue. I want to
do this using flipping.
First I create primary surface with 3 back buffers
( lpDDsurfaces[0] )...
// black primary surface
DDSURFACEDESC2 ddsd;
ZeroMemory(&ddsd, sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX |
DDSCAPS_FLIP;
ddsd.dwBackBufferCount = 3;
lpDD->CreateSurface(&ddsd, &lpDDsurfaces[0], NULL);
...after that I try to get back buffers...
// red buffer
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
lpDDsurfaces[0]->GetAttachedSurface(&ddsd.ddsCaps, &lpDDsurfaces[1]);
// green buffer
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
lpDDsurfaces[0]->GetAttachedSurface(&ddsd.ddsCaps, &lpDDsurfaces[2]);
// blue buffer
ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
lpDDsurfaces[0]->GetAttachedSurface(&ddsd.ddsCaps, &lpDDsurfaces[3]);
...then I fill back buffer surfaces with colors...
DDBLTFX ddbltfx;
ddbltfx.dwSize = sizeof(ddbltfx);
ddbltfx.dwFillColor = 0xFF0000;
lpDDSurfaces[1]->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &ddbltfx);
ddbltfx.dwFillColor = 0x00FF00;
lpDDSurfaces[2]->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &ddbltfx);
ddbltfx.dwFillColor = 0x0000FF;
lpDDSurfaces[3]->Blt(NULL, NULL, NULL, DDBLT_COLORFILL, &ddbltfx);
...and finally run loop with flip...
while (true)
{
lpDDsurfaces[0]->Flip(NULL, DDFLIP_WAIT);
// sleep some time
}
Unfortunately, it doesn't work. :-( When I try to change color of 2nd
surface nothing happening. Back buffers seem to point the same place
in memory.
How can I get access to 3 back buffer surfaces? How can I set colors
(or initialize surfaces in other way) and finally run fliping?
Thanks for any help
MarCas
PS. I know correct solution with getting only one attached surface,
but I need separate initialisation from fliping only part of code.