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

📄 gscreen.h

📁 用FREE BASIC做的演示程序
💻 H
字号:
#ifndef GPP_SCREEN_H_
#define GPP_SCREEN_H_
#define D3D_OVERLOADS
#include<ddraw.h>
#include<d3d.h>
#include<windows.h>
__int64 GetCPUFrequency();
class GScreen
{
public:
	GScreen();
	virtual ~GScreen();
	
public:
	bool CreateWindowed(HWND hWnd,int nWidth,int nHeight);
	bool CreateFullScreen(HWND hWnd,int nWidth,int nHeight);
	void Present();
	bool SwitchDisplayMode();
	
	inline void DrawPixel(int x,int y,unsigned char byColorIndex)
	{
		int pos=y*m_nWidth+x;
		if( pos>=0 && pos<(int)m_dwBufSize)
			m_pBuffer[pos]=byColorIndex;
	}
	inline void UseDefaultPal(bool bUseDefault){m_bDefaultPal=bUseDefault;}
	inline unsigned short* GetPal(){return m_pPal;}
	inline void SetPal(unsigned short *pPal){if(!pPal){for(int i=0;i<256;i++)m_pPal[i]=i|(i<<8);}else memcpy(m_pPal,pPal,sizeof(m_pPal));}
	inline void SetScreenColorKeyIndex(unsigned char byColorKey){m_byScreenColorKeyIndex=byColorKey;}
	inline unsigned char GetScreenColorKeyIndex()const{return m_byScreenColorKeyIndex;}
	inline void ClearBuffer(){memset(m_pBuffer,0,m_dwBufSize);}
	inline unsigned char* GetBuffer(){return m_pBuffer;}
	inline long GetWidth(){return m_nWidth;}
	inline long GetHeight(){return m_nHeight;}
	inline unsigned long GetFPS()	{return m_dwFPS;}
	inline LPDIRECTDRAW7	GetDirectDrawObject() {return m_pDD;}
	inline LPDIRECTDRAWSURFACE7 GetBackSurface(){return m_pDSBack;}
	inline LPDIRECTDRAWSURFACE7 GetFrontSurface(){return m_pDSPrimary;}
	void TextOutDC(int x,int y,unsigned long dwColor,unsigned long dwLineChar,char*txt,...);
	void ClearPrimary();
private:
	void DestroySurface();
	HRESULT RestoreSurface();
	bool CreateDirectDrawObject();

	LPDIRECTDRAW7			m_pDD;
	LPDIRECTDRAWSURFACE7	m_pDSPrimary;
	LPDIRECTDRAWSURFACE7	m_pDSBack;
	
	HWND					m_hWnd;							//hWnd
	BOOL					m_bFullScreen;					//是否全屏幕
	
	short					m_nDesktopBpp;
	short					m_nBpp;							//Blue Dream Support 16bit Only
	long					m_nWidth;						//宽
	long					m_nHeight;						//高
	
	unsigned long			m_dwBufSize;
	unsigned char			*m_pBuffer;						//缓冲区
	
	unsigned long			m_dwFPS;						//FPS

	unsigned char			m_byScreenColorKeyIndex;
	unsigned char			m_bDefaultPal;
	unsigned char			m_bUseVideoMemory;
	unsigned char			m_bRes;

	unsigned short			m_pPal[256];
};
#endif

⌨️ 快捷键说明

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