Platform SDK: DirectX

Step 4: Execute the Rendering Loop

[C++]

This section pertains only to application development in Visual Basic. See Direct3D Immediate Mode C/C++ Tutorials.

[Visual Basic]

After you have created the application window, created the DirectX objects, and initialized the scene, you are ready to render the scene. The rendering loop in the Triangle tutorial code renders the scene by calling the application-defined subroutines RenderScene and FrameMove :

    Do While g_bRunning = True
        CNT = CNT + 1
        RenderScene
        FrameMove (CNT / 360)
        
        g_dx.GetWindowRect Me.hWnd, g_rcDest
    
        j = g_ddsPrimary.Blt(g_rcDest, g_ddsBackBuffer, g_rcSrc, DDBLT_WAIT)
        If j <> DD_OK Then
            MsgBox "Couldn't copy the source rectangle to the destination surface." & _
                    Chr$(13) & Hex(j)
            End
        End If
        DoEvents
    Loop

Although the rendering loop appears to be infinite, it terminates when the Form_Unload procedure is triggered. For more information, see Step 5: Shut Down.

The rendering loop subdivides the scene rendering task into the following steps: