DirectX SDK |
This section pertains only to application development in Visual Basic. See DirectDraw C/C++ Tutorials.
In Tutorial 2, the off-screen, back buffer surface was used as a composing surface for the background image and the sprite image. This tutorial again uses a back buffer, but it is part of a complex surface. A complex surface is a set of surfaces created with a single call to the DirectDraw7.CreateSurface method. If the DDSCAPS_COMPLEX flag is set when you call CreateSurface call, DirectDraw implicitly creates one or more surfaces in addition to the surface explicitly specified.
One of the most useful complex surfaces you can create is a flipping chain. Usually, a flipping chain is made of a primary surface and one or more back buffers. The DDSCAPS_FLIP flag indicates that a surface is part of a flipping chain. Creating a flipping chain this way requires that you also include the DDSCAPS_COMPLEX flag.
The Tutorial 2 sample creates a flipping chain with one back buffer with the statements:
ddsd1.lFlags = DDSD_CAPS Or DDSD_BACKBUFFERCOUNT ddsd1.ddsCaps.lCaps = DDSCAPS_PRIMARYSURFACE Or DDSCAPS_FLIP Or DDSCAPS_COMPLEX ddsd1.lBackBufferCount = 1 Set primary = dd.CreateSurface(ddsd1)
Next we create a DDSCAPS2 type variable and set the DDSCAPS_BACKBUFFER flag to specify this is surface description for a back buffer. Then we obtain the created back buffer by using the DirectDrawSurface7.GetAttachedSurface method:
Dim caps As DDSCAPS2 caps.lCaps = DDSCAPS_BACKBUFFER Set backbuffer = primary.GetAttachedSurface(caps)