Fix love.graphics.drawLayer.

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-05-20 15:37:29 -03:00
parent fe81d79c6a
commit e03c763215
10 changed files with 37 additions and 64 deletions
-19
View File
@@ -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*/)
+5 -2
View File
@@ -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);
+3 -1
View File
@@ -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);
}
}
+5 -12
View File
@@ -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
+5 -2
View File
@@ -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.