mirror of
https://github.com/love2d/love.git
synced 2026-08-16 16:20:42 +02:00
Merge branch '12.0-development' into GraphicsBuffer
This commit is contained in:
@@ -252,12 +252,11 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
|
||||
// Restore the graphics state.
|
||||
restoreState(states.back());
|
||||
|
||||
int gammacorrect = isGammaCorrect() ? 1 : 0;
|
||||
Shader::Language target = getShaderLanguageTarget();
|
||||
|
||||
// We always need a default shader.
|
||||
for (int i = 0; i < Shader::STANDARD_MAX_ENUM; i++)
|
||||
{
|
||||
auto stype = (Shader::StandardShader) i;
|
||||
|
||||
if (i == Shader::STANDARD_ARRAY && !capabilities.textureTypes[TEXTURE_2D_ARRAY])
|
||||
continue;
|
||||
|
||||
@@ -267,8 +266,10 @@ bool Graphics::setMode(int width, int height, int pixelwidth, int pixelheight, b
|
||||
{
|
||||
if (!Shader::standardShaders[i])
|
||||
{
|
||||
const auto &code = defaultShaderCode[i][target][gammacorrect];
|
||||
Shader::standardShaders[i] = love::graphics::Graphics::newShader(code.source[ShaderStage::STAGE_VERTEX], code.source[ShaderStage::STAGE_PIXEL]);
|
||||
std::vector<std::string> stages;
|
||||
stages.push_back(Shader::getDefaultCode(stype, ShaderStage::STAGE_VERTEX));
|
||||
stages.push_back(Shader::getDefaultCode(stype, ShaderStage::STAGE_PIXEL));
|
||||
Shader::standardShaders[i] = newShader(stages);
|
||||
}
|
||||
}
|
||||
catch (love::Exception &)
|
||||
@@ -1501,18 +1502,6 @@ bool Graphics::isPixelFormatSupported(PixelFormat format, bool rendertarget, boo
|
||||
return supported.value;
|
||||
}
|
||||
|
||||
Shader::Language Graphics::getShaderLanguageTarget() const
|
||||
{
|
||||
if (gl.isCoreProfile())
|
||||
return Shader::LANGUAGE_GLSL3;
|
||||
else if (GLAD_ES_VERSION_3_0)
|
||||
return Shader::LANGUAGE_ESSL3;
|
||||
else if (GLAD_ES_VERSION_2_0)
|
||||
return Shader::LANGUAGE_ESSL1;
|
||||
else
|
||||
return Shader::LANGUAGE_GLSL1;
|
||||
}
|
||||
|
||||
} // opengl
|
||||
} // graphics
|
||||
} // love
|
||||
|
||||
@@ -106,8 +106,6 @@ public:
|
||||
Renderer getRenderer() const override;
|
||||
RendererInfo getRendererInfo() const override;
|
||||
|
||||
Shader::Language getShaderLanguageTarget() const override;
|
||||
|
||||
// Internal use.
|
||||
void cleanupRenderTexture(love::graphics::Texture *texture);
|
||||
|
||||
|
||||
@@ -1061,7 +1061,7 @@ void OpenGL::setTextureUnit(int textureunit)
|
||||
state.curTextureUnit = textureunit;
|
||||
}
|
||||
|
||||
void OpenGL::bindTextureToUnit(TextureType target, GLuint texture, int textureunit, bool restoreprev)
|
||||
void OpenGL::bindTextureToUnit(TextureType target, GLuint texture, int textureunit, bool restoreprev, bool bindforedit)
|
||||
{
|
||||
if (texture != state.boundTextures[target][textureunit])
|
||||
{
|
||||
@@ -1077,9 +1077,14 @@ void OpenGL::bindTextureToUnit(TextureType target, GLuint texture, int textureun
|
||||
else
|
||||
state.curTextureUnit = textureunit;
|
||||
}
|
||||
else if (bindforedit && !restoreprev && textureunit != state.curTextureUnit)
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0 + textureunit);
|
||||
state.curTextureUnit = textureunit;
|
||||
}
|
||||
}
|
||||
|
||||
void OpenGL::bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev)
|
||||
void OpenGL::bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev, bool bindforedit)
|
||||
{
|
||||
TextureType textype = TEXTURE_2D;
|
||||
GLuint handle = 0;
|
||||
@@ -1101,7 +1106,7 @@ void OpenGL::bindTextureToUnit(Texture *texture, int textureunit, bool restorepr
|
||||
handle = getDefaultTexture(textype);
|
||||
}
|
||||
|
||||
bindTextureToUnit(textype, handle, textureunit, restoreprev);
|
||||
bindTextureToUnit(textype, handle, textureunit, restoreprev, bindforedit);
|
||||
}
|
||||
|
||||
void OpenGL::deleteTexture(GLuint texture)
|
||||
|
||||
@@ -318,9 +318,10 @@ public:
|
||||
*
|
||||
* @param textureunit Index in the range of [0, maxtextureunits-1]
|
||||
* @param restoreprev Restore previously bound texture unit when done.
|
||||
* @param bindforedit If false, the active texture unit may be left alone.
|
||||
**/
|
||||
void bindTextureToUnit(TextureType target, GLuint texture, int textureunit, bool restoreprev);
|
||||
void bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev);
|
||||
void bindTextureToUnit(TextureType target, GLuint texture, int textureunit, bool restoreprev, bool bindforedit = true);
|
||||
void bindTextureToUnit(Texture *texture, int textureunit, bool restoreprev, bool bindforedit = true);
|
||||
|
||||
/**
|
||||
* Helper for deleting an OpenGL texture.
|
||||
|
||||
@@ -440,7 +440,7 @@ void Shader::attach()
|
||||
{
|
||||
const TextureUnit &unit = textureUnits[i];
|
||||
if (unit.active)
|
||||
gl.bindTextureToUnit(unit.type, unit.texture, i, false);
|
||||
gl.bindTextureToUnit(unit.type, unit.texture, i, false, false);
|
||||
}
|
||||
|
||||
// send any pending uniforms to the shader program.
|
||||
@@ -637,7 +637,7 @@ void Shader::sendTextures(const UniformInfo *info, love::graphics::Texture **tex
|
||||
int texunit = info->ints[i];
|
||||
|
||||
if (shaderactive)
|
||||
gl.bindTextureToUnit(info->textureType, gltex, texunit, false);
|
||||
gl.bindTextureToUnit(info->textureType, gltex, texunit, false, false);
|
||||
|
||||
// Store texture id so it can be re-bound to the texture unit later.
|
||||
textureUnits[texunit].texture = gltex;
|
||||
|
||||
Reference in New Issue
Block a user