My Project
|
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 #pragma once 00029 #include "Define.h" 00030 #include <d3dx9.h> 00031 #include <dinput.h> 00032 #include <vector> 00033 00034 namespace SallyAPI 00035 { 00036 namespace Config 00037 { 00038 class CTheme; 00039 class CLanguageManager; 00040 } 00041 } 00042 00043 namespace SallyAPI 00044 { 00045 namespace Core 00046 { 00047 class CCamera; 00048 } 00049 } 00050 00051 #include "Texture.h" 00052 #include "TextureManager.h" 00053 #include "Font.h" 00054 #include "FontManager.h" 00055 #include "Camera.h" 00056 #include "Counter.h" 00057 #include "Speech.h" 00058 #include "GUIBaseObject.h" 00059 #include "Config.h" 00060 #include "StringHelper.h" 00061 #include "PathHelper.h" 00062 #include "Logger.h" 00063 #include "Option.h" 00064 00065 namespace SallyAPI 00066 { 00067 namespace Core 00068 { 00074 00075 enum DEVICE_STATE {DEVICE_STATE_OK, DEVICE_STATE_LOST, DEVICE_STATE_RESTORED}; 00076 00085 00086 class DLL_API_SALLY CGame 00087 { 00088 protected: 00089 int m_iDeviceId; 00090 int m_iVertexProcessing; 00091 bool m_bWindowd; 00092 bool m_bMultiMonitor; 00093 std::string m_strMonitorId; 00094 int m_iWindowPosX; 00095 int m_iWindowPosY; 00096 int m_iWindowWidth; 00097 int m_iWindowHeight; 00098 float m_fWidthCorrection; 00099 float m_fHeightCorrection; 00100 int m_iScreenColorDepth; 00101 DEVICE_STATE m_eDeviceState; 00102 D3DMULTISAMPLE_TYPE m_MultiSampleType; 00103 00104 static int m_iScreenWidth; 00105 static int m_iScreenHeight; 00106 protected: 00107 // Initialise 00108 bool InitialiseLights(); 00109 bool InitialiseDirect3D(); 00110 bool InitialiseDeviceStates(); 00111 00112 // Create Device 00113 bool CheckDevice(); 00114 void CheckDisplayMode(); 00115 bool InitialisePresentationParameters(); 00116 bool InitialiseDisplayMode(); 00117 00118 bool OnLostDevice(); 00119 bool OnRestoreDevice(); 00120 00121 // The Game 00122 void Render(); 00123 void ExecuteGame(); 00124 protected: 00125 static std::string m_strMediaFolder; 00126 static SallyAPI::System::CLogger* m_pLogger; 00127 static SallyAPI::Core::CCamera* m_pCamera; 00128 static SallyAPI::Core::CCounter* m_pCounter; 00129 00130 static LPDIRECT3DDEVICE9 m_pDirect3DDevice; 00131 static LPD3DXSPRITE m_pSpriteInterface; 00132 static LPDIRECT3D9 m_pDirect3D; 00133 static LPDIRECT3DSURFACE9 m_pBackBuffer; 00134 static LPDIRECT3DSURFACE9 m_pRenderTarget; 00135 00136 static HWND m_hWnd; 00137 static HINSTANCE m_hInst; 00138 00139 D3DDISPLAYMODE m_DisplayMode; 00140 D3DPRESENT_PARAMETERS m_PresentParameters; 00141 00142 // Input Devices 00143 LPDIRECTINPUT8 m_pDirectInput; 00144 LPDIRECTINPUTDEVICE8 m_pKeyboard; 00145 LPDIRECTINPUTDEVICE8 m_pMouse; 00146 LPDIRECTINPUTDEVICE8 m_pGamepad; 00147 00148 // Frame calculation 00149 DWORD m_dwFrames; 00150 DWORD m_dwFramesPerSecond; 00151 DWORD m_dwFramesPerSecondNew; 00152 DWORD m_dwLastFramesPerSecondTime; 00153 00154 // draw counter 00155 static int m_iDrawCount; 00156 static int m_iDrawCountNew; 00157 00158 // Misc 00159 int m_iQuit; 00160 protected: 00161 // Virtuelle Functionen 00162 virtual bool InitialiseEx(); 00163 virtual void ExecuteGameEx(); 00164 00165 virtual void OnCommandDeviceRestoreStart() = 0; 00166 virtual void OnCommandDeviceRestoreEnd() = 0; 00167 virtual void OnCommandDeviceLost() = 0; 00168 virtual void TimerEvent() = 0; 00169 virtual void RenderEx() = 0; 00170 public: 00171 CGame(); 00172 virtual ~CGame(); 00173 00174 static LPDIRECT3DDEVICE9 GetDevice(); 00175 static LPDIRECT3D9 GetD3D(); 00176 00177 static SallyAPI::Core::CCamera* GetCamera(); 00178 static SallyAPI::Core::CCounter* GetCounter(); 00179 static LPD3DXSPRITE GetSpriteInterface(); 00180 static SallyAPI::System::CLogger* GetLogger(); 00181 static HWND GetHWnd(); 00182 static HINSTANCE GetHInstance(); 00183 static int GetScreenWidth(); 00184 static int GetScreenHeight(); 00185 static std::string GetMediaFolder(); 00186 static void SetMediaFolder(const std::string& mediaFolder); 00187 static void IncreaseDrawCount(); 00188 00189 static bool StartRenderToTexture(LPDIRECT3DTEXTURE9 pRenderTexture); 00190 static bool EndRenderToTexture(); 00191 00192 void GameLoop(); 00193 bool Initialise(HWND hWnd, HINSTANCE hInst); 00194 }; 00195 } 00196 }