mirror of
https://github.com/love2d/love.git
synced 2026-08-12 08:30:56 +02:00
Reset current color after drawing smooth lines.
GL_COLOR_ARRAY used by line smoothing leaves the current color undefined after calling glDrawArrays. This makes it defined again.
This commit is contained in:
@@ -835,15 +835,14 @@ namespace opengl
|
||||
// prepare colors:
|
||||
// even indices in overdraw* point to inner vertices => alpha = current-alpha,
|
||||
// odd indices point to outer vertices => alpha = 0.
|
||||
Colorf tmp;
|
||||
glGetFloatv(GL_CURRENT_COLOR, (GLfloat*)(&tmp));
|
||||
Color color((unsigned char) (tmp.r * 255.0f), (unsigned char) (tmp.g * 255.0f), (unsigned char) (tmp.b * 255.0f), (unsigned char) (tmp.a * 255.0f));
|
||||
GLfloat c[4];
|
||||
glGetFloatv(GL_CURRENT_COLOR, c);
|
||||
|
||||
Color *colors = new Color[count];
|
||||
for (unsigned int i = 0; i < count; ++i)
|
||||
for (size_t i = 0; i < count; ++i)
|
||||
{
|
||||
colors[i] = color;
|
||||
colors[i].a *= int(i%2 == 0); // avoids branching. equiv to colors[i].a *= (i%2==0) ? 1 : 0;
|
||||
colors[i] = Color(c[0] * 255.f, c[1] * 255.f, c[2] * 255.f,
|
||||
c[3] * 255.f * int(i%2 == 0));// avoids branching. equiv to colors[i].a *= (i%2==0) ? 1 : 0;
|
||||
}
|
||||
|
||||
// TODO: overdraw at line start and end
|
||||
@@ -856,6 +855,9 @@ namespace opengl
|
||||
glVertexPointer(2, GL_FLOAT, 0, (const GLvoid*)overdraw_bottom);
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, count);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
// "if GL_COLOR_ARRAY is enabled, the value of the current color is
|
||||
// undefined after glDrawArrays executes"
|
||||
glColor4fv(c);
|
||||
|
||||
delete[] colors;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user