static void ReportError(HWND hwnd, int nMessage,
HRESULT hRes);
static void FatalError(HWND hwnd, int nMessage, HRESULT hRes);
static DWORD BitDepthToFlags(DWORD dwBitDepth);
static DWORD FlagsToBitDepth(DWORD dwFlags);
static void SetPerspectiveProjection(LPD3DMATRIX lpd3dMatrix,
double dHalfHeight,
double dFrontClipping,
double dBackClipping);
static void SetRotationAboutY(LPD3DMATRIX lpd3dMatrix,
double dAngleOfRotation);
static HRESULT CreateDirect3D(HWND hwnd);
static HRESULT ReleaseDirect3D(void);
static HRESULT CreatePrimary(HWND hwnd);
static HRESULT RestorePrimary(void);
static HRESULT ReleasePrimary(void);
static HRESULT WINAPI EnumDeviceCallback(LPGUID lpGUID,
LPSTR lpszDeviceDesc,
LPSTR lpszDeviceName,
LPD3DDEVICEDESC lpd3dHWDeviceDesc,
LPD3DDEVICEDESC lpd3dSWDeviceDesc,
LPVOID lpUserArg);
static HRESULT ChooseDevice(void);
static HRESULT CreateDevice(DWORD dwWidth, DWORD dwHeight);
static HRESULT RestoreDevice(void);
static HRESULT ReleaseDevice(void);
static LRESULT RestoreSurfaces(void);
static HRESULT FillExecuteBuffer(void);
static HRESULT CreateScene(void);
static HRESULT ReleaseScene(void);
static HRESULT AnimateScene(void);
static HRESULT UpdateViewport(void);
static HRESULT RenderScene(void);
static HRESULT DoFrame(void);
static void PaintSuspended(HWND hwnd, HDC hdc);
static LRESULT OnMove(HWND hwnd, int x, int y);
static LRESULT OnSize(HWND hwnd, int w, int h);
static LRESULT OnPaint(HWND hwnd, HDC hdc, LPPAINTSTRUCT lpps);
static LRESULT OnIdle(HWND hwnd);
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam);
int PASCAL WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpszCommandLine, int cmdShow);