Global Variables

// Application instance handle (set in WinMain). 
 
static HINSTANCE               hAppInstance              = NULL; 
 
// Running in debug mode? 
 
static BOOL                    fDebug                    = FALSE; 
 
// Is the application active? 
 
static BOOL                    fActive                   = TRUE; 
 
// Has the application been suspended? 
 
static BOOL                    fSuspended                = FALSE; 
 
// DirectDraw interfaces 
 
static LPDIRECTDRAW            lpdd                      = NULL; 
static LPDIRECTDRAWSURFACE     lpddPrimary               = NULL; 
static LPDIRECTDRAWSURFACE     lpddDevice                = NULL; 
static LPDIRECTDRAWSURFACE     lpddZBuffer               = NULL; 
static LPDIRECTDRAWPALETTE     lpddPalette               = NULL; 
 
// Direct3D interfaces 
 
static LPDIRECT3D              lpd3d                     = NULL; 
static LPDIRECT3DDEVICE        lpd3dDevice               = NULL; 
static LPDIRECT3DMATERIAL      lpd3dMaterial             = NULL; 
static LPDIRECT3DMATERIAL      lpd3dBackgroundMaterial   = NULL; 
static LPDIRECT3DVIEWPORT      lpd3dViewport             = NULL; 
static LPDIRECT3DLIGHT         lpd3dLight                = NULL; 
static LPDIRECT3DEXECUTEBUFFER lpd3dExecuteBuffer        = NULL; 
 
// Direct3D handles 
 
static D3DMATRIXHANDLE         hd3dWorldMatrix           = 0; 
static D3DMATRIXHANDLE         hd3dViewMatrix            = 0; 
static D3DMATRIXHANDLE         hd3dProjMatrix            = 0; 
static D3DMATERIALHANDLE       hd3dSurfaceMaterial       = 0; 
static D3DMATERIALHANDLE       hd3dBackgroundMaterial    = 0; 
 
// Globals used for selecting the Direct3D device. They are 
// globals because this makes it easy for the enumeration callback 
// function to read and write from them. 
 
static BOOL                    fDeviceFound              = FALSE; 
static DWORD                   dwDeviceBitDepth          = 0; 
static GUID                    guidDevice; 
static char                    szDeviceName[MAX_DEVICE_NAME]; 
static char                    szDeviceDesc[MAX_DEVICE_DESC]; 
static D3DDEVICEDESC           d3dHWDeviceDesc; 
static D3DDEVICEDESC           d3dSWDeviceDesc; 
 
// The screen coordinates of the client area of the window. This 
// rectangle defines the destination into which we blit to update 
// the client area of the window with the results of the 3-D rendering. 
 
static RECT                    rDstRect; 
 
// This rectangle defines the portion of the rendering target surface 
// into which we render. The top-left coordinates of this rectangle 
// are always zero; the right and bottom coordinates give the size of 
// the viewport. 
 
static RECT                    rSrcRect; 
 
// Angle of rotation of the world matrix. 
 
static double                  dAngleOfRotation          = 0.0; 
 
// Predefined transformations. 
 
static D3DMATRIX d3dWorldMatrix = 
{ 
    D3DVAL( 1.0), D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 1.0), D3DVAL( 0.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 1.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 1.0) 
}; 
 
static D3DMATRIX d3dViewMatrix = 
{ 
    D3DVAL( 1.0), D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 1.0), D3DVAL( 0.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 1.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 5.0), D3DVAL( 1.0) 
}; 
 
static D3DMATRIX d3dProjMatrix = 
{ 
    D3DVAL( 2.0), D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 2.0), D3DVAL( 0.0), D3DVAL( 0.0), 
    D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL( 1.0), D3DVAL( 1.0), 
    D3DVAL( 0.0), D3DVAL( 0.0), D3DVAL(-1.0), D3DVAL( 0.0) 
};