P-155: Phoenix Engine Update 5: Text Rendering
I have finally finished implementing freetype fonts in this project. This was a long process, and much more complex than I thought.
I found that a lot of the tutorials available online were written for older versions of OpenGL, and would not work correctly with the code that I was using.
One of the problems that I noticed was that the output from the FreeType font is in grayscale format. Loading this into a glTexImage2D(), for texturing onto a quad, resulted in a corrupted image for me. This turned out to be because I had used GL_RGB as the “format” parameter in glTexImage2D. I needed to change this to “GL_LUMINANCE”, so that it now looks like this:
glTexImage2D( GL_TEXTURE_2D,
0,
GL_RGB,
face->glyph->bitmap.width,
face->glyph->bitmap.rows,
0,
GL_LUMINANCE,
GL_UNSIGNED_BYTE,
face->glyph->bitmap.buffer
);
The next goal is to get the text properly integrated into my main rendering loop, and include the ability to change to the previous and next pages using Page up and Page Down.
