clear stencil after each tile

This commit is contained in:
Hannes Janetzek 2013-01-31 05:43:08 +01:00
parent 2b68d93891
commit f442395a11
2 changed files with 20 additions and 4 deletions

View File

@ -16,6 +16,7 @@ package org.oscim.renderer;
import static android.opengl.GLES20.GL_ARRAY_BUFFER; import static android.opengl.GLES20.GL_ARRAY_BUFFER;
import static android.opengl.GLES20.GL_BLEND; import static android.opengl.GLES20.GL_BLEND;
import static android.opengl.GLES20.glStencilMask;
import static org.oscim.generator.JobTile.STATE_READY; import static org.oscim.generator.JobTile.STATE_READY;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
@ -54,8 +55,9 @@ public class BaseMap {
mDrawCnt = 0; mDrawCnt = 0;
GLES20.glDepthFunc(GLES20.GL_LESS); GLES20.glDepthFunc(GLES20.GL_LESS);
glStencilMask(0xFF);
LineRenderer.beginLines(); LineRenderer.beginLines();
for (int i = 0; i < tileCnt; i++) { for (int i = 0; i < tileCnt; i++) {
MapTile t = tiles[i]; MapTile t = tiles[i];
if (t.isVisible && t.state == STATE_READY) if (t.isVisible && t.state == STATE_READY)
@ -79,6 +81,7 @@ public class BaseMap {
} }
LineRenderer.endLines(); LineRenderer.endLines();
glStencilMask(0x0);
//long end = SystemClock.uptimeMillis(); //long end = SystemClock.uptimeMillis();
//Log.d(TAG, "base took " + (end - start)); //Log.d(TAG, "base took " + (end - start));
@ -144,7 +147,13 @@ public class BaseMap {
break; break;
} }
} }
PolygonRenderer.drawOver(mvp);
glStencilMask(0xFF);
GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
//glStencilMask(0x0);
//PolygonRenderer.drawOver(mvp);
//GLES20.glFlush();
} }
private static int drawProxyChild(MapTile tile, MapPosition pos) { private static int drawProxyChild(MapTile tile, MapPosition pos) {

View File

@ -243,14 +243,20 @@ public final class PolygonRenderer {
return l; return l;
} }
/**
* @param clip ...
* @param first ...
*/
static void drawStencilRegion(boolean clip, boolean first) { static void drawStencilRegion(boolean clip, boolean first) {
GLState.useProgram(polygonProgram); GLState.useProgram(polygonProgram);
// disable drawing to framebuffer (will be re-enabled in fill) // disable drawing to framebuffer (will be re-enabled in fill)
glColorMask(false, false, false, false); glColorMask(false, false, false, false);
// write to all bits if (!first) {
glStencilMask(0xFF); // write to all bits
glStencilMask(0xFF);
}
// set clip bit (0x80) for draw region // set clip bit (0x80) for draw region
glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_REPLACE); glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GLES20.GL_REPLACE);
@ -295,6 +301,7 @@ public final class PolygonRenderer {
} }
static void drawOver(float[] matrix) { static void drawOver(float[] matrix) {
GLState.useProgram(polygonProgram); GLState.useProgram(polygonProgram);
GLState.enableVertexArrays(hPolygonVertexPosition, -1); GLState.enableVertexArrays(hPolygonVertexPosition, -1);