mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
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
This commit is contained in:
@@ -226,7 +226,9 @@ bool Graphics::setMode(int width, int height, bool &sRGB)
|
|||||||
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
glHint(GL_GENERATE_MIPMAP_HINT, GL_NICEST);
|
||||||
|
|
||||||
// Enable textures
|
// Enable textures
|
||||||
glEnable(GL_TEXTURE_2D);
|
if (!GLAD_ES_VERSION_2_0)
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
|
||||||
gl.setTextureUnit(0);
|
gl.setTextureUnit(0);
|
||||||
|
|
||||||
// Set pixel row alignment
|
// Set pixel row alignment
|
||||||
@@ -279,8 +281,10 @@ bool Graphics::setMode(int width, int height, bool &sRGB)
|
|||||||
Shader::defaultShader = newShader(Shader::defaultCode[renderer]);
|
Shader::defaultShader = newShader(Shader::defaultCode[renderer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!getShader())
|
// A shader should always be active, but the default shader shouldn't be
|
||||||
setShader(Shader::defaultShader);
|
// returned by getShader(), so we don't do setShader(defaultShader).
|
||||||
|
if (!Shader::current)
|
||||||
|
Shader::defaultShader->attach();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -737,6 +741,7 @@ void Graphics::setShader()
|
|||||||
{
|
{
|
||||||
DisplayState &state = states.back();
|
DisplayState &state = states.back();
|
||||||
|
|
||||||
|
// This will activate the default shader.
|
||||||
Shader::detach();
|
Shader::detach();
|
||||||
|
|
||||||
state.shader.set(nullptr);
|
state.shader.set(nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user