This repository offers a highly optimized method for rendering text in Modern OpenGL. By utilizing a font atlas and binding textures only once for an entire group of text, this approach significantly improves efficiency compared to rendering characters individually. This repository can be used as a helpful resource for developers who want to improve the performance of text rendering in their OpenGL projects.
Rendering text in OpenGL can be inefficient when using a method that binds textures and vertex/index buffers for every single character. This repository offers an alternative solution for rendering text more efficiently with a single texture and index bind.
The repository uses Freetype to load the font.ttf file and create an atlas for every character. The atlas stores the character size, bearing, and texture coordinates, and creates a 2D texture with all the textures aligned in a straight manner. By assigning the appropriate texture coordinate when creating the vertex buffer, the method becomes much more efficient.
The main component for rendering text with a single bind is the Font_atlas.cpp and Font_atlas.h files.
To use this repository in your OpenGL project, simply include the Font_atlas.cpp and Font_atlas.h files in your project directory and add them to your project build settings. Then, initialize the font atlas and render your text using the render_text() function.
By using this repository, you can significantly improve the efficiency of text rendering in your OpenGL projects.
Below is the example implementation in another app. Batch rendering of n-number of text in one draw call.