From b4bacb38a6796a7387d6a8f82f18ad8d1aaa8f11 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 24 Jan 2015 03:21:33 -0400 Subject: [PATCH] Fixed love.graphics.getShader() to return nil when no shader is set, fixed a potential (harmless) OpenGL error when OpenGL ES is used. --HG-- branch : minor --- src/modules/graphics/opengl/Graphics.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/graphics/opengl/Graphics.cpp b/src/modules/graphics/opengl/Graphics.cpp index 2d91859f7..93a9f0121 100644 --- a/src/modules/graphics/opengl/Graphics.cpp +++ b/src/modules/graphics/opengl/Graphics.cpp @@ -226,7 +226,9 @@ bool Graphics::setMode(int width, int height, bool &sRGB) glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST); // Enable textures - glEnable(GL_TEXTURE_2D); + if (!GLAD_ES_VERSION_2_0) + glEnable(GL_TEXTURE_2D); + gl.setTextureUnit(0); // Set pixel row alignment @@ -279,8 +281,10 @@ bool Graphics::setMode(int width, int height, bool &sRGB) Shader::defaultShader = newShader(Shader::defaultCode[renderer]); } - if (!getShader()) - setShader(Shader::defaultShader); + // A shader should always be active, but the default shader shouldn't be + // returned by getShader(), so we don't do setShader(defaultShader). + if (!Shader::current) + Shader::defaultShader->attach(); return true; } @@ -737,6 +741,7 @@ void Graphics::setShader() { DisplayState &state = states.back(); + // This will activate the default shader. Shader::detach(); state.shader.set(nullptr);