GLState: keep track of clear color
This commit is contained in:
parent
2833d0f5c2
commit
15023432cc
@ -30,6 +30,7 @@ public class GLState {
|
||||
private static boolean depth = false;
|
||||
private static boolean stencil = false;
|
||||
private static int shader;
|
||||
private static float[] clearColor;
|
||||
|
||||
private static int currentTexId;
|
||||
|
||||
@ -43,6 +44,7 @@ public class GLState {
|
||||
stencil = false;
|
||||
shader = -1;
|
||||
currentTexId = -1;
|
||||
clearColor = null;
|
||||
|
||||
GL.glDisable(GL20.GL_STENCIL_TEST);
|
||||
GL.glDisable(GL20.GL_DEPTH_TEST);
|
||||
@ -131,4 +133,16 @@ public class GLState {
|
||||
currentTexId = id;
|
||||
}
|
||||
}
|
||||
|
||||
public static void setClearColor(float[] color) {
|
||||
if (clearColor != null &&
|
||||
color[0] == clearColor[0] &&
|
||||
color[1] == clearColor[1] &&
|
||||
color[2] == clearColor[2] &&
|
||||
color[3] == clearColor[3])
|
||||
return;
|
||||
|
||||
clearColor = color;
|
||||
GL.glClearColor(color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +50,6 @@ public class MapRenderer {
|
||||
private static int mQuadVerticesID;
|
||||
public final static int maxQuads = 64;
|
||||
|
||||
private static boolean mUpdateColor;
|
||||
|
||||
public static long frametime;
|
||||
private static boolean rerender;
|
||||
|
||||
@ -116,7 +114,6 @@ public class MapRenderer {
|
||||
|
||||
public static void setBackgroundColor(int color) {
|
||||
mClearColor = GLUtils.colorToFloat(color);
|
||||
mUpdateColor = true;
|
||||
}
|
||||
|
||||
static class BufferItem extends Inlist<BufferItem> {
|
||||
@ -179,12 +176,7 @@ public class MapRenderer {
|
||||
}
|
||||
|
||||
private void draw() {
|
||||
|
||||
//if (mUpdateColor) {
|
||||
float cc[] = mClearColor;
|
||||
GL.glClearColor(cc[0], cc[1], cc[2], cc[3]);
|
||||
mUpdateColor = false;
|
||||
//}
|
||||
GLState.setClearColor(mClearColor);
|
||||
|
||||
GL.glDepthMask(true);
|
||||
GL.glStencilMask(0xFF);
|
||||
@ -307,9 +299,6 @@ public class MapRenderer {
|
||||
quad.length * 4, floatBuffer, GL20.GL_STATIC_DRAW);
|
||||
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
|
||||
|
||||
if (mClearColor != null)
|
||||
mUpdateColor = true;
|
||||
|
||||
GLState.init(GL);
|
||||
|
||||
mMap.updateMap(true);
|
||||
|
@ -17,6 +17,7 @@ public class OffscreenRenderer extends LayerRenderer {
|
||||
int texH = -1;
|
||||
|
||||
boolean initialized;
|
||||
private float[] mClearColor = { 0, 0, 0, 0 };
|
||||
|
||||
private boolean useDepthTexture = false;
|
||||
|
||||
@ -160,7 +161,7 @@ public class OffscreenRenderer extends LayerRenderer {
|
||||
GL.glBindFramebuffer(GL20.GL_FRAMEBUFFER, fb);
|
||||
GL.glViewport(0, 0, texW, texH);
|
||||
GL.glDepthMask(true);
|
||||
GL.glClearColor(0, 0, 0, 0);
|
||||
GLState.setClearColor(mClearColor);
|
||||
GL.glClear(GL20.GL_DEPTH_BUFFER_BIT | GL20.GL_COLOR_BUFFER_BIT);
|
||||
|
||||
mRenderer.render(viewport);
|
||||
|
Loading…
x
Reference in New Issue
Block a user