winmain.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:70k
- //-----------------------------------------------------------------------------
- // File: rmmain.cpp
- //
- // Desc: Main file for retained-mode samples. Contains Windows UI and D3DRM
- // initialization/cleanup code.
- //
- //
- // Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
- //-----------------------------------------------------------------------------
- #define INITGUID
- #include <windows.h>
- #include <stdio.h>
- #include <string.h>
- #include <stdarg.h>
- #include <d3drmwin.h>
- #include <commdlg.h>
- #include "resource.h"
- #include "resrc1.h"
- #define SAFE_RELEASE(x) if (x != NULL) {x->Release(); x = NULL;}
- #define MSG(msg) MessageBox( NULL, msg, "Application Message", MB_OK )
- // Functions to build the customize the app for each sample
- BOOL BuildScene( LPDIRECT3DRM3 pD3DRM,
- LPDIRECT3DRMDEVICE3 dev,
- LPDIRECT3DRMFRAME3 scene, LPDIRECT3DRMFRAME3 camera );
- VOID OverrideDefaults( BOOL* bNoTextures, BOOL* pbResizingDisabled,
- BOOL* pbConstRenderQuality, CHAR** pstrName );
- HRESULT AddItemXFile(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMFRAME3 pScene,const char * filename,D3DVECTOR playerpos,char *cXfileName);
- HRESULT LoadXFile(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMFRAME3 pScene,const char *filename,D3DVECTOR playerpos,float fRotation);
- HRESULT AddXFile(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMFRAME3 pScene,const char * filename);
- BOOL AddExit(LPDIRECT3DRM3 pD3DRM,LPDIRECT3DRMFRAME3 pScene,
- LPDIRECT3DRMFRAME3 pMeshFrameExit[],
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit[],
- int index,float fX,float fY);
- char * PopFileOpenDlg(HWND hWnd); //Open file dialog
- char * PopFileSaveDlg(HWND hWnd); //Save file dialog
- BOOL LoadStage1(LPDIRECT3DRM3 pD3DRM,LPDIRECT3DRMFRAME3 pScene,char *szXFileName);
- BOOL LoadStage2(LPDIRECT3DRM3 pD3DRM,LPDIRECT3DRMFRAME3 pScene,char *szXFileName);
- void DeleteExit(LPDIRECT3DRMFRAME3 pMeshFrameExit[],
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit[],
- int index);
- void ReleaseStage();
- void ReleaseExit();
- void MoveExit(LPDIRECT3DRMFRAME3 pScene,
- LPDIRECT3DRMFRAME3 pMeshFrameExit,
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit,
- float fX,float fY);
- void LoadMap(char *szMapFileName);
- void LoadNextMap(char *szMapFileName);
- //-----------------------------------------------------------------------------
- // GLOBAL VARIABLES
- //-----------------------------------------------------------------------------
- HWND hWnd = NULL;
- HWND hCmdDlg = NULL;
- HINSTANCE hInstance = NULL;
- LPDIRECT3DRM3 g_pD3DRM = NULL; // D3DRM object
- LPDIRECTDRAWCLIPPER g_pDDClipper = NULL; // DDrawClipper object
- LPDIRECT3DRMDEVICE3 g_pDev = NULL; // D3DRM device
- LPDIRECT3DRMVIEWPORT2 g_pViewport1 = NULL; // D3DRM viewport
- LPDIRECT3DRMVIEWPORT2 g_pViewport2 = NULL; // D3DRM viewport
- LPDIRECT3DRMFRAME3 g_pScene1 = NULL; // Root frame for the scene
- LPDIRECT3DRMFRAME3 g_pScene2 = NULL; // Root frame for the scene
- LPDIRECT3DRMFRAME3 g_pCamera1 = NULL; // Camera's frame
- LPDIRECT3DRMFRAME3 g_pCamera2 = NULL; // Camera's frame
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilder1 = NULL;
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase1 = NULL;
- LPDIRECT3DRMFRAME3 pMeshFrame1 = NULL;
- LPDIRECT3DRMFRAME3 pMeshFrameExit1[10];
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit1[10];
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilder2 = NULL;
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase2 = NULL;
- LPDIRECT3DRMFRAME3 pMeshFrame2 = NULL;
- LPDIRECT3DRMFRAME3 pMeshFrameExit2[10];
- LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit2[10];
- #define MAX_DRIVERS 5 // Max # of D3D drivers to enumerate
- GUID g_DriverGUID[MAX_DRIVERS]; // GUIDs of the available D3D drivers
- CHAR g_DriverName[MAX_DRIVERS][50]; // names of the available D3D drivers
- WORD g_wNumDrivers = 0; // number of available D3D drivers
- WORD g_wCurrDriver = 0; // D3D driver currently being used
- D3DRMRENDERQUALITY g_eRenderQuality; // Shade, fill and light state
- D3DRMTEXTUREQUALITY g_eTextureQuality; // Texture interpolation
- BOOL g_bDithering = FALSE; // Dithering enable flag
- BOOL g_bAntialiasing = FALSE; // Antialiasing enable flag
- BOOL g_bQuit = FALSE; // Program is about to terminate
- BOOL g_bInitialized = FALSE; // Objects have been initialized
- BOOL g_bMinimized = FALSE; // Window is minimized
- BOOL g_bDrawAFrame = TRUE; // Render the scene
- BOOL g_bNoTextures = FALSE; // This sample doesn't use any textures
- BOOL g_bConstRenderQuality = FALSE; // Whether sample is not constructed
- // w/MeshBuilders and so the RenderQuality
- // cannot be changed
- DWORD g_wBPP; // bit depth of the current display mode
- WORD g_wMouseButtons; // mouse button state
- WORD g_wMouseX; // mouse cursor x position
- WORD g_wMouseY; // mouse cursor y position
- typedef struct tagExit{
- char szEName[128]; //