keep track of GL_BLEND state: GLState.blend(enable)
This commit is contained in:
parent
f442395a11
commit
e99a4279bf
@ -15,7 +15,6 @@
|
|||||||
package org.oscim.renderer;
|
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.glStencilMask;
|
import static android.opengl.GLES20.glStencilMask;
|
||||||
import static org.oscim.generator.JobTile.STATE_READY;
|
import static org.oscim.generator.JobTile.STATE_READY;
|
||||||
|
|
||||||
@ -130,7 +129,6 @@ public class BaseMap {
|
|||||||
|
|
||||||
switch (l.type) {
|
switch (l.type) {
|
||||||
case Layer.POLYGON:
|
case Layer.POLYGON:
|
||||||
GLES20.glDisable(GL_BLEND);
|
|
||||||
l = PolygonRenderer.draw(pos, l, mvp, !clipped, true);
|
l = PolygonRenderer.draw(pos, l, mvp, !clipped, true);
|
||||||
clipped = true;
|
clipped = true;
|
||||||
break;
|
break;
|
||||||
@ -140,8 +138,6 @@ public class BaseMap {
|
|||||||
PolygonRenderer.draw(pos, null, mvp, true, true);
|
PolygonRenderer.draw(pos, null, mvp, true, true);
|
||||||
clipped = true;
|
clipped = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLES20.glEnable(GL_BLEND);
|
|
||||||
l = LineRenderer.draw(pos, l, mvp, div, simpleShader,
|
l = LineRenderer.draw(pos, l, mvp, div, simpleShader,
|
||||||
t.layers.lineOffset);
|
t.layers.lineOffset);
|
||||||
break;
|
break;
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package org.oscim.renderer;
|
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_DYNAMIC_DRAW;
|
import static android.opengl.GLES20.GL_DYNAMIC_DRAW;
|
||||||
import static android.opengl.GLES20.GL_ONE;
|
import static android.opengl.GLES20.GL_ONE;
|
||||||
import static android.opengl.GLES20.GL_ONE_MINUS_SRC_ALPHA;
|
import static android.opengl.GLES20.GL_ONE_MINUS_SRC_ALPHA;
|
||||||
@ -452,14 +451,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
/* draw base layer */
|
/* draw base layer */
|
||||||
BaseMap.draw(tiles, tileCnt, pos);
|
BaseMap.draw(tiles, tileCnt, pos);
|
||||||
|
|
||||||
// start drawing while overlays uploading textures, etc
|
|
||||||
//GLES20.glFlush();
|
|
||||||
|
|
||||||
/* draw overlays */
|
/* draw overlays */
|
||||||
|
|
||||||
//GLState.blend(true);
|
|
||||||
GLES20.glEnable(GL_BLEND);
|
|
||||||
|
|
||||||
for (int i = 0, n = overlays.size(); i < n; i++) {
|
for (int i = 0, n = overlays.size(); i < n; i++) {
|
||||||
RenderOverlay renderOverlay = overlays.get(i);
|
RenderOverlay renderOverlay = overlays.get(i);
|
||||||
|
|
||||||
|
@ -47,15 +47,15 @@ public class GLState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
|
||||||
public static void blend(boolean enable) {
|
public static void blend(boolean enable) {
|
||||||
if (blend == enable)
|
if (blend == enable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (blend)
|
if (enable)
|
||||||
GLES20.glEnable(GLES20.GL_BLEND);
|
GLES20.glEnable(GLES20.GL_BLEND);
|
||||||
else
|
else
|
||||||
GLES20.glDisable(GLES20.GL_BLEND);
|
GLES20.glDisable(GLES20.GL_BLEND);
|
||||||
|
blend = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void test(boolean depthTest, boolean stencilTest) {
|
public static void test(boolean depthTest, boolean stencilTest) {
|
||||||
|
@ -118,6 +118,8 @@ public final class LineRenderer {
|
|||||||
if (layer == null)
|
if (layer == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
GLState.blend(true);
|
||||||
|
|
||||||
GLState.useProgram(lineProgram[mode]);
|
GLState.useProgram(lineProgram[mode]);
|
||||||
|
|
||||||
int uLineScale = hLineScale[mode];
|
int uLineScale = hLineScale[mode];
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
package org.oscim.renderer;
|
package org.oscim.renderer;
|
||||||
|
|
||||||
import static android.opengl.GLES20.GL_ALWAYS;
|
import static android.opengl.GLES20.GL_ALWAYS;
|
||||||
import static android.opengl.GLES20.GL_BLEND;
|
|
||||||
import static android.opengl.GLES20.GL_EQUAL;
|
import static android.opengl.GLES20.GL_EQUAL;
|
||||||
import static android.opengl.GLES20.GL_INVERT;
|
import static android.opengl.GLES20.GL_INVERT;
|
||||||
import static android.opengl.GLES20.GL_SHORT;
|
import static android.opengl.GLES20.GL_SHORT;
|
||||||
@ -23,9 +22,7 @@ import static android.opengl.GLES20.GL_TRIANGLE_FAN;
|
|||||||
import static android.opengl.GLES20.GL_TRIANGLE_STRIP;
|
import static android.opengl.GLES20.GL_TRIANGLE_STRIP;
|
||||||
import static android.opengl.GLES20.glColorMask;
|
import static android.opengl.GLES20.glColorMask;
|
||||||
import static android.opengl.GLES20.glDepthMask;
|
import static android.opengl.GLES20.glDepthMask;
|
||||||
import static android.opengl.GLES20.glDisable;
|
|
||||||
import static android.opengl.GLES20.glDrawArrays;
|
import static android.opengl.GLES20.glDrawArrays;
|
||||||
import static android.opengl.GLES20.glEnable;
|
|
||||||
import static android.opengl.GLES20.glGetAttribLocation;
|
import static android.opengl.GLES20.glGetAttribLocation;
|
||||||
import static android.opengl.GLES20.glGetUniformLocation;
|
import static android.opengl.GLES20.glGetUniformLocation;
|
||||||
import static android.opengl.GLES20.glStencilFunc;
|
import static android.opengl.GLES20.glStencilFunc;
|
||||||
@ -87,7 +84,6 @@ public final class PolygonRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void fillPolygons(int zoom, float scale) {
|
private static void fillPolygons(int zoom, float scale) {
|
||||||
boolean blend = false;
|
|
||||||
|
|
||||||
/* draw to framebuffer */
|
/* draw to framebuffer */
|
||||||
glColorMask(true, true, true, false);
|
glColorMask(true, true, true, false);
|
||||||
@ -98,36 +94,35 @@ public final class PolygonRenderer {
|
|||||||
for (int c = mStart; c < mCount; c++) {
|
for (int c = mStart; c < mCount; c++) {
|
||||||
PolygonLayer l = mFillPolys[c];
|
PolygonLayer l = mFillPolys[c];
|
||||||
|
|
||||||
|
if (l.area.fade >= zoom) {
|
||||||
float f = 1.0f;
|
float f = 1.0f;
|
||||||
|
|
||||||
if (l.area.fade >= zoom || l.area.color[3] != 1.0) {
|
|
||||||
/* fade in/out || draw alpha color */
|
/* fade in/out || draw alpha color */
|
||||||
if (l.area.fade >= zoom) {
|
if (l.area.fade >= zoom) {
|
||||||
f = (scale > FADE_START ? scale : FADE_START) - f;
|
if (scale > FADE_START)
|
||||||
|
f = scale - 1;
|
||||||
|
else
|
||||||
|
f = FADE_START - 1;
|
||||||
|
}
|
||||||
|
GLState.blend(true);
|
||||||
|
|
||||||
}
|
if (f < 1) {
|
||||||
if (!blend) {
|
GlUtils.setColor(hPolygonColor, l.area.color,
|
||||||
glEnable(GL_BLEND);
|
f * l.area.color[3]);
|
||||||
blend = true;
|
|
||||||
}
|
|
||||||
if (f != 1) {
|
|
||||||
f = (f > 1 ? 1 : f) * l.area.color[3];
|
|
||||||
GlUtils.setColor(hPolygonColor, l.area.color, f);
|
|
||||||
} else {
|
} else {
|
||||||
glUniform4fv(hPolygonColor, 1, l.area.color, 0);
|
glUniform4fv(hPolygonColor, 1, l.area.color, 0);
|
||||||
}
|
}
|
||||||
} else if (l.area.blend == zoom) {
|
} else if (l.area.blend == zoom) {
|
||||||
/* blend colors */
|
/* blend colors */
|
||||||
f = scale - 1.0f;
|
|
||||||
GlUtils.setBlendColors(hPolygonColor,
|
GlUtils.setBlendColors(hPolygonColor,
|
||||||
l.area.color, l.area.blendColor, f);
|
l.area.color, l.area.blendColor, scale - 1.0f);
|
||||||
} else {
|
} else {
|
||||||
/* draw solid */
|
if (l.area.color[3] != 1.0) {
|
||||||
if (blend) {
|
GLState.blend(true);
|
||||||
glDisable(GL_BLEND);
|
} else {
|
||||||
blend = false;
|
GLState.blend(false);
|
||||||
}
|
}
|
||||||
if (l.area.blend <= zoom && l.area.blend > 0)
|
|
||||||
|
if (l.area.blend < zoom && l.area.blend > 0)
|
||||||
glUniform4fv(hPolygonColor, 1, l.area.blendColor, 0);
|
glUniform4fv(hPolygonColor, 1, l.area.blendColor, 0);
|
||||||
else
|
else
|
||||||
glUniform4fv(hPolygonColor, 1, l.area.color, 0);
|
glUniform4fv(hPolygonColor, 1, l.area.color, 0);
|
||||||
@ -141,9 +136,6 @@ public final class PolygonRenderer {
|
|||||||
/* draw tile fill coordinates */
|
/* draw tile fill coordinates */
|
||||||
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blend)
|
|
||||||
glDisable(GL_BLEND);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// layers to fill
|
// layers to fill
|
||||||
@ -151,8 +143,6 @@ public final class PolygonRenderer {
|
|||||||
// stencil buffer index to start fill
|
// stencil buffer index to start fill
|
||||||
private static int mStart;
|
private static int mStart;
|
||||||
|
|
||||||
//private final static boolean drawBackground = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* draw polygon layers (unil layer.next is not polygon layer)
|
* draw polygon layers (unil layer.next is not polygon layer)
|
||||||
* using stencil buffer method
|
* using stencil buffer method
|
||||||
@ -209,6 +199,7 @@ public final class PolygonRenderer {
|
|||||||
|
|
||||||
// op for stencil method polygon drawing
|
// op for stencil method polygon drawing
|
||||||
glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GL_INVERT);
|
glStencilOp(GLES20.GL_KEEP, GLES20.GL_KEEP, GL_INVERT);
|
||||||
|
GLState.blend(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
mFillPolys[mCount] = pl;
|
mFillPolys[mCount] = pl;
|
||||||
@ -248,8 +239,14 @@ public final class PolygonRenderer {
|
|||||||
* @param first ...
|
* @param first ...
|
||||||
*/
|
*/
|
||||||
static void drawStencilRegion(boolean clip, boolean first) {
|
static void drawStencilRegion(boolean clip, boolean first) {
|
||||||
GLState.useProgram(polygonProgram);
|
//if (!first && clip) {
|
||||||
|
// // only clear 'layer-bits'
|
||||||
|
// glStencilMask(0x7F);
|
||||||
|
// GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
|
||||||
|
// glColorMask(false, false, false, false);
|
||||||
|
// glStencilFunc(GL_EQUAL, CLIP_BIT, CLIP_BIT);
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
// 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);
|
||||||
|
|
||||||
|
@ -91,8 +91,8 @@ public final class TextureRenderer {
|
|||||||
|
|
||||||
public static Layer draw(Layer layer, float scale, float[] projection, float matrix[]) {
|
public static Layer draw(Layer layer, float scale, float[] projection, float matrix[]) {
|
||||||
GLState.test(false, false);
|
GLState.test(false, false);
|
||||||
GLES20.glEnable(GLES20.GL_BLEND);
|
GLState.blend(true);
|
||||||
// GlUtils.checkGlError("draw texture >");
|
|
||||||
GLState.useProgram(mTextureProgram);
|
GLState.useProgram(mTextureProgram);
|
||||||
|
|
||||||
GLState.enableVertexArrays(hTextureTexCoord, hTextureVertex);
|
GLState.enableVertexArrays(hTextureTexCoord, hTextureVertex);
|
||||||
|
@ -58,10 +58,8 @@ public abstract class BasicOverlay extends RenderOverlay {
|
|||||||
|
|
||||||
for (Layer l = layers.layers; l != null;) {
|
for (Layer l = layers.layers; l != null;) {
|
||||||
if (l.type == Layer.POLYGON) {
|
if (l.type == Layer.POLYGON) {
|
||||||
GLES20.glDisable(GLES20.GL_BLEND);
|
|
||||||
l = PolygonRenderer.draw(pos, l, mvp, true, false);
|
l = PolygonRenderer.draw(pos, l, mvp, true, false);
|
||||||
} else {
|
} else {
|
||||||
GLES20.glEnable(GLES20.GL_BLEND);
|
|
||||||
l = LineRenderer.draw(pos, l, mvp, div, 0, layers.lineOffset);
|
l = LineRenderer.draw(pos, l, mvp, div, 0, layers.lineOffset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,6 +261,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
|||||||
GLState.enableVertexArrays(uExtVertexPosition, uExtLightPosition);
|
GLState.enableVertexArrays(uExtVertexPosition, uExtLightPosition);
|
||||||
GLES20.glColorMask(true, true, true, true);
|
GLES20.glColorMask(true, true, true, true);
|
||||||
GLES20.glDepthMask(false);
|
GLES20.glDepthMask(false);
|
||||||
|
GLState.blend(true);
|
||||||
|
|
||||||
for (int i = 0; i < mTileCnt; i++) {
|
for (int i = 0; i < mTileCnt; i++) {
|
||||||
MapTile t = tiles[i];
|
MapTile t = tiles[i];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user