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

📄 interface.h

📁 一个自己写的游戏引擎,用DirectX 写成
💻 H
字号:
//--------------------------------------------------
//  Desc: 引擎主接口
//  Date: 2007.3.12 /update
//  Author: artsylee
//
//  Copyright (C) 2007 artsylee
//
//--------------------------------------------------

#ifndef _INTERFACE_
#define _INTERFACE_

#include <d3d9.h>
#include <d3dx9.h>

//---------------------------------------------------
// Macro Definitions
//---------------------------------------------------
#define INVALID_HANDLE 0x00
#define MSGLEN  1024

#define S_RELEASE(A)			if((A) != NULL) { (A)->Release(); (A) = NULL; } 
#define S_DELETE(X)				if((X) != NULL) { delete (X); (X) = NULL; } 
#define S_DELETE_ARRAY(X)		if((X) != NULL) { delete[] (X); (X) = NULL; } 
#define S_FREE(X)				if((X) != NULL) { free(X); (X)=NULL; } 

// Definitions of useful mathematical constants
#define M_PI		3.14159265358979323846
#define M_PI_2		1.57079632679489661923
#define M_PI_4		0.78539816339744830961
#define M_1_PI		0.31830988618379067153
#define M_2_PI		0.63661977236758134307
#define M_PI_180	0.01745329251994329576
#define M_180_PI	57.2957795130823208768

#define AS_PI		((float)3.141592654f)
#define AS_PIDIV2	((float)1.570796326f)
#define AS_PIDIV4	((float)0.785398163f)
#define AS_1BYPI	((float)0.318309886f)
#define AS_2BYPI	((float)0.636619772f)

#define ToRadian(degree) ((degree)*(AS_PI / 180.0f))
#define ToDegree(radian) ((radian)*(180.0f / AS_PI))

class CGraphics;
class CTextureManager;
class CMessageManager;
class CFrameManager;
class GUIManager;
class CGameApp;
class CLog;
struct stInputInfo;

// System Pointer
ASE_DLL IDirect3DDevice9* __stdcall GetD3DDevice(void);
ASE_DLL CTextureManager* __stdcall GetTextureManager(void);
ASE_DLL CMessageManager* __stdcall GetMessageManager(void);
ASE_DLL CFrameManager* __stdcall GetFrameManager(void);
ASE_DLL GUIManager* __stdcall GetGUIManager(void);
ASE_DLL CGraphics* __stdcall GetGraphics(void);
ASE_DLL CGameApp* __stdcall GetMainApp(void);
ASE_DLL CLog* __stdcall GetLog(void);
//---------------------------------------------------
// 可能需要提供g_pMessageManager接口
//---------------------------------------------------

//---------------------------------------------------
// 状态检测
//---------------------------------------------------
ASE_DLL bool __stdcall IsSupportFSAA(void);

// 2DRender
ASE_DLL void __stdcall Render(DWORD hTex, int x, int y, const RECT *rc = NULL, DWORD color = 0xffffffff);
ASE_DLL void __stdcall Render(DWORD hTex, const RECT *rcdst, const RECT *rc = NULL, DWORD color = 0xffffffff);
ASE_DLL void __stdcall Render(DWORD hTex, int x, int y, float xScale, float yScale, const RECT *rc = NULL, DWORD color = 0xffffffff);
ASE_DLL void __stdcall RenderCenter(DWORD hTex, int centerx, int centery, float xScale, float yScale, const RECT *rc = NULL, DWORD color = 0xffffffff);

// Text
ASE_DLL void __stdcall DrawSingleLine(int x, int y, DWORD color, bool bCenter, const char *pString, ...);
ASE_DLL RECT __stdcall GetFontRect(const char *pString);

// Input
ASE_DLL stInputInfo __stdcall GetInputInfo(void);
ASE_DLL bool __stdcall IsKeyDown(int key);
ASE_DLL bool __stdcall IsMouseDown(unsigned char mouse);
ASE_DLL bool __stdcall GetPointerOffset(long *x, long *y, long *z);

// texture
ASE_DLL DWORD __stdcall LoadTexture(const char *szFilename);
ASE_DLL	DWORD __stdcall LoadAMFTexture(const char *szFilename, DWORD index = 0);
ASE_DLL void __stdcall ReleaseTexture(DWORD hHandle);
ASE_DLL void __stdcall DestroyTexture(DWORD hHandle);

// IniFile
struct Vec2D;
struct Vec3D;
ASE_DLL D3DXVECTOR2 __stdcall Vec2DToD3D(const Vec2D &vec);
ASE_DLL D3DXVECTOR3 __stdcall Vec3DToD3D(const Vec3D &vec);
ASE_DLL Vec2D __stdcall D3DToVec2D(const D3DXVECTOR2 &vec);
ASE_DLL Vec3D __stdcall D3DToVec3D(const D3DXVECTOR3 &vec);

// common function
#ifdef __cplusplus
extern "C"
{
#endif

ASE_DLL void __stdcall ShowMessage(const char *msg,...);
ASE_DLL int __stdcall FloatToIntAver(float fParam);
ASE_DLL int __stdcall RandomInt(int min, int max);
ASE_DLL float __stdcall RandomFloat(float min, float max);

#ifdef __cplusplus
}
#endif

#endif // _INTERFACE_

⌨️ 快捷键说明

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