DirectX SDK |
This section pertains only to application development in Visual Basic. See DirectDraw C/C++ Tutorials.
The Tutorial 2 sample uses an off-screen surface as a composing surface. An off-screen surface is a conceptually rectangular area in memory that is generally used to store bitmaps to be blitted to the primary surface. This back buffer will be used to store the images of the lake and the sprite before displaying the composited image to the screen. This surface is created with the following statements:
'Create an invisible surface to draw to be used 'as a compositing surface in system memory 'Indicate that we want to specify the height and width 'The format of the surface (bits per pixel) will be the same 'as the primary surface ddsdBackBuffer.lFlags = DDSD_CAPS Or DDSD_HEIGHT Or DDSD_WIDTH 'Indicate that we want a surface that is not visible and that 'we want it in system memory as opposed to video memory ddsdBackBuffer.ddsCaps.lCaps = DDSCAPS_OFFSCREENPLAIN Or DDSCAPS_SYSTEMMEMORY 'Specify the height and width of the surface to be the same 'as the picture box (note unit are in pixels) ddsdBackBuffer.lWidth = Picture1.Width ddsdBackBuffer.lHeight = Picture1.Height 'Create the requested surface Set objDDBackBuffer = objDD.CreateSurface(ddsdBackBuffer)