From: Matthias Braun Date: Sun, 27 May 2007 11:32:00 +0000 (+0000) Subject: fix broken color state management X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=20478842796ab18418ca69966047148dfacdf27a;p=supertux.git fix broken color state management SVN-Revision: 5063 --- diff --git a/src/video/drawing_context.cpp b/src/video/drawing_context.cpp index 60faef5b7..8633956dc 100644 --- a/src/video/drawing_context.cpp +++ b/src/video/drawing_context.cpp @@ -380,6 +380,7 @@ DrawingContext::draw_gradient(const DrawingRequest& request) const glVertex2f(0, SCREEN_HEIGHT); glEnd(); glEnable(GL_TEXTURE_2D); + glColor4f(1, 1, 1, 1); } void @@ -413,6 +414,8 @@ DrawingContext::draw_filled_rect(const DrawingRequest& request) const glVertex2f(x, y+h); glEnd(); glEnable(GL_TEXTURE_2D); + + glColor4f(1, 1, 1, 1); } void diff --git a/src/video/surface.cpp b/src/video/surface.cpp index 23ff69389..fc0f870bc 100644 --- a/src/video/surface.cpp +++ b/src/video/surface.cpp @@ -135,7 +135,7 @@ static inline void intern_draw(float left, float top, float right, float bottom, static inline void intern_draw2(float left, float top, float right, float bottom, float uv_left, float uv_top, float uv_right, float uv_bottom, - float angle, + float angle, float alpha, const Color& color, const Blend& blend, DrawingEffect effect) @@ -159,7 +159,7 @@ static inline void intern_draw2(float left, float top, float right, float bottom bottom -= center_y; glBlendFunc(blend.sfactor, blend.dfactor); - glColor4f(color.red, color.green, color.blue, color.alpha); + glColor4f(color.red, color.green, color.blue, color.alpha * alpha); glBegin(GL_QUADS); glTexCoord2f(uv_left, uv_top); glVertex2f(left*ca - top*sa + center_x, @@ -186,13 +186,13 @@ static inline void intern_draw2(float left, float top, float right, float bottom void Surface::draw(float x, float y, float alpha, float angle, const Color& color, const Blend& blend, DrawingEffect effect) const { - glColor4f(1.0f, 1.0f, 1.0f, alpha); glBindTexture(GL_TEXTURE_2D, texture->get_handle()); intern_draw2(x, y, x + width, y + height, uv_left, uv_top, uv_right, uv_bottom, angle, + alpha, color, blend, effect); @@ -201,12 +201,13 @@ Surface::draw(float x, float y, float alpha, float angle, const Color& color, co void Surface::draw(float x, float y, float alpha, DrawingEffect effect) const { - glColor4f(1.0f, 1.0f, 1.0f, alpha); glBindTexture(GL_TEXTURE_2D, texture->get_handle()); + glColor4f(1, 1, 1, alpha); intern_draw(x, y, x + width, y + height, uv_left, uv_top, uv_right, uv_bottom, effect); + glColor4f(1, 1, 1, 1); } void @@ -222,10 +223,11 @@ Surface::draw_part(float src_x, float src_y, float dst_x, float dst_y, float uv_right = this->uv_left + (uv_width * (src_x + width)) / this->width; float uv_bottom = this->uv_top + (uv_height * (src_y + height)) / this->height; - glColor4f(1.0f, 1.0f, 1.0f, alpha); glBindTexture(GL_TEXTURE_2D, texture->get_handle()); + glColor4f(1, 1, 1, alpha); intern_draw(dst_x, dst_y, dst_x + width, dst_y + height, uv_left, uv_top, uv_right, uv_bottom, effect); + glColor4f(1, 1, 1, 1); }