font.h

来自「有个小游戏」· C头文件 代码 · 共 48 行

H
48
字号
#ifndef __FONT_H
#define __FONT_H

/*
	FONT.H

	The CFont class

	Author: Kevin Hawkins
	Date: 3/29/2001
	Description: The CFont class. Currently only supports Bitmap fonts.

*/

#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>

class CFont
{
private:
	unsigned int texID;		// font texture id
	unsigned int callList;	// font display list
	float r, g, b, a;		// RGBA
	int screenX, screenY;	// screen coordinates
	float xpos, ypos, zpos;	// 3d coordinates

	void LoadTexture();		// loads the TGA font texture
	void CreateCallLists();	// creates the font display list

public:
	CFont();
	CFont(char *name, int size);
	~CFont();

	void Build(char *name, int size);
	void ClearFont();

	void Print(const char *str, ...);

	void SetPos2D(int x, int y) { screenX = x; screenY = y; }
	void SetPos3D(float x, float y, float z) { xpos = x; ypos = y; zpos = z; }

	void SetRGB(float red, float green, float blue) { r = red; g = green; b = blue; a = 1.0; }
	void SetRGBA(float red, float green, float blue, float alpha) { r = red; g = green; b = blue; a = alpha; }
};

#endif

⌨️ 快捷键说明

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