Skip to content

Commit

Permalink
VTM: LineBucket: transparent lines
Browse files Browse the repository at this point in the history
  • Loading branch information
andreynovikov committed Feb 3, 2024
1 parent f8ac992 commit 122fd51
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/java/mobi/maptrek/MapTrek.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public class MapTrek extends Application {
Parameters.MAP_EVENT_LAYER2 = true;
//Parameters.TEXTURE_ATLAS = true;
Parameters.POT_TEXTURES = true;
Parameters.TRANSPARENT_LINES = false;
}

@Override
Expand Down
16 changes: 16 additions & 0 deletions app/src/main/java/org/oscim/renderer/bucket/LineBucket.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.oscim.backend.GL;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MercatorProjection;
Expand All @@ -27,6 +28,7 @@
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.GLViewport;
import org.oscim.theme.styles.LineStyle;
import org.oscim.utils.Parameters;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -661,6 +663,12 @@ public static RenderBucket draw(RenderBucket b, GLViewport v,
blur = false;
}

if (Parameters.TRANSPARENT_LINES && !Color.isOpaque(line.color)) {
gl.depthMask(true);
gl.clear(GL.DEPTH_BUFFER_BIT);
GLState.test(true, false);
}

/* draw LineLayer */
if (!line.outline) {
/* invert scaling of extrusion vectors so that line
Expand Down Expand Up @@ -710,6 +718,10 @@ public static RenderBucket draw(RenderBucket b, GLViewport v,
gl.drawArrays(GL.TRIANGLE_STRIP,
b.vertexOffset, b.numVertices);

if (Parameters.TRANSPARENT_LINES && !Color.isOpaque(line.color)) {
gl.depthMask(false);
}

continue;
}

Expand Down Expand Up @@ -764,6 +776,10 @@ public static RenderBucket draw(RenderBucket b, GLViewport v,
gl.drawArrays(GL.TRIANGLE_STRIP,
ref.vertexOffset, ref.numVertices);
}

if (Parameters.TRANSPARENT_LINES && !Color.isOpaque(line.color)) {
gl.depthMask(false);
}
}

return b;
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/java/org/oscim/utils/Parameters.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public final class Parameters {
*/
public static boolean TEXTURE_ATLAS = false;

/**
* Transparent line layers.
*/
public static boolean TRANSPARENT_LINES = false;

/**
* Threaded system initialization.
*/
Expand Down

0 comments on commit 122fd51

Please sign in to comment.