Geometries now automatically use per-vertex colors when drawing if any vertex has a custom color set, otherwise the constant color is used.

Still not a perfect solution, but it works better than before
This commit is contained in:
Alex Szpakowski
2013-04-23 23:25:45 -07:00
parent a5eaffe625
commit 3b05ec0635
7 changed files with 78 additions and 41 deletions
+13 -4
View File
@@ -106,13 +106,22 @@ void Image::drawg(love::graphics::Geometry *geom, float x, float y, float angle,
static Matrix t;
t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky);
// use colors stored in geometry (horrible, horrible hack)
const vertex *v = geom->getVertexArray();
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *)&v->r);
// use colors stored in geometry (horrible, horrible hack)
if (geom->hasVertexColors())
{
glEnableClientState(GL_COLOR_ARRAY);
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(vertex), (GLvoid *) &v[0].r);
}
drawv(t, v, geom->getVertexArraySize(), GL_TRIANGLES);
glDisableClientState(GL_COLOR_ARRAY);
if (geom->hasVertexColors())
{
glDisableClientState(GL_COLOR_ARRAY);
gl.setColor(gl.getColor());
}
}
void Image::uploadCompressedMipmaps()