formatting
This commit is contained in:
@@ -80,7 +80,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
private static float[] mTileCoords = new float[8];
|
||||
private static float[] mDebugCoords = new float[8];
|
||||
|
||||
//private
|
||||
//private
|
||||
static float[] mClearColor = null;
|
||||
private static boolean mUpdateColor = false;
|
||||
|
||||
|
||||
@@ -135,8 +135,8 @@ public final class LineRenderer {
|
||||
glUniformMatrix4fv(hLineMatrix[mode], 1, false, matrix, 0);
|
||||
|
||||
// line scale factor for non fixed lines: within a zoom-
|
||||
// level lines would be scaled by the factor 2 via projection.
|
||||
// though lines should only scale by sqrt(2). this is achieved
|
||||
// level lines would be scaled by the factor 2 via projection.
|
||||
// though lines should only scale by sqrt(2). this is achieved
|
||||
// by inverting scaling of extrusion vector with: width/sqrt(s).
|
||||
// within one zoom-level: 1 <= s <= 2
|
||||
float s = scale / div;
|
||||
@@ -280,7 +280,7 @@ public final class LineRenderer {
|
||||
+ "varying vec2 v_mode;"
|
||||
+ "void main() {"
|
||||
//+ " float len;"
|
||||
// some say one should not use conditionals
|
||||
// some say one should not use conditionals
|
||||
// (FIXME currently required as overlay line renderers dont load the texture)
|
||||
//+ " if (u_mode == 0)"
|
||||
//+ " len = abs(v_st.s);"
|
||||
@@ -289,7 +289,7 @@ public final class LineRenderer {
|
||||
// one trick to avoid branching, need to check performance
|
||||
+ " float len = max(v_mode[0] * abs(v_st.s), v_mode[1] * texture2D(tex, v_st).a);"
|
||||
// interpolate alpha between: 0.0 < 1.0 - len < u_wscale
|
||||
// where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2)
|
||||
// where wscale is 'filter width' / 'line width' and 0 <= len <= sqrt(2)
|
||||
+ " gl_FragColor = u_color * smoothstep(0.0, u_wscale, 1.0 - len);"
|
||||
//+ " gl_FragColor = u_color * min(1.0, (1.0 - len) / u_wscale);"
|
||||
+ "}";
|
||||
@@ -316,7 +316,7 @@ public final class LineRenderer {
|
||||
+ " fuzz = max(st_width.s, st_width.t);"
|
||||
+ " }"
|
||||
//+ " gl_FragColor = u_color * smoothstep(0.0, fuzz + u_wscale, 1.0 - len);"
|
||||
// smoothstep is too sharp, guess one could increase extrusion with z..
|
||||
// smoothstep is too sharp, guess one could increase extrusion with z..
|
||||
// this looks ok:
|
||||
//+ " gl_FragColor = u_color * min(1.0, (1.0 - len) / (u_wscale + fuzz));"
|
||||
// can be faster according to nvidia docs 'Optimize OpenGL ES 2.0 Performace'
|
||||
|
||||
@@ -130,7 +130,7 @@ public final class PolygonRenderer {
|
||||
glUniform4fv(hPolygonColor, 1, a.color, 0);
|
||||
}
|
||||
|
||||
// set stencil buffer mask used to draw this layer
|
||||
// set stencil buffer mask used to draw this layer
|
||||
// also check that clip bit is set to avoid overdraw
|
||||
// of other tiles
|
||||
glStencilFunc(GL_EQUAL, 0xff, CLIP_BIT | 1 << c);
|
||||
@@ -146,6 +146,7 @@ public final class PolygonRenderer {
|
||||
/**
|
||||
* draw polygon layers (unil layer.next is not polygon layer)
|
||||
* using stencil buffer method
|
||||
*
|
||||
* @param pos
|
||||
* used to fade layers accorind to 'fade'
|
||||
* in layer.area.
|
||||
@@ -234,6 +235,7 @@ public final class PolygonRenderer {
|
||||
/**
|
||||
* Draw a tile filling rectangle to set stencil- and depth buffer
|
||||
* appropriately
|
||||
*
|
||||
* @param first in the first run the clip region is set based on
|
||||
* depth buffer and depth buffer is updated
|
||||
*/
|
||||
@@ -305,8 +307,10 @@ public final class PolygonRenderer {
|
||||
glUniformMatrix4fv(hPolygonMatrix, 1, false, matrix, 0);
|
||||
}
|
||||
|
||||
/* clear stencilbuffer (tile region) by drawing
|
||||
* a quad with func 'always' and op 'zero' */
|
||||
/*
|
||||
* 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);
|
||||
|
||||
@@ -160,8 +160,10 @@ public abstract class ScanBox {
|
||||
}
|
||||
}
|
||||
|
||||
/* ported from Polymaps: Layer.js Copyright (c) 2010, SimpleGeo and Stamen
|
||||
* Design */
|
||||
/*
|
||||
* ported from Polymaps: Layer.js Copyright (c) 2010, SimpleGeo and Stamen
|
||||
* Design
|
||||
*/
|
||||
|
||||
// // scan-line conversion
|
||||
// function edge(a, b) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@@ -43,7 +43,7 @@ import android.util.Log;
|
||||
public class TileManager {
|
||||
static final String TAG = TileManager.class.getSimpleName();
|
||||
|
||||
// TODO this should depend on the number of
|
||||
// TODO this should depend on the number of
|
||||
// tiles that could be displayed
|
||||
private static final int MAX_TILES_IN_QUEUE = 50;
|
||||
|
||||
@@ -152,6 +152,7 @@ public class TileManager {
|
||||
* Update list of visible tiles and passes them to TileManager, when not
|
||||
* available tiles are created and added to JobQueue (mapView.addJobs) for
|
||||
* loading by TileGenerator class
|
||||
*
|
||||
* @param clear
|
||||
* whether to clear and reload all tiles
|
||||
*/
|
||||
@@ -174,7 +175,7 @@ public class TileManager {
|
||||
for (int i = 0; i < mTilesSize; i++)
|
||||
clearTile(mTiles[i]);
|
||||
} else {
|
||||
// mInitialized is set when surface changed
|
||||
// mInitialized is set when surface changed
|
||||
// and VBOs might be lost
|
||||
VertexPool.init();
|
||||
}
|
||||
@@ -292,6 +293,7 @@ public class TileManager {
|
||||
/**
|
||||
* set mNewTiles for the visible tiles and pass it to GLRenderer, add jobs
|
||||
* for not yet loaded tiles
|
||||
*
|
||||
* @param mapPosition
|
||||
* the current MapPosition
|
||||
* @param zdir
|
||||
@@ -303,7 +305,7 @@ public class TileManager {
|
||||
// one could also append new tiles and sort in JobQueue
|
||||
// but this has the nice side-effect that MapWorkers dont
|
||||
// start with old jobs while new jobs are calculated, which
|
||||
// should increase the chance that they are free when new
|
||||
// should increase the chance that they are free when new
|
||||
// jobs come in.
|
||||
mMapView.addJobs(null);
|
||||
|
||||
@@ -523,9 +525,9 @@ public class TileManager {
|
||||
Log.d(TAG, "limitCache: tile still locked " + t + " " + t.distance);
|
||||
//mTiles.add(t);
|
||||
} else if (t.state == STATE_LOADING) {
|
||||
// NOTE: when set loading to false the tile could be
|
||||
// added to load queue again while still processed in
|
||||
// TileGenerator => need tile.cancel flag.
|
||||
// NOTE: when set loading to false the tile could be
|
||||
// added to load queue again while still processed in
|
||||
// TileGenerator => need tile.cancel flag.
|
||||
// t.isLoading = false;
|
||||
//mTiles.add(t);
|
||||
Log.d(TAG, "limitCache: cancel loading " + t + " " + t.distance);
|
||||
@@ -556,6 +558,7 @@ public class TileManager {
|
||||
|
||||
/**
|
||||
* called from MapWorker Thread when tile is loaded by TileGenerator
|
||||
*
|
||||
* @param jobTile
|
||||
* Tile ready for upload to GL
|
||||
* @return ... caller does not care
|
||||
@@ -579,7 +582,7 @@ public class TileManager {
|
||||
|
||||
tile.state = STATE_NEW_DATA;
|
||||
|
||||
// locked means the tile is visible or referenced by
|
||||
// locked means the tile is visible or referenced by
|
||||
// a tile that might be visible.
|
||||
if (tile.isLocked())
|
||||
mMapView.render();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012, 2013 OpenScienceMap
|
||||
* Copyright 2012, 2013 OpenScienceMap
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -37,7 +37,7 @@ public abstract class Layer {
|
||||
|
||||
// in case of line and polygon layer:
|
||||
// - number of VERTICES offset for this layertype in VBO
|
||||
// otherwise:
|
||||
// otherwise:
|
||||
// - offset in byte in VBO
|
||||
public int offset;
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ public final class LineLayer extends Layer {
|
||||
/**
|
||||
* line extrusion is based on code from GLMap
|
||||
* (https://github.com/olofsj/GLMap/)
|
||||
*
|
||||
* @param points
|
||||
* array of points as x,y pairs
|
||||
* @param index
|
||||
|
||||
@@ -48,7 +48,7 @@ public final class SymbolLayer extends TextureLayer {
|
||||
|
||||
for (SymbolItem it = symbols; it != null; it = it.next) {
|
||||
if (it.bitmap == item.bitmap) {
|
||||
// insert after same bitmap
|
||||
// insert after same bitmap
|
||||
item.next = it.next;
|
||||
it.next = item;
|
||||
return;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class TextItem {
|
||||
// in.next = ti.next;
|
||||
// ti.next = in;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// TextItem t = ti;
|
||||
// while (t.next != null)
|
||||
// t = t.next;
|
||||
@@ -68,7 +68,7 @@ public class TextItem {
|
||||
while (ti != null) {
|
||||
TextItem next = ti.next;
|
||||
|
||||
// drop references
|
||||
// drop references
|
||||
ti.string = null;
|
||||
ti.text = null;
|
||||
ti.n1 = null;
|
||||
@@ -83,7 +83,7 @@ public class TextItem {
|
||||
TextItem next = ti.next;
|
||||
ti.next = pool;
|
||||
|
||||
// drop references
|
||||
// drop references
|
||||
ti.string = null;
|
||||
ti.text = null;
|
||||
ti.n1 = null;
|
||||
|
||||
@@ -91,7 +91,7 @@ public final class TextLayer extends TextureLayer {
|
||||
it = it.next;
|
||||
|
||||
// unify duplicate string :)
|
||||
// Note: this is required for 'packing test' in prepare to work!
|
||||
// Note: this is required for 'packing test' in prepare to work!
|
||||
if (item.string != it.string && item.string.equals(it.string))
|
||||
item.string = it.string;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ public class VertexPoolItem {
|
||||
public int used;
|
||||
public VertexPoolItem next;
|
||||
|
||||
// must be multiple of
|
||||
// must be multiple of
|
||||
// 4 (LineLayer/PolygonLayer),
|
||||
// 6 (TexLineLayer)
|
||||
// 24 (TextureLayer)
|
||||
|
||||
@@ -156,7 +156,7 @@ public class BuildingOverlay extends RenderOverlay {
|
||||
|
||||
mCurVertices.used = v;
|
||||
|
||||
// fill ZigZagQuadIndices(tm)
|
||||
// fill ZigZagQuadIndices(tm)
|
||||
for (int j = 0; j < 2; j++) {
|
||||
short[] indices = mCurIndices[j].vertices;
|
||||
int cnt = mCurIndices[j].used;
|
||||
|
||||
@@ -28,7 +28,7 @@ import android.opengl.Matrix;
|
||||
|
||||
/*
|
||||
* This is an example how to integrate custom OpenGL drawing routines as map overlay
|
||||
*
|
||||
*
|
||||
* based on chapter 2 from:
|
||||
* https://github.com/dalinaum/opengl-es-book-samples/tree/master/Android
|
||||
* */
|
||||
|
||||
@@ -227,7 +227,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
GLState.useProgram(extrusionProgram[shaderMode]);
|
||||
GLState.enableVertexArrays(uExtVertexPosition, -1);
|
||||
if (pos.scale < 2) {
|
||||
// chances are high that one moves through a building
|
||||
// chances are high that one moves through a building
|
||||
// with scale > 2 also draw back sides in this case.
|
||||
GLES20.glEnable(GLES20.GL_CULL_FACE);
|
||||
GLES20.glCullFace(GLES20.GL_FRONT);
|
||||
@@ -296,7 +296,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
GLES20.glDrawElements(GLES20.GL_TRIANGLES, el.mIndiceCnt[1],
|
||||
GLES20.GL_UNSIGNED_SHORT, el.mIndiceCnt[0] * 2);
|
||||
|
||||
// drawing gl_lines with the same coordinates does not result in
|
||||
// drawing gl_lines with the same coordinates does not result in
|
||||
// same depth values as polygons, so add offset and draw gl_lequal:
|
||||
GLES20.glDepthFunc(GLES20.GL_LEQUAL);
|
||||
GlUtils.addOffsetM(mv, 100);
|
||||
@@ -346,7 +346,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
_a * ((_g + _l + 1) / 255),
|
||||
_a * ((_b + _l) / 255),
|
||||
_a,
|
||||
// sligthly differ adjacent side
|
||||
// sligthly differ adjacent side
|
||||
// faces to improve contrast
|
||||
_a * ((_r - _s) / 255 + 0.01f),
|
||||
_a * ((_g - _s) / 255 + 0.01f),
|
||||
@@ -385,7 +385,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
+ " float z = (0.96 + gl_Position.z * 0.04);"
|
||||
+ " if (u_mode == 1){"
|
||||
// sides 1 - use 0xff00
|
||||
// scale direction to -0.5<>0.5
|
||||
// scale direction to -0.5<>0.5
|
||||
+ " float dir = abs(a_light.y / ff - 0.5);"
|
||||
+ " color = u_color[1] * z;"
|
||||
+ " color.rgb *= (0.7 + dir * 0.4);"
|
||||
@@ -420,7 +420,7 @@ public class ExtrusionOverlay extends RenderOverlay {
|
||||
// decrease contrast with distance
|
||||
+ " if (u_mode == 1){"
|
||||
// sides 1 - use 0xff00
|
||||
// scale direction to -0.5<>0.5
|
||||
// scale direction to -0.5<>0.5
|
||||
//+ " float dir = abs(a_light.y / ff - 0.5);"
|
||||
+ " float dir = a_light.y / ff;"
|
||||
+ " float z = (0.98 + gl_Position.z * 0.02);"
|
||||
|
||||
@@ -45,6 +45,7 @@ public abstract class RenderOverlay {
|
||||
* called 1. by GLRenderer. Set 'newData' true when 'compile()' should be
|
||||
* called
|
||||
* before next 'render()'
|
||||
*
|
||||
* @param curPos TODO
|
||||
* @param positionChanged
|
||||
* true when MapPosition has changed
|
||||
@@ -61,6 +62,7 @@ public abstract class RenderOverlay {
|
||||
|
||||
/**
|
||||
* called 3. draw overlay
|
||||
*
|
||||
* @param pos
|
||||
* current MapPosition
|
||||
* @param mv
|
||||
@@ -73,6 +75,7 @@ public abstract class RenderOverlay {
|
||||
/**
|
||||
* Utility: set matrix relative to the difference of current MapPosition
|
||||
* and the last updated Overlay MapPosition
|
||||
*
|
||||
* @param curPos ...
|
||||
* @param matrix ...
|
||||
*/
|
||||
@@ -106,6 +109,7 @@ public abstract class RenderOverlay {
|
||||
|
||||
/**
|
||||
* Utility: update mMapPosition
|
||||
*
|
||||
* @return true if position has changed
|
||||
*/
|
||||
protected boolean updateMapPosition() {
|
||||
|
||||
@@ -125,7 +125,7 @@ public class TextOverlay extends BasicOverlay {
|
||||
lp.x1, lp.y1, lp.x2, lp.y2);
|
||||
|
||||
if (intersect != 0) {
|
||||
//Log.d(TAG, "overlap " + lp.string + " <> " + ti.string
|
||||
//Log.d(TAG, "overlap " + lp.string + " <> " + ti.string
|
||||
//+ " at " + ti.x + ":" + ti.y);
|
||||
|
||||
if ((lp.n1 != null && lp.n1 == ti.n2) ||
|
||||
|
||||
Reference in New Issue
Block a user