refactor to use less gl calls

This commit is contained in:
Hannes Janetzek 2013-01-30 08:10:49 +01:00
parent dd74e1aa7b
commit 4be1e5dd4d

View File

@ -246,7 +246,7 @@ public final class PolygonRenderer {
glColorMask(true, true, true, false); glColorMask(true, true, true, false);
} }
// clip bit must be zero // clip to the region where highest bit is zero
glStencilFunc(GL_EQUAL, 0x00, 0x80); glStencilFunc(GL_EQUAL, 0x00, 0x80);
} }
@ -254,12 +254,10 @@ public final class PolygonRenderer {
} }
static void drawStencilRegion(boolean clip, boolean first) { static void drawStencilRegion(boolean clip, boolean first) {
/* clear stencilbuffer (tile region) by drawing GLState.useProgram(polygonProgram);
* a quad with func 'always' and op 'zero' */
// 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);
GLES20.glUniform4f(hPolygonColor, 0.7f, 0.7f, 0.7f, 1);
// write to all bits // write to all bits
glStencilMask(0xFF); glStencilMask(0xFF);
@ -281,13 +279,13 @@ public final class PolygonRenderer {
// write to depth buffer // write to depth buffer
glDepthMask(true); glDepthMask(true);
} }
else { }
// use clip region from stencil buffer if (!clip || first) {
glStencilFunc(GL_EQUAL, 0x00, 0x80);
}
} else {
// always pass stencil test: // always pass stencil test:
glStencilFunc(GL_ALWAYS, 0x00, 0x00); glStencilFunc(GL_ALWAYS, 0x00, 0x00);
} else {
// use clip region from stencil buffer
glStencilFunc(GL_EQUAL, 0x00, 0x80);
} }
// draw a quad for the tile region // draw a quad for the tile region
@ -301,10 +299,12 @@ public final class PolygonRenderer {
GLState.test(false, true); GLState.test(false, true);
GLES20.glDisable(GLES20.GL_POLYGON_OFFSET_FILL); GLES20.glDisable(GLES20.GL_POLYGON_OFFSET_FILL);
} else {
glStencilFunc(GL_ALWAYS, 0x00, 0x00);
} }
} }
if (first) {
glStencilFunc(GL_EQUAL, 0x00, 0x80);
}
} }
static void drawOver(float[] matrix) { static void drawOver(float[] matrix) {