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

📄 opengl.h

📁 小型的3D游戏引擎
💻 H
字号:
#ifndef _OPENGL_H_
#define _OPENGL_H_

#include <windows.h>
#include <gl\gl.h>
#include <gl\glu.h>
#include <gl\glaux.h>
#include "../singleton.h"

static PIXELFORMATDESCRIPTOR m_pfd;

class GcOpenGL : public Singleton<GcOpenGL>
{
public:
	GcOpenGL();
	~GcOpenGL();

	// Intialize / shut down open gl
	bool Init( HWND hParent, int width, int height, int depth );
	bool Close();

	// Set the view mode of the screen
	void SetPerspective(int iWidth, int iHeight);

	// Clear the screen / flip the buffers
	void Clear()	{ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); }
	void Flip()		{ glFlush(); SwapBuffers(hDC); }

	bool HasVertexArraySupport() { return m_vertexArraySupport; }
	bool HasMultiTextureSupport() { return m_multiTextureSupport; }
	bool HasFogSupport() { return m_fogSupport; }

	HWND GetWindowHandle() { return m_hWnd; }

private:

	bool SetupPixelFormat();
	bool SetupGLWindow();
	void SetupGLState();

	void SetupMultitexturing();
	void SetupFog();
	void SetupVertexArrayRange();

	bool CheckSupport( char * check, char * str );

	HGLRC		hRC;
	HDC			hDC;
	HWND		m_hWnd;
	GLuint		iPixelFormat;
	int			m_screenWidth;
	int			m_screenHeight;
	int			m_screenDepth;
	
	// FIXME: Convert to hash table
	bool		m_multiTextureSupport;
	bool		m_vertexArraySupport;
	bool		m_fogSupport;
};

#endif

⌨️ 快捷键说明

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