Direct3D Immediate-Mode Tutorial

To create a Windows-based Direct3D Immediate-Mode application, you create DirectDraw and Direct3D objects, set render states, fill execute buffers, and execute those buffers. This section is a tutorial that provides step-by-step instructions for implementing a simple Immediate-Mode application. The sample code in this tutorial is part of this SDK.

The D3dmain.cpp file in the samples provided with this SDK is used as a basis for all of the other Immediate-Mode samples. D3dmain.cpp contains the standard Windows framework of initialization, setting up a message loop, and creating a window procedure for message processing, but it also does some work that is specific to Direct3D Immediate-Mode applications. This work is discussed in the following sections:

·Step 1: Beginning Initialization

·Step 2: Creating DirectDraw and Direct3D Objects

·Step 3: Setting Up the Device-Creation Callback Function

·Step 4: Initializing the Viewport

·Step 5: Setting the Immediate-Mode Render State

·Step 6: Completing Initialization

·Step 7: Running the Rendering Loop

·Step 8: Cleaning Up

The Immediate-Mode samples in this SDK include some code that is not documented here. In particular, this SDK includes a collection of helper functions collectively referred to as the D3DApp functions. You might find them useful when writing your own Immediate-Mode applications. These helper functions are referred to frequently in this documentation but are not covered exhaustively. They are implemented by the D3dapp.c, Ddcalls.c, D3dcalls.c, Texture.c, and Misc.c source files. The Stats.cpp source file sends frame-rate and screen-mode information to the screen.

Every sample that uses D3dmain.cpp must implement the following functions, which enable samples to customize their behavior:

·InitScene

·InitView

·RenderScene

·ReleaseView

·ReleaseScene

·OverrideDefaults

In addition, samples can use the SetMouseCallback and SetKeyboardCallback functions to read mouse and keyboard input.