winmain.cpp
上传用户:garry_shen
上传日期:2015-04-15
资源大小:45647k
文件大小:70k
源码类别:

游戏引擎

开发平台:

Visual C++

  1. //-----------------------------------------------------------------------------
  2. // File: rmmain.cpp
  3. //
  4. // Desc: Main file for retained-mode samples. Contains Windows UI and D3DRM
  5. //       initialization/cleanup code.
  6. //
  7. //
  8. // Copyright (C) 1998-1999 Microsoft Corporation. All Rights Reserved.
  9. //-----------------------------------------------------------------------------
  10. #define INITGUID
  11. #include <windows.h>
  12. #include <stdio.h>
  13. #include <string.h>
  14. #include <stdarg.h>
  15. #include <d3drmwin.h>
  16. #include <commdlg.h>
  17. #include "resource.h"
  18. #include "resrc1.h"
  19. #define SAFE_RELEASE(x) if (x != NULL) {x->Release(); x = NULL;}
  20. #define MSG(msg) MessageBox( NULL, msg, "Application Message", MB_OK )
  21. // Functions to build the customize the app for each sample
  22. BOOL BuildScene( LPDIRECT3DRM3 pD3DRM,
  23.  LPDIRECT3DRMDEVICE3 dev,
  24.  LPDIRECT3DRMFRAME3 scene, LPDIRECT3DRMFRAME3 camera );
  25. VOID OverrideDefaults( BOOL* bNoTextures, BOOL* pbResizingDisabled, 
  26.    BOOL* pbConstRenderQuality, CHAR** pstrName );
  27. HRESULT AddItemXFile(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMFRAME3 pScene,const char * filename,D3DVECTOR playerpos,char *cXfileName);
  28. HRESULT LoadXFile(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMFRAME3 pScene,const char *filename,D3DVECTOR playerpos,float fRotation);
  29. HRESULT AddXFile(LPDIRECT3DRM3 g_lpD3DRM,LPDIRECT3DRMFRAME3 pScene,const char * filename);
  30. BOOL AddExit(LPDIRECT3DRM3 pD3DRM,LPDIRECT3DRMFRAME3 pScene,
  31.  LPDIRECT3DRMFRAME3       pMeshFrameExit[],
  32.  LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit[],
  33.  int index,float fX,float fY);
  34. char * PopFileOpenDlg(HWND hWnd);       //Open file dialog
  35. char * PopFileSaveDlg(HWND hWnd);       //Save file dialog 
  36. BOOL LoadStage1(LPDIRECT3DRM3 pD3DRM,LPDIRECT3DRMFRAME3 pScene,char *szXFileName);
  37. BOOL LoadStage2(LPDIRECT3DRM3 pD3DRM,LPDIRECT3DRMFRAME3 pScene,char *szXFileName);
  38. void DeleteExit(LPDIRECT3DRMFRAME3       pMeshFrameExit[],
  39.  LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit[],
  40.  int index);
  41. void ReleaseStage();
  42. void ReleaseExit();
  43. void MoveExit(LPDIRECT3DRMFRAME3 pScene,
  44.   LPDIRECT3DRMFRAME3       pMeshFrameExit,
  45.  LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit,
  46.  float fX,float fY);
  47. void LoadMap(char *szMapFileName);
  48. void LoadNextMap(char *szMapFileName);
  49. //-----------------------------------------------------------------------------
  50. // GLOBAL VARIABLES
  51. //-----------------------------------------------------------------------------
  52. HWND hWnd = NULL;
  53. HWND hCmdDlg = NULL;
  54. HINSTANCE hInstance = NULL;
  55. LPDIRECT3DRM3         g_pD3DRM      = NULL; // D3DRM object
  56. LPDIRECTDRAWCLIPPER   g_pDDClipper  = NULL; // DDrawClipper object
  57. LPDIRECT3DRMDEVICE3   g_pDev     = NULL; // D3DRM device 
  58. LPDIRECT3DRMVIEWPORT2 g_pViewport1   = NULL; // D3DRM viewport
  59. LPDIRECT3DRMVIEWPORT2 g_pViewport2   = NULL; // D3DRM viewport
  60. LPDIRECT3DRMFRAME3    g_pScene1      = NULL; // Root frame for the scene
  61. LPDIRECT3DRMFRAME3    g_pScene2      = NULL; // Root frame for the scene
  62. LPDIRECT3DRMFRAME3    g_pCamera1     = NULL; // Camera's frame
  63. LPDIRECT3DRMFRAME3    g_pCamera2     = NULL; // Camera's frame
  64. LPDIRECT3DRMMESHBUILDER3 pMeshBuilder1 = NULL;
  65. LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase1 = NULL;
  66. LPDIRECT3DRMFRAME3       pMeshFrame1   = NULL;
  67. LPDIRECT3DRMFRAME3       pMeshFrameExit1[10];
  68. LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit1[10];
  69. LPDIRECT3DRMMESHBUILDER3 pMeshBuilder2 = NULL;
  70. LPDIRECT3DRMMESHBUILDER3 pMeshBuilderBase2 = NULL;
  71. LPDIRECT3DRMFRAME3       pMeshFrame2   = NULL;
  72. LPDIRECT3DRMFRAME3       pMeshFrameExit2[10];
  73. LPDIRECT3DRMMESHBUILDER3 pMeshBuilderExit2[10];
  74. #define MAX_DRIVERS 5               // Max # of D3D drivers to enumerate
  75. GUID g_DriverGUID[MAX_DRIVERS];     // GUIDs of the available D3D drivers
  76. CHAR g_DriverName[MAX_DRIVERS][50]; // names of the available D3D drivers
  77. WORD g_wNumDrivers = 0;             // number of available D3D drivers
  78. WORD g_wCurrDriver = 0;             // D3D driver currently being used
  79. D3DRMRENDERQUALITY  g_eRenderQuality;        // Shade, fill and light state
  80. D3DRMTEXTUREQUALITY g_eTextureQuality;       // Texture interpolation
  81. BOOL                g_bDithering    = FALSE; // Dithering enable flag
  82. BOOL                g_bAntialiasing = FALSE; // Antialiasing enable flag
  83. BOOL g_bQuit               = FALSE; // Program is about to terminate
  84. BOOL g_bInitialized        = FALSE; // Objects have been initialized
  85. BOOL g_bMinimized          = FALSE; // Window is minimized
  86. BOOL g_bDrawAFrame         = TRUE; // Render the scene
  87. BOOL g_bNoTextures         = FALSE; // This sample doesn't use any textures
  88. BOOL g_bConstRenderQuality = FALSE; // Whether sample is not constructed
  89.                                     // w/MeshBuilders and so the RenderQuality
  90.                                     // cannot be changed
  91. DWORD g_wBPP;                 // bit depth of the current display mode
  92. WORD  g_wMouseButtons;         // mouse button state
  93. WORD  g_wMouseX;               // mouse cursor x position
  94. WORD  g_wMouseY;               // mouse cursor y position
  95. typedef struct tagExit{
  96. char szEName[128];           //