Don't unbind shaders.

https://github.com/libgdx/libgdx/pull/5944
This commit is contained in:
NathanSweet 2020-03-11 11:30:24 +01:00
parent 06b532504d
commit fef881730d
2 changed files with 4 additions and 10 deletions

View File

@ -250,11 +250,9 @@ public class NormalMapTest extends ApplicationAdapter {
ShaderProgram.pedantic = false; ShaderProgram.pedantic = false;
if (!program.isCompiled()) throw new IllegalArgumentException("Error compiling shader: " + program.getLog()); if (!program.isCompiled()) throw new IllegalArgumentException("Error compiling shader: " + program.getLog());
program.begin(); program.bind();
program.setUniformi("u_texture", 0); program.setUniformi("u_texture", 0);
program.setUniformi("u_normals", 1); program.setUniformi("u_normals", 1);
program.end();
return program; return program;
} }

View File

@ -118,7 +118,7 @@ public class TwoColorPolygonBatch implements PolygonBatch {
public void begin () { public void begin () {
if (drawing) throw new IllegalStateException("end must be called before begin."); if (drawing) throw new IllegalStateException("end must be called before begin.");
Gdx.gl.glDepthMask(false); Gdx.gl.glDepthMask(false);
shader.begin(); shader.bind();
setupMatrices(); setupMatrices();
drawing = true; drawing = true;
} }
@ -127,7 +127,6 @@ public class TwoColorPolygonBatch implements PolygonBatch {
public void end () { public void end () {
if (!drawing) throw new IllegalStateException("begin must be called before end."); if (!drawing) throw new IllegalStateException("begin must be called before end.");
if (vertexIndex > 0) flush(); if (vertexIndex > 0) flush();
shader.end();
Gdx.gl.glDepthMask(true); Gdx.gl.glDepthMask(true);
if (isBlendingEnabled()) Gdx.gl.glDisable(GL20.GL_BLEND); if (isBlendingEnabled()) Gdx.gl.glDisable(GL20.GL_BLEND);
@ -1384,13 +1383,10 @@ public class TwoColorPolygonBatch implements PolygonBatch {
@Override @Override
public void setShader (ShaderProgram newShader) { public void setShader (ShaderProgram newShader) {
if (shader == newShader) return; if (shader == newShader) return;
if (drawing) { if (drawing) flush();
flush();
shader.end();
}
shader = newShader == null ? defaultShader : newShader; shader = newShader == null ? defaultShader : newShader;
if (drawing) { if (drawing) {
shader.begin(); shader.bind();
setupMatrices(); setupMatrices();
} }
} }