gkernel.h
来自「巫魔问题求解」· C头文件 代码 · 共 82 行
H
82 行
#pragma once
#include <map>
#include <glut.h>
#include <gl\glaux.h>
#include <string>
#include <list>
#include <vector>
#include <Wum_Base\src\Map.h>
#include <Wum_Server\src\GameEngine.h>
#include <Wum_Server\src\Explorer.h>
namespace _graphics
{
const unsigned int MAX_TEXTURE = 100;
class GKernel
{
private:
//type definitions, no need to explain
typedef std::map<std::string, GLuint> TMapStringGLuint;
typedef std::map<unsigned int, std::string> TMapUintString;
typedef void (*TVoidFunc)(void);
typedef std::vector<TVoidFunc> TVVoidFunc;
typedef std::map<int, TVVoidFunc> TMapIntVVoidFunc;
typedef std::map<int, TMapIntVVoidFunc> TMapIntMapIntVVoidFunc;
typedef std::map<unsigned char, TVVoidFunc> TMapUcharVVoidFunc;
private:
//disable constructors and destructor, only one instance
GKernel(void);
GKernel(const GKernel &from);
~GKernel(void);
public:
//reference, to the only instance
static GKernel &TheGKernel(void);
public:
//init
void Init(void);
//for glutmainloop
void MainLoop(void);
//bind a cell type to a texture file
bool BindBMP(unsigned int type, char *filename);
//bind a explorer status to a texture file
bool BindBMP_Explorer(unsigned int type, char *filename);
//bind the GKernel to a game engine
void BindGameEngine(_server::GameEngine &ge);
//bind the GKernel to an explorer
void BindExplorer(_server::Explorer &explorer);
//regist a function to a keyboard or mouse event
void RegistMouseFunction(int button, int eve, TVoidFunc func);
void RegistKeyFunction(unsigned char key, TVoidFunc func);
void RegistKeyFunction_All(TVoidFunc func);
private:
//for glut use
void GL_Init(void);
static void GLUT_Display(void);
static void GLUT_Reshape(GLsizei w, GLsizei h);
static void GLUT_MouseFunc(int button, int state, int x,int y);
static void GLUT_KeyFunc(unsigned char key, int x,int y);
public:
//int x, int y, int width, int height, std::string texture_name
//bool DrawRect(std::vector<TParameter> para_list);
bool DrawRect(int x, int y, int width, int height, std::string texture_name);
private:
bool mIsBindedExplorer;
//maps, for textures
TMapStringGLuint mMapNameTexture;
TMapUintString mMapEnumName;
TMapUintString mMapExplorerName;
//pointers and references
_server::GameEngine *mpGE;
_server::Explorer *mpExplorer;
//funcs
TMapIntMapIntVVoidFunc mMouseFuncs;
TMapUcharVVoidFunc mKeyFuncs;
TVVoidFunc mKeyFuncsAll;
};
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?