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