afApplication.h
资源名称:AirForce.rar [点击查看]
上传用户:kaiguan
上传日期:2007-10-28
资源大小:1074k
文件大小:4k
源码类别:
其他游戏
开发平台:
Visual C++
- // afApplication.h
- //Program Main Body
- //////////////////////////////////////////////////////////////////////
- #ifndef AF_APPLICATION
- #define AF_APPLICAITON
- #pragma once
- #include "afCamera.h"
- #include "afLog.h"
- #include "afSettings.h"
- #include "afInput.h"
- enum APP_STATE_TYPE
- {
- APPSTATE_LOADSPLASH,
- APPSTATE_DISPLAYSPLASH,
- APPSTATE_ACTIVE
- };
- // Error codes
- #define AFERR_NODIRECT3D 0x00000001
- #define AFERR_NOD3DDEVICE 0x00000002
- #define AFERR_ARTLOADFAILED 0x00000003
- #define AFERR_NOINPUT 0x00000004
- class afTerrain;
- struct CULLINFO
- {
- D3DXVECTOR3 vecFrustum[8]; // corners of the view frustum
- D3DXPLANE planeFrustum[6]; // planes of the view frustum
- };
- struct SCREENVERTEX
- {
- D3DXVECTOR4 p;
- DWORD color;
- FLOAT tu, tv;
- };
- #define D3DFVF_SCREENVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE|D3DFVF_TEX1)
- LRESULT CALLBACK StaticMsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
- class afApplication
- {
- public:
- afApplication();
- HRESULT Create( HINSTANCE hInstance );
- INT Run();
- LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
- VOID SetAppState( DWORD dwAppState ) { m_dwAppState = dwAppState; }
- DWORD GetScreenWidth() { return m_dwScreenWidth; }
- DWORD GetScreenHeight() { return m_dwScreenHeight; }
- float GetAppTime() { return m_fTime; }
- BOOL IsFullScreen() { return m_bFullScreen; }
- HRESULT RenderFrame();
- // Error handling
- VOID CleanupAndDisplayError( DWORD dwError, TCHAR* strArg1, TCHAR* strArg2 );
- protected:
- HRESULT OneTimeSceneInit( HWND hWnd );
- HRESULT UpdateScene();
- VOID FrameMove();
- HRESULT RenderScene();
- VOID FinalCleanup();
- // Display functions
- HRESULT InitDeviceObjects( HWND hWnd );
- HRESULT RestoreDeviceObjects();
- HRESULT InvalidateDeviceObjects();
- HRESULT DeleteDeviceObjects();
- HRESULT SwitchDisplayModes( BOOL bFullScreen, DWORD dwWidth, DWORD dwHeight );
- // Menu functions
- VOID ConstructMenus();
- VOID DestroyMenus();
- VOID UpdateMenus();
- // Rendering functions
- VOID RenderSplash();
- VOID DarkenScene( FLOAT fAmount );
- protected:
- // Misc game functions
- VOID UpdateCullInfo( CULLINFO* pCullInfo, D3DXMATRIXA16* pMatView, D3DXMATRIXA16* pMatProj );
- public:
- DWORD m_dwWindowStyle;
- RECT m_rcWindowBounds;
- RECT m_rcWindowClient;
- BOOL m_bDebugMode;
- BOOL m_bWireMode;
- BOOL m_bPaused;
- TCHAR* m_strAppName;
- HWND m_hWndMain; // Main window
- DWORD m_dwScreenWidth; // Dimensions for fullscreen modes
- DWORD m_dwScreenHeight;
- D3DDISPLAYMODE m_DesktopMode;
- D3DFORMAT m_d3dfmtFullscreen; // Pixel format for fullscreen modes
- D3DFORMAT m_d3dfmtTexture; // Pixel format for textures
- BOOL m_bFullScreen; // Whether app is fullscreen (or windowed)
- BOOL m_bIsActive; // Whether app is active
- BOOL m_bDisplayReady; // Whether display class is initialized
- BOOL m_bMouseVisible; // Whether mouse is visible
- HBITMAP m_hSplashBitmap; // Bitmap for splash screen
- DWORD m_dwAppState; // Current state the app is in
- afTerrain* m_pTerrain;
- // Player view mode
- afCamera m_Camera; // Camera used for 3D scene
- afInput* m_pInput;
- CULLINFO m_cullinfo; // Cull info updated from camera position
- // DirectDraw/Direct3D objects
- HINSTANCE m_hInst;
- D3DPRESENT_PARAMETERS m_d3dpp;
- IDirect3DDevice9* m_pd3dDevice;
- LPDIRECT3DVERTEXBUFFER9 m_pViewportVB;
- FLOAT m_fTime; // Current time in seconds
- FLOAT m_fElapsedTime; // Time elapsed since last frame
- FLOAT m_fFPS; // Instanteous frame rate
- };
- #endif