P-155: Phoenix Engine Update 6: Text Rendering
I have now implemented the ability for the player to cycle the text onscreen. Finalising the text rendering took a little more work than I thought, since I had to integrate it into my existing rendering code.
I realised that the main reason for my issues was a slight confusion over the way OpenGL works. Unlike a high-level games engine, OpenGL doesn’t use objects. It is a state machine, which means, instead of doing, for example:
myobject.setrendermode(“wireframe”);
you must first do something like this;
SetModeWireframe
Render Myobject
SetModeNormal
The reason why my text was not appearing properly was simply because I was setting the render mode to wireframe to create an “edged faces” effect around my shapes, like this:
glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );
and I was not turning off wireframe, causing the text to render as an outline. Adding this line after rendering my wireframe fixed this issue:
glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );
I also learned about saving and loading the OpenGL state, which solved a lot of problems I was having with vertex attribute objects not rendering correctly. In OpenGL, is extremely important to reset the state after rendering, by doing something like this:
glBindVertexArray(0);
glDeleteVertexArrays(1, &vao);
I think I have really turned a corner with my knowledge of OpenGL, I have much more of a command of it now. The next step in this project is to enable click-detection, so that the user can select objects in the world.
