Make OpenGLTextTexture use the smallest texture that is large enough to fit the requested glyph rather than always using 256x256

Originally committed to SVN as r4250.
This commit is contained in:
Thomas Goyne 2010-04-30 03:00:19 +00:00
parent 27a159793a
commit c3a986414c

View file

@ -267,7 +267,7 @@ OpenGLTextGlyph OpenGLText::CreateGlyph(int n) {
// No texture could fit it, create a new one
if (!ok) {
textures.push_back(new OpenGLTextTexture(256,256));
textures.push_back(new OpenGLTextTexture(glyph.w,glyph.h));
textures.back()->TryToInsert(glyph);
}
@ -285,8 +285,9 @@ OpenGLTextGlyph OpenGLText::CreateGlyph(int n) {
OpenGLTextTexture::OpenGLTextTexture(int w,int h) {
// Properties
x = y = nextY = 0;
width = SmallestPowerOf2(w);
height = SmallestPowerOf2(h);
width = max(SmallestPowerOf2(w), 64);
height = max(SmallestPowerOf2(h), 64);
width = height = max(width, height);
tex = 0;
// Generate and bind