From 046f2a3084bbc9c15dc335e2058ad468e5b58c6f Mon Sep 17 00:00:00 2001 From: Bill Meltsner Date: Sat, 28 Aug 2010 11:42:37 -0500 Subject: [PATCH] Fixed some bugs with font drawing and reverted the display list change - it was causing problems with multiple fonts --- src/modules/font/GlyphData.cpp | 4 ++-- src/modules/graphics/opengl/Font.cpp | 13 ++++--------- src/modules/graphics/opengl/Glyph.cpp | 1 + 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/modules/font/GlyphData.cpp b/src/modules/font/GlyphData.cpp index af94fdc44..cd5e9dc53 100644 --- a/src/modules/font/GlyphData.cpp +++ b/src/modules/font/GlyphData.cpp @@ -126,8 +126,8 @@ namespace font int pw = next_p2(w); int ph = next_p2(h); unsigned char * d = new unsigned char[pw * ph * (format == GlyphData::FORMAT_LUMINOSITY_ALPHA ? 2 : 4)]; - for (int i = 0; i < pw; i++) { - for (int j = 0; j < ph; j++) { + for (int j = 0; j < ph; j++) { + for (int i = 0; i < pw; i++) { int n = i+j*w; int p = i+j*pw; if (i < w && j < h) { diff --git a/src/modules/graphics/opengl/Font.cpp b/src/modules/graphics/opengl/Font.cpp index 0b49e7442..0072d91da 100644 --- a/src/modules/graphics/opengl/Font.cpp +++ b/src/modules/graphics/opengl/Font.cpp @@ -38,10 +38,7 @@ namespace opengl for(unsigned int i = 0; i < MAX_CHARS; i++) { glyphs[i] = new Glyph(data->getGlyphData(i)); - glyphs[i]->load(); - glNewList(list + i, GL_COMPILE); - glyphs[i]->draw(0, 0, 0, 1, 1, 0, 0); - glEndList(); + glyphs[i]->load(); widths[i] = data->getGlyphData(i)->getWidth(); spacing[i] = data->getGlyphData(i)->getAdvance(); bearingX[i] = data->getGlyphData(i)->getBearingX(); @@ -71,16 +68,14 @@ namespace opengl glTranslatef(ceil(x), ceil(y), 0.0f); glRotatef(LOVE_TODEG(angle), 0, 0, 1.0f); glScalef(sx, sy, 1.0f); - int first = (int)text[0]; - int s = -bearingX[first]; for (unsigned int i = 0; i < text.size(); i++) { int g = (int)text[i]; if (!glyphs[g]) g = 32; // space glPushMatrix(); - glTranslatef(bearingX[g] + s, -bearingY[g]+height, 0.0f); - glCallList(list+g); + glTranslatef(0, height, 0); + glyphs[g]->draw(0, 0, 0, 1, 1, 0, 0); glPopMatrix(); - s += spacing[g] * mSpacing; + glTranslatef(spacing[g], 0, 0); } glPopMatrix(); } diff --git a/src/modules/graphics/opengl/Glyph.cpp b/src/modules/graphics/opengl/Glyph.cpp index 06f431456..0ec12a137 100644 --- a/src/modules/graphics/opengl/Glyph.cpp +++ b/src/modules/graphics/opengl/Glyph.cpp @@ -68,6 +68,7 @@ namespace opengl glPushMatrix(); glMultMatrixf((const GLfloat*)t.getElements()); + glTranslatef(data->getBearingX(), -data->getBearingY(), 0.0f); glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_TEXTURE_COORD_ARRAY);