我正在尝试使用OpenGL渲染freetype字体,遵循http://en.wikibooks.org/wiki/OpenGL_Programming/Modern_OpenGL_Tutorial_Text_Rendering_02上发布的示例.
我已经能够从字体生成纹理图集,创建着色器和创建四边形.我似乎被困在的是将纹理传递到着色器和/或为我的四边形获得正确的UV.现在一直在努力,真的需要帮助.
以下是我用来创建纹理图集的结构.
struct FontCharacter
{
float advanceX;
float advanceY;
float bitmapWidth;
float bitmapHeight;
float bitmapLeft;
float bitmapTop;
float uvOffsetX;
float uvOffsetY;
};
struct FontTextureAtlas
{
GLuint texture;
GLuint textureUniform;
int width;
int height;
FontCharacter characters[128];
FontTextureAtlas(FT_Face face, int h, GLuint tUniform)
{
FT_Set_Pixel_Sizes(face, 0, h);
FT_GlyphSlot glyphSlot = face->glyph;
int roww = 0;
int rowh = 0;
width = 0;
height = 0;
memset(characters, 0, sizeof(FontCharacter));
for (int i = 32; i < 128; i++)
{
if …Run Code Online (Sandbox Code Playgroud)