From: LMH Date: Wed, 20 Feb 2013 21:09:42 +0000 (-1000) Subject: Temporary fix to redundant glBlindTexture calls, see bug 542 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=e427bb4e3461955104f1e7132352e1c55dc95513;p=supertux.git Temporary fix to redundant glBlindTexture calls, see bug 542 --- diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index 361f30a51..2f1f505ef 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -34,7 +34,8 @@ GLRenderer::GLRenderer() : desktop_size(-1, -1), screen_size(-1, -1), - fullscreen_active(false) + fullscreen_active(false), + last_texture(static_cast (-1)) { Renderer::instance_ = this; @@ -116,7 +117,11 @@ GLRenderer::draw_surface(const DrawingRequest& request) GLTexture* gltexture = static_cast(surface->get_texture().get()); GLSurfaceData *surface_data = static_cast(surface->get_surface_data()); - glBindTexture(GL_TEXTURE_2D, gltexture->get_handle()); + GLuint th = gltexture->get_handle(); + if (th != last_texture) { + last_texture = th; + glBindTexture(GL_TEXTURE_2D, th); + } intern_draw(request.pos.x, request.pos.y, request.pos.x + surface->get_width(), request.pos.y + surface->get_height(), @@ -148,7 +153,11 @@ GLRenderer::draw_surface_part(const DrawingRequest& request) float uv_right = surface_data->get_uv_left() + (uv_width * (surfacepartrequest->source.x + surfacepartrequest->size.x)) / surface->get_width(); float uv_bottom = surface_data->get_uv_top() + (uv_height * (surfacepartrequest->source.y + surfacepartrequest->size.y)) / surface->get_height(); - glBindTexture(GL_TEXTURE_2D, gltexture->get_handle()); + GLuint th = gltexture->get_handle(); + if (th != last_texture) { + last_texture = th; + glBindTexture(GL_TEXTURE_2D, th); + } intern_draw(request.pos.x, request.pos.y, request.pos.x + surfacepartrequest->size.x, request.pos.y + surfacepartrequest->size.y, diff --git a/src/video/gl/gl_renderer.hpp b/src/video/gl/gl_renderer.hpp index 9e208597b..d5d999520 100644 --- a/src/video/gl/gl_renderer.hpp +++ b/src/video/gl/gl_renderer.hpp @@ -109,6 +109,8 @@ private: Size desktop_size; Size screen_size; bool fullscreen_active; + + GLuint last_texture; public: GLRenderer();