📄 graphics.h
字号:
//--------------------------------------------------
// Desc: 绘图核心类
// Date: 2006.10.29 /update
// Author: artsylee
//
// Copyright (C) 2006 artsylee
//
// 扩展: BeginSprite & EndSprite(2006_11_15)
// // DrawCaptin(2006_11_15)
// // 使用自定义字体(2006_11_15)
// 动画支持(2006_12_7)
// 背景颜色(2006_12_10)
//
//--------------------------------------------------
#ifndef _GRAPHICS_
#define _GRAPHICS_
#include <d3d9.h>
#include <d3dx9.h>
class CTextureManager;
class CFrameManager;
#pragma comment (lib, "d3d9.lib")
#pragma comment (lib, "d3dx9.lib")
class ASE_DLL CGraphics
{
public:
CGraphics();
~CGraphics();
bool InitGraphics(HWND hWnd, int width, int height, bool bWindowed = true, int colordepth = 32);
void ToggleScreen(void);
void SnapToFile(const char *szFileName);
bool BeginScene(void);
void EndScene(void);
void BeginSprite(void);
void EndSprite(void);
// Normal Blt
void Render(IDirect3DTexture9 *pTexture, int x, int y, RECT rcSrc, DWORD color = 0xffffffff);
void Render(DWORD hTex, int x, int y, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
void RenderSprite(DWORD hTex, int x, int y, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
// Scale Blt
void Render(DWORD hTex, const RECT *rcDst, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
// 支持水平翻转和竖直翻转
void Render(DWORD hTex, int x, int y, float xScale, float yScale, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
void RenderSprite(DWORD hTex, const RECT *rcDst, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
// Rotation Blt------------coming soon
// Draw Geometry Primitive
// Animation(Using Sprite)
void RenderAnimation(DWORD hFrm, DWORD index, const RECT *rcDst, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
void RenderAnimation(DWORD hFrm, DWORD index, int x, int y, float xScale, float yScale, const RECT *rcSrc = NULL, DWORD color = 0xffffffff);
void Point(int x, int y, DWORD color);
void Line(int x1, int y1, int x2, int y2, DWORD color);
void Rectangle(RECT rc, DWORD color, bool bFill = false);
void Circle(int x0, int y0, int r, DWORD color);
// 文字
void DrawText(int x, int y, DWORD color, const char *szInfo, ...);
void DrawCaption(int xCenter, int yCenter, DWORD color, const char *szInfo, ...);
// 3D support
void Render3DObject();
bool IsWindowed() { return m_bWindowed; }
void SetBKColor(DWORD color) { m_BackGroundColor = color;}
void SetZBuffer(bool c) { m_bZBuffer = c; }
bool GetZBuffer(void) const { return m_bZBuffer; }
IDirect3DDevice9* GetDevice(void) { return m_pD3DDevice;}
ID3DXSprite* GetSprite(void) { return m_pSprite; }
protected:
void InitDevice(void);
void OnLostDevice(void);
void OnResetDevice(void);
private:
IDirect3D9* m_pD3D;
IDirect3DDevice9* m_pD3DDevice;
ID3DXSprite* m_pSprite;
ID3DXFont* m_pFont;
D3DCAPS9 m_D3DCaps;
D3DPRESENT_PARAMETERS* m_pD3DParam;
D3DPRESENT_PARAMETERS m_D3DParamW;
D3DPRESENT_PARAMETERS m_D3DParamFS;
D3DXMATRIX m_MatProj;
D3DXMATRIX m_MatView;
int m_ScreenWidth;
int m_ScreenHeight;
int m_ScreenDepth;
HWND m_hWnd;
bool m_bWindowed;
bool m_bZBuffer;
DWORD m_BackGroundColor;
CTextureManager* m_pTextureManager;
CFrameManager* m_pFrameManager;
};
#endif // _GRAPHICS
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -