Step 5.3: Update the Display

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()
{
    // The g_pddsPrimary variable will be NULL when 
    // the application is in the middle of recreating
    // DirectDraw objects.
    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.