I am writing text rendering for an OpenGL application. Size, color, font, and anti-aliasing can be hidden at runtime (and therefore multiple fonts can appear on the screen at once). Too many combinations to highlight one texture of each combination of string and attributes. However, at any given time, only a small subset of the entire row database will be displayed on the screen.
This leads me to the possibility of creating a cache for lines that print after the frame. It was instructed that I use only one texture for the entire operation, since creating a cache of many textures will result in a fine for exchanging text for each line printed from the cache.
So, I have a 2048x2048 texture in which I can place any lines that I can put when they are requested by the caching application. I quickly realized that tracking the free space available in two-dimensional space is not trivial.
I looked at things like Best Fit and Next fit, but they seem to be suitable for 1d spaces.
How can I control the texture of the cache in OpenGL?
Edit: I have since found out that this is an instance of the "2d" packaging problem.
source
share