reset GL program and texture state each frame
This commit is contained in:
parent
4ccc8ed147
commit
113f8180cc
@ -24,6 +24,8 @@ public class GLAdapter {
|
||||
|
||||
public static boolean NON_PREMUL_CANVAS;
|
||||
|
||||
public final static boolean debug = true;
|
||||
|
||||
public static GL20 get() {
|
||||
if (g == null)
|
||||
throw new IllegalStateException();
|
||||
|
||||
@ -41,15 +41,12 @@ public class GLState {
|
||||
|
||||
GL.glDisable(GL20.GL_STENCIL_TEST);
|
||||
GL.glDisable(GL20.GL_DEPTH_TEST);
|
||||
|
||||
// if (currentTexId != 0) {
|
||||
// GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||
// currentTexId = 0;
|
||||
// }
|
||||
}
|
||||
|
||||
public static boolean useProgram(int shaderProgram) {
|
||||
if (shaderProgram != shader) {
|
||||
if (shaderProgram < 0) {
|
||||
shader = -1;
|
||||
} else if (shaderProgram != shader) {
|
||||
GL.glUseProgram(shaderProgram);
|
||||
shader = shaderProgram;
|
||||
return true;
|
||||
@ -120,13 +117,10 @@ public class GLState {
|
||||
}
|
||||
|
||||
public static void bindTex2D(int id) {
|
||||
// if (GLAdapter.GDX_DESKTOP_QUIRKS){
|
||||
// GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||
//if (GLAdapter.GDX_DESKTOP_QUIRKS && id != 0)
|
||||
// GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||
// } else
|
||||
|
||||
if (currentTexId != id) {
|
||||
if (id < 0) {
|
||||
GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||
currentTexId = 0;
|
||||
} else if (currentTexId != id) {
|
||||
GL.glBindTexture(GL20.GL_TEXTURE_2D, id);
|
||||
currentTexId = id;
|
||||
}
|
||||
|
||||
@ -260,7 +260,8 @@ public class MapRenderer {
|
||||
}
|
||||
|
||||
//Log.d(TAG, "begin frame");
|
||||
GLState.bindTex2D(0);
|
||||
GLState.bindTex2D(-1);
|
||||
GLState.useProgram(-1);
|
||||
//GL.glBindTexture(GL20.GL_TEXTURE_2D, 0);
|
||||
|
||||
/* update layers */
|
||||
@ -276,6 +277,9 @@ public class MapRenderer {
|
||||
|
||||
renderer.update(pos, changed, mMatrices);
|
||||
|
||||
if (GLAdapter.debug)
|
||||
GLUtils.checkGlError(renderer.getClass().getName());
|
||||
|
||||
if (renderer.isReady)
|
||||
renderer.render(mMapPosition, mMatrices);
|
||||
}
|
||||
@ -317,6 +321,9 @@ public class MapRenderer {
|
||||
GL.glDisable(GL20.GL_CULL_FACE);
|
||||
GL.glBlendFunc(GL20.GL_ONE, GL20.GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GL.glFrontFace(GL20.GL_CW);
|
||||
GL.glCullFace(GL20.GL_BACK);
|
||||
|
||||
if (!mNewSurface) {
|
||||
mMap.updateMap(false);
|
||||
return;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user