mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
Fix love.graphics.drawLayer.
--HG-- branch : minor
This commit is contained in:
@@ -339,22 +339,6 @@ void Graphics::flushStreamDraws()
|
||||
if (sbstate.vertexCount == 0 && sbstate.indexCount == 0)
|
||||
return;
|
||||
|
||||
love::graphics::Shader *prevdefaultshader = nullptr;
|
||||
|
||||
if (sbstate.texture.get())
|
||||
{
|
||||
TextureType textype = sbstate.texture->getTextureType();
|
||||
|
||||
if (textype == TEXTURE_2D_ARRAY && Shader::isDefaultActive())
|
||||
{
|
||||
if (!Shader::standardShaders[Shader::STANDARD_ARRAY])
|
||||
throw love::Exception("Standard array texture shader has not been initialized!");
|
||||
|
||||
prevdefaultshader = Shader::current;
|
||||
Shader::standardShaders[Shader::STANDARD_ARRAY]->attach();
|
||||
}
|
||||
}
|
||||
|
||||
OpenGL::TempDebugGroup debuggroup("Stream vertices flush and draw");
|
||||
|
||||
uint32 attribs = 0;
|
||||
@@ -434,9 +418,6 @@ void Graphics::flushStreamDraws()
|
||||
|
||||
streamBufferState.vertexCount = 0;
|
||||
streamBufferState.indexCount = 0;
|
||||
|
||||
if (prevdefaultshader != nullptr)
|
||||
prevdefaultshader->attach();
|
||||
}
|
||||
|
||||
static void APIENTRY debugCB(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei /*len*/, const GLchar *msg, const GLvoid* /*usr*/)
|
||||
|
||||
@@ -99,11 +99,14 @@ void Mesh::drawInstanced(love::graphics::Graphics *gfx, const love::Matrix4 &m,
|
||||
if (instancecount > 1 && !gl.isInstancingSupported())
|
||||
throw love::Exception("Instancing is not supported on this system.");
|
||||
|
||||
gfx->flushStreamDraws();
|
||||
|
||||
if (Shader::isDefaultActive())
|
||||
Shader::attachDefault(Shader::STANDARD_DEFAULT);
|
||||
|
||||
if (Shader::current && texture.get())
|
||||
Shader::current->checkMainTexture(texture);
|
||||
|
||||
gfx->flushStreamDraws();
|
||||
|
||||
OpenGL::TempDebugGroup debuggroup("Mesh draw");
|
||||
|
||||
uint32 enabledattribs = 0;
|
||||
|
||||
@@ -59,6 +59,9 @@ void ParticleSystem::draw(Graphics *gfx, const Matrix4 &m)
|
||||
|
||||
Graphics::TempTransform transform(gfx, m);
|
||||
|
||||
if (Shader::isDefaultActive())
|
||||
Shader::attachDefault(Shader::STANDARD_DEFAULT);
|
||||
|
||||
if (Shader::current && texture.get())
|
||||
Shader::current->checkMainTexture(texture);
|
||||
|
||||
|
||||
@@ -522,6 +522,8 @@ void Shader::attach()
|
||||
{
|
||||
if (current != this)
|
||||
{
|
||||
Graphics::flushStreamDrawsGlobal();
|
||||
|
||||
gl.useProgram(program);
|
||||
current = this;
|
||||
// retain/release happens in Graphics::setShader.
|
||||
@@ -777,7 +779,7 @@ void Shader::setVideoTextures(Texture *ytexture, Texture *cbtexture, Texture *cr
|
||||
const UniformInfo *info = builtinUniformInfo[builtins[i]];
|
||||
|
||||
if (info != nullptr)
|
||||
sendTextures(info, &textures[i], 1);
|
||||
sendTextures(info, &textures[i], 1, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -60,19 +60,15 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
|
||||
|
||||
gfx->flushStreamDraws();
|
||||
|
||||
Shader *prevdefaultshader = nullptr;
|
||||
|
||||
if (texture.get())
|
||||
{
|
||||
TextureType textype = texture->getTextureType();
|
||||
|
||||
if (textype == TEXTURE_2D_ARRAY && Shader::isDefaultActive())
|
||||
if (Shader::isDefaultActive())
|
||||
{
|
||||
if (!Shader::standardShaders[Shader::STANDARD_ARRAY])
|
||||
throw love::Exception("Standard array texture shader has not been initialized!");
|
||||
Shader::StandardShader defaultshader = Shader::STANDARD_DEFAULT;
|
||||
if (texture->getTextureType() == TEXTURE_2D_ARRAY)
|
||||
defaultshader = Shader::STANDARD_ARRAY;
|
||||
|
||||
prevdefaultshader = Shader::current;
|
||||
Shader::standardShaders[Shader::STANDARD_ARRAY]->attach();
|
||||
Shader::attachDefault(defaultshader);
|
||||
}
|
||||
|
||||
if (Shader::current)
|
||||
@@ -138,9 +134,6 @@ void SpriteBatch::draw(Graphics *gfx, const Matrix4 &m)
|
||||
|
||||
gl.drawElements(GL_TRIANGLES, (GLsizei) quad_indices.getIndexCount(count), gltype, indices);
|
||||
}
|
||||
|
||||
if (prevdefaultshader != nullptr)
|
||||
prevdefaultshader->attach();
|
||||
}
|
||||
|
||||
} // opengl
|
||||
|
||||
@@ -45,11 +45,14 @@ void Text::draw(Graphics *gfx, const Matrix4 &m)
|
||||
if (vbo == nullptr || draw_commands.empty())
|
||||
return;
|
||||
|
||||
gfx->flushStreamDraws();
|
||||
|
||||
if (Shader::isDefaultActive())
|
||||
Shader::attachDefault(Shader::STANDARD_DEFAULT);
|
||||
|
||||
if (Shader::current)
|
||||
Shader::current->checkMainTextureType(TEXTURE_2D, false);
|
||||
|
||||
gfx->flushStreamDraws();
|
||||
|
||||
OpenGL::TempDebugGroup debuggroup("Text object draw");
|
||||
|
||||
// Re-generate the text if the Font's texture cache was invalidated.
|
||||
|
||||
Reference in New Issue
Block a user