Definitions and Global Variables
Below are the first lines of the Helworld.c example. Helworld.c is the only C source file required to build this application.
Notice that INITGUID must be defined prior to all other includes and defines. This is a crucial point that is sometimes missed by developers who are new to DirectX.
/////////////////////////////////////////////////////////////////////
//
// Copyright (C) 1996 Microsoft Corporation. All Rights Reserved.
//
// File: Helworld.c
//
// Simplified Direct3D Retained-Mode example, based on
// the "Globe" SDK sample.
//
/////////////////////////////////////////////////////////////////////
#define INITGUID // Must precede other defines and includes
#include <windows.h>
#include <malloc.h> // Required by memset call
#include <d3drmwin.h>
#define MAX_DRIVERS 5 // Maximum D3D drivers expected
// Global variables
LPDIRECT3DRM lpD3DRM; // Direct3DRM object
LPDIRECTDRAWCLIPPER lpDDClipper;// DirectDrawClipper object
struct _myglobs {
LPDIRECT3DRMDEVICE dev; // Direct3DRM device
LPDIRECT3DRMVIEWPORT view; // Direct3DRM viewport through which
// the scene is viewed
LPDIRECT3DRMFRAME scene; // Master frame in which others are
// placed
LPDIRECT3DRMFRAME camera; // Frame describing the user's POV
GUID DriverGUID[MAX_DRIVERS]; // GUIDs of available D3D drivers
char DriverName[MAX_DRIVERS][50]; // Names of available D3D drivers
int NumDrivers; // Number of available D3D drivers
int CurrDriver; // Number of D3D driver currently
// being used
BOOL bQuit; // Program is about to terminate
BOOL bInitialized; // All D3DRM objects are initialized
BOOL bMinimized; // Window is minimized
int BPP; // Bit depth of the current display mode
} myglobs;
// Function prototypes.
static BOOL InitApp(HINSTANCE, int);
long FAR PASCAL WindowProc(HWND, UINT, WPARAM, LPARAM);
static BOOL EnumDrivers(HWND win);
static HRESULT WINAPI enumDeviceFunc(LPGUID lpGuid,
LPSTR lpDeviceDescription, LPSTR lpDeviceName,
LPD3DDEVICEDESC lpHWDesc, LPD3DDEVICEDESC lpHELDesc,
LPVOID lpContext);
static DWORD BPPToDDBD(int bpp);
static BOOL CreateDevAndView(LPDIRECTDRAWCLIPPER lpDDClipper,
int driver, int width, int height);
static BOOL SetRenderState(void);
static BOOL RenderLoop(void);
static BOOL MyScene(LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view,
LPDIRECT3DRMFRAME scene, LPDIRECT3DRMFRAME camera);
void MakeMyFrames(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera,
LPDIRECT3DRMFRAME * lplpLightFrame1,
LPDIRECT3DRMFRAME * lplpWorld_frame);
void MakeMyLights(LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera,
LPDIRECT3DRMFRAME lpLightFrame1,
LPDIRECT3DRMLIGHT * lplpLight1, LPDIRECT3DRMLIGHT * lplpLight2);
void SetMyPositions(LPDIRECT3DRMFRAME lpScene,
LPDIRECT3DRMFRAME lpCamera, LPDIRECT3DRMFRAME lpLightFrame1,
LPDIRECT3DRMFRAME lpWorld_frame);
void MakeMyMesh(LPDIRECT3DRMMESHBUILDER * lplpSphere3_builder);
void MakeMyWrap(LPDIRECT3DRMMESHBUILDER sphere3_builder,
LPDIRECT3DRMWRAP * lpWrap);
void AddMyTexture(LPDIRECT3DRMMESHBUILDER lpSphere3_builder,
LPDIRECT3DRMTEXTURE * lplpTex);
static void CleanUp(void);