From 6a27e1aa2f15a78a85089aec8d963394f1be0986 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Fri, 12 Apr 2013 15:40:53 -0300 Subject: [PATCH] Ensure the current color is set properly after drawing particlesystems and spritebatches --- src/modules/graphics/opengl/ParticleSystem.cpp | 6 ++++-- src/modules/graphics/opengl/SpriteBatch.cpp | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/graphics/opengl/ParticleSystem.cpp b/src/modules/graphics/opengl/ParticleSystem.cpp index 4dd116df0..ab266cef7 100644 --- a/src/modules/graphics/opengl/ParticleSystem.cpp +++ b/src/modules/graphics/opengl/ParticleSystem.cpp @@ -514,8 +514,9 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo int numParticles = count(); if (numParticles == 0) return; // don't bother if there's nothing to do + Color curcolor = opengl::getCurrentColor(); + glPushMatrix(); - glPushAttrib(GL_CURRENT_BIT); static Matrix t; t.setTransformation(x, y, angle, sx, sy, ox, oy, kx, ky); @@ -576,8 +577,9 @@ void ParticleSystem::draw(float x, float y, float angle, float sx, float sy, flo glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - glPopAttrib(); glPopMatrix(); + + opengl::setCurrentColor(curcolor); } void ParticleSystem::update(float dt) diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index 2145e9bc0..ef312eb9d 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -218,6 +218,8 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float VertexBuffer::Bind array_bind(*array_buf); VertexBuffer::Bind element_bind(*element_buf->getVertexBuffer()); + Color curcolor = opengl::getCurrentColor(); + // Apply per-sprite color, if a color is set. if (color) { @@ -237,7 +239,10 @@ void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float glDisableClientState(GL_TEXTURE_COORD_ARRAY); if (color) + { glDisableClientState(GL_COLOR_ARRAY); + opengl::setCurrentColor(curcolor); + } glPopMatrix(); }