try to fix occasional flickering. only seen on nexus with PowerVR
-> clear stencil region by drawing a quad instead of using glClear(stencil) for each tile
This commit is contained in:
parent
fc96e5f6e8
commit
a95e7d6f31
@ -127,7 +127,6 @@ public class BaseMap {
|
||||
int simpleShader = (pos.tilt < 1 ? 1 : 0);
|
||||
|
||||
for (Layer l = t.layers.layers; l != null;) {
|
||||
|
||||
switch (l.type) {
|
||||
case Layer.POLYGON:
|
||||
l = PolygonRenderer.draw(pos, l, mvp, !clipped, true);
|
||||
@ -145,7 +144,7 @@ public class BaseMap {
|
||||
}
|
||||
}
|
||||
|
||||
//PolygonRenderer.drawOver(mvp);
|
||||
PolygonRenderer.drawOver(mvp);
|
||||
}
|
||||
|
||||
private static int drawProxyChild(MapTile tile, MapPosition pos) {
|
||||
|
@ -239,6 +239,14 @@ public final class PolygonRenderer {
|
||||
*/
|
||||
static void drawStencilRegion(boolean first) {
|
||||
|
||||
// if (!first) {
|
||||
// glStencilMask(0x7F);
|
||||
// GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
|
||||
// // disable drawing to color buffer
|
||||
// glColorMask(false, false, false, false);
|
||||
// glStencilFunc(GL_EQUAL, CLIP_BIT, CLIP_BIT);
|
||||
// }
|
||||
|
||||
// disable drawing to color buffer
|
||||
glColorMask(false, false, false, false);
|
||||
|
||||
@ -247,7 +255,7 @@ public final class PolygonRenderer {
|
||||
|
||||
if (first) {
|
||||
// clear previous clip-region from stencil buffer
|
||||
GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
|
||||
//GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
// Draw clip-region into depth and stencil buffer
|
||||
// this is used for tile line and polygon layers.
|
||||
@ -256,7 +264,7 @@ public final class PolygonRenderer {
|
||||
// draw where no other tile has drawn yet.
|
||||
GLES20.glEnable(GLES20.GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
// test depth and write to depth buffer
|
||||
// test GL_LESS and write to depth buffer
|
||||
GLState.test(true, true);
|
||||
glDepthMask(true);
|
||||
|
||||
@ -286,33 +294,33 @@ public final class PolygonRenderer {
|
||||
}
|
||||
}
|
||||
|
||||
// static void drawOver(float[] matrix) {
|
||||
//
|
||||
// GLState.useProgram(polygonProgram);
|
||||
//
|
||||
// GLState.enableVertexArrays(hPolygonVertexPosition, -1);
|
||||
//
|
||||
// glVertexAttribPointer(hPolygonVertexPosition, 2, GL_SHORT,
|
||||
// false, 0, POLYGON_VERTICES_DATA_POS_OFFSET);
|
||||
//
|
||||
// glUniformMatrix4fv(hPolygonMatrix, 1, false, matrix, 0);
|
||||
//
|
||||
// /* clear stencilbuffer (tile region) by drawing
|
||||
// * a quad with func 'always' and op 'zero' */
|
||||
//
|
||||
// // disable drawing to framebuffer (will be re-enabled in fill)
|
||||
// glColorMask(false, false, false, false);
|
||||
//
|
||||
// // always pass stencil test:
|
||||
// glStencilFunc(GL_ALWAYS, 0x00, 0x00);
|
||||
// // write to all bits
|
||||
// glStencilMask(0xFF);
|
||||
// // zero out area to draw to
|
||||
// glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_ZERO);
|
||||
//
|
||||
// glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
// glColorMask(true, true, true, true);
|
||||
// }
|
||||
static void drawOver(float[] matrix) {
|
||||
if (GLState.useProgram(polygonProgram)) {
|
||||
|
||||
GLState.enableVertexArrays(hPolygonVertexPosition, -1);
|
||||
|
||||
glVertexAttribPointer(hPolygonVertexPosition, 2, GL_SHORT,
|
||||
false, 0, POLYGON_VERTICES_DATA_POS_OFFSET);
|
||||
|
||||
glUniformMatrix4fv(hPolygonMatrix, 1, false, matrix, 0);
|
||||
}
|
||||
|
||||
/* clear stencilbuffer (tile region) by drawing
|
||||
* a quad with func 'always' and op 'zero' */
|
||||
|
||||
// disable drawing to framebuffer (will be re-enabled in fill)
|
||||
glColorMask(false, false, false, false);
|
||||
|
||||
// always pass stencil test:
|
||||
glStencilFunc(GL_ALWAYS, 0x00, 0x00);
|
||||
// write to all bits
|
||||
glStencilMask(0xFF);
|
||||
// zero out area to draw to
|
||||
glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_ZERO);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||
glColorMask(true, true, true, true);
|
||||
}
|
||||
|
||||
private static float[] debugFillColor = { 0.3f, 0.0f, 0.0f, 0.3f };
|
||||
private static float[] debugFillColor2 = { .8f, .8f, .8f, .8f };
|
||||
|
@ -200,9 +200,13 @@ public class GlUtils {
|
||||
}
|
||||
|
||||
public static void setColor(int handle, float[] c, float alpha) {
|
||||
if (alpha >= 1)
|
||||
if (alpha >= 1) {
|
||||
GLES20.glUniform4fv(handle, 1, c, 0);
|
||||
else {
|
||||
} else {
|
||||
if (alpha < 0) {
|
||||
Log.d(TAG, "setColor: " + alpha);
|
||||
alpha = 0;
|
||||
}
|
||||
tmpColor[0] = c[0] * alpha;
|
||||
tmpColor[1] = c[1] * alpha;
|
||||
tmpColor[2] = c[2] * alpha;
|
||||
|
Loading…
x
Reference in New Issue
Block a user