⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 application.h

📁 load .x file to application
💻 H
字号:
#ifndef APPLICATION_H
#define APPLICATION_H

// Link in the required libraries
#pragma comment(lib, "d3d9.lib")

#ifdef _DEBUG
#pragma comment(lib, "d3dx9d.lib")
#else
#pragma comment(lib, "d3dx9.lib")
#endif

#pragma comment(lib, "winmm.lib")

#define D3D_DEBUG_INFO

// include necessary headers
#include <windows.h>
#include <d3dx9.h>
#include "DXFont.h"
#include "Utils.h"


// Define the frame time
#define FT m_fTimeForFrame


#define SAFE_RELEASE(i) if(i != NULL)            \
                        {                        \
                            i->Release();        \
                            i = NULL;            \
                        }

// This new macro is for deleting stuff created with new
#define SAFE_DELETE(o) if(o != NULL)             \
                       {                         \
                            delete o;            \
                            o = NULL;            \
                       }



class CApplication  
{
public:
	CApplication();
	virtual ~CApplication();

    void Run(HINSTANCE hInstance, bool bWindowed);

    LRESULT WINAPI MessageProcedure( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam );

protected:

    bool InitializeD3D( D3DDEVICE_CREATION_PARAMETERS dcp );
    bool IsDeviceThere();
    bool CanReset();
    bool ResetDevice();
    bool ToggleFullscreen();
    bool SetPerspective();
    bool WindowSizeChange();

    bool InitializeWindow( int iWidth, int iHeight, bool bWindowed );
    void MyGameLoop();

    virtual bool FirstInitialize() { return true; }  
    virtual bool FinalCleanup() { return true; }     
    virtual bool InvalidateObjects() { return true; }   
    virtual bool RestoreObjects() { return true; }     
    virtual bool PreRender() { return true; }        
    virtual bool Render() { return true; }             


    HWND m_hWnd;
	HINSTANCE m_hInstance;
    bool m_bPaused;
    bool m_bActive;
    bool m_bAlive;
    bool m_bWindowed;
    UINT m_iWndWidth;
    UINT m_iWndHeight;
    char m_strTitle[128];
    char m_strClass[128];

    IDirect3D9* m_pD3D;
    IDirect3DDevice9* m_pD3DDevice;

	ID3DXSprite* m_pD3DSprite;

    D3DPRESENT_PARAMETERS m_d3dpp;
    D3DDEVICE_CREATION_PARAMETERS m_d3ddcp;

    D3DXMATRIX m_matProjection;
    D3DXMATRIX m_matView;

    bool m_bKey[256];

    bool m_bUseQPC;
    DWORD m_dwTotalFrames;
    float m_fTimeForFrame;
    float m_fElapsedTime;
    int m_iAbsoluteTime;

	LARGE_INTEGER	m_llTime;
	LONGLONG		m_llLastTime;  
	LONGLONG		m_llStartTime;     
	LONGLONG		m_llTicksPerSec;    
    
	ULONG m_ulTime;
	ULONG m_ulLastTime;
	ULONG m_ulStartTime;

    void ProcessTimer();
    void PauseTimer(); 
    void InitializeTimer();

    float m_fFPS;
    float m_fAvgFPS;

    CDXFont m_statsFont;
    bool RenderStats();
    bool Error(const char* strErrorText);
    bool m_bShowStats;

    char m_strVertexProcessing[256];

};

#endif




//////////////////////////////////////////////////////////////////////////////////////////////
// This file is copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -