mirror of
https://github.com/love2d/love.git
synced 2026-08-21 21:15:09 +02:00
tweaked drawing a bit more for efficiency's sake
This commit is contained in:
@@ -38,8 +38,9 @@ namespace opengl
|
|||||||
for(unsigned int i = 0; i < MAX_CHARS; i++)
|
for(unsigned int i = 0; i < MAX_CHARS; i++)
|
||||||
{
|
{
|
||||||
glyphs[i] = new Glyph(data->getGlyphData(i));
|
glyphs[i] = new Glyph(data->getGlyphData(i));
|
||||||
glNewList(list + i, GL_COMPILE);
|
|
||||||
glyphs[i]->load();
|
glyphs[i]->load();
|
||||||
|
glNewList(list + i, GL_COMPILE);
|
||||||
|
glyphs[i]->draw(0, 0, 0, 1, 1, 0, 0);
|
||||||
glEndList();
|
glEndList();
|
||||||
widths[i] = data->getGlyphData(i)->getWidth();
|
widths[i] = data->getGlyphData(i)->getWidth();
|
||||||
spacing[i] = data->getGlyphData(i)->getAdvance();
|
spacing[i] = data->getGlyphData(i)->getAdvance();
|
||||||
|
|||||||
@@ -56,6 +56,31 @@ namespace opengl
|
|||||||
unload();
|
unload();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Glyph::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
|
||||||
|
{
|
||||||
|
static Matrix t;
|
||||||
|
|
||||||
|
t.setTransformation(x, y, angle, sx, sy, ox, oy);
|
||||||
|
|
||||||
|
if(texture != 0)
|
||||||
|
glBindTexture(GL_TEXTURE_2D,texture);
|
||||||
|
|
||||||
|
glPushMatrix();
|
||||||
|
|
||||||
|
glMultMatrixf((const GLfloat*)t.getElements());
|
||||||
|
|
||||||
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].x);
|
||||||
|
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].s);
|
||||||
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
|
|
||||||
|
glPopMatrix();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool Glyph::load()
|
bool Glyph::load()
|
||||||
{
|
{
|
||||||
return loadVolatile();
|
return loadVolatile();
|
||||||
@@ -89,14 +114,6 @@ namespace opengl
|
|||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
data->getData());
|
data->getData());
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glVertexPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].x);
|
|
||||||
glTexCoordPointer(2, GL_FLOAT, sizeof(vertex), (GLvoid*)&vertices[0].s);
|
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
|
||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ namespace graphics
|
|||||||
namespace opengl
|
namespace opengl
|
||||||
{
|
{
|
||||||
|
|
||||||
class Glyph : public Volatile
|
class Glyph : public Drawable, public Volatile
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@@ -68,6 +68,8 @@ namespace opengl
|
|||||||
float getWidth() const;
|
float getWidth() const;
|
||||||
float getHeight() const;
|
float getHeight() const;
|
||||||
|
|
||||||
|
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
|
||||||
|
|
||||||
}; // Glyph
|
}; // Glyph
|
||||||
|
|
||||||
} // opengl
|
} // opengl
|
||||||
|
|||||||
Reference in New Issue
Block a user