DirectX SDK

Step 5.3: Update the Display

[Visual Basic]

The information in this section pertains only to applications written in C and C++. See Direct3D Immediate Mode Visual Basic Tutorials.

[C++]

Once a scene has been rendered to the render-target surface, you can show the results on screen. A windowed application usually does this by blitting the content of the render-target surface to the primary surface, and a full-screen application that employs page-flipping would simply flip the surfaces in the flipping chain. The Triangle sample uses the former method because it runs in a window, using the following code:

HRESULT ShowFrame()
{
    if( NULL == g_pddsPrimary )
        return E_FAIL;
 
    // We are in windowed mode, so perform a blit from the backbuffer to the
    // correct position on the primary surface
    return g_pddsPrimary->Blt( &g_rcScreenRect, g_pddsBackBuffer, 
                               &g_rcViewportRect, DDBLT_WAIT, NULL );
}

Note that the preceding application-defined function simply blits the entire contents of the render target surface to the window on the desktop. The tutorial tracks the destination rectangle for the blit in the g_rcScreenRect global variable. This rectangle is updated whenever the user moves the window, as covered in the Handle Window Movement section.