surface.h

来自「这个例子告诉你2d Arpg游戏中的动态阴影如何生成」· C头文件 代码 · 共 54 行

H
54
字号
#ifndef SURFACE_H
#define SURFACE_H
#include <ddraw.h>

/////////////////////////////////////////////////////////////////
//DDraw离屏页面类
/////////////////////////////////////////////////////////////////
class Surface  
{
public:
	void CreateNight();
	void FreeSurface();
	void Init();
	Surface();
	Surface( Surface &surf );
	Surface &operator = ( Surface &surf );
	virtual ~Surface();


	bool CreateImageSurface( char *szFileName, bool isSysMemory, bool isColorKey, DWORD ColorKey );
	bool CreateNullSurface( int iw, int ih, bool isSysMemory, bool isColorKey, DWORD ColorKey );
	bool CreateBmpSurface( char *szFileName, bool isSysMemory, bool isColorKey, DWORD ColorKey );
	bool OnCreateSurface( bool isSysMemory, bool isColorKey );
	bool GetWH( int *pWidth, int *pHeight );
	bool CreateCopySurface();
	void Surface::DrawAlphaShadow( int x, int y );

	void DrawSurface( int x, int y, RECT *pRect );
	void DrawNight( int x, int y, RECT *pRect );
	void DrawAutoClip( int x, int y );
	void DrawAlphaMMX( int x, int y );
	void BltTo( int destX, int destY, Surface *pDestSurf, RECT *rcSrc );
	void WriteText( const char *szText, int TextLen, int x, int y, DWORD Color );

	void  SetSurfaceColorKey( DWORD ColorKey );
	int  GetWidth(){return m_iWidth;}
	int  GetHeight(){return m_iHeight;}
	bool IsEmpty() { return m_lpDDSurface == NULL; }
	bool  IsColorKey() {return m_ColorKeyType == DDBLTFAST_SRCCOLORKEY;}
	bool Restore();
	bool CopySurface( Surface * psurf );
	bool CopySurfaceToBmp( char *szBmpName, RECT *pRect );
	LPDIRECTDRAWSURFACE7 m_lpDDSurface;
	LPDIRECTDRAWSURFACE7 m_lpDDSurfaceCopy;
private:
	DWORD m_ColorKeyType;		//透明色种类
	int	  m_iWidth, m_iHeight;
	static HDC		g_hdc;
	static HFONT	g_hFont;
	static RECT		g_TextRect;
};

#endif // !defined(AFX_SURFACE_H__1119098C_1750_4105_8F44_5DDF2DCCDC6C__INCLUDED_)

⌨️ 快捷键说明

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