Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e3ba155 authored by Romain Guy's avatar Romain Guy
Browse files

Don't change texture unit when not needed.

Change-Id: Ifa84426d234f2122402cb13533cb5964f1ce95ec
parent 8164c2d3
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -1391,16 +1391,19 @@ void OpenGLRenderer::bindTexture(GLuint texture, GLuint textureUnit) {

void OpenGLRenderer::setTextureWrapModes(Texture* texture, GLenum wrapS, GLenum wrapT,
        GLuint textureUnit) {
    glActiveTexture(gTextureUnits[textureUnit]);
    bool bound = false;
    if (wrapS != texture->wrapS) {
        glActiveTexture(gTextureUnits[textureUnit]);
        glBindTexture(GL_TEXTURE_2D, texture->id);
        bound = true;
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapS);
        texture->wrapS = wrapS;
    }
    if (wrapT != texture->wrapT) {
        if (!bound) glBindTexture(GL_TEXTURE_2D, texture->id);
        if (!bound) {
            glActiveTexture(gTextureUnits[textureUnit]);
            glBindTexture(GL_TEXTURE_2D, texture->id);
        }
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapT);
        texture->wrapT = wrapT;
    }