refactor: utils.GlUtils -> renderer.GLUtils, utils.Matrix4 -> renderer.GLMatrix

- init 'GL' handle of rendering classes in MapRenderer.onSurfaceCreated,
  at this point handle is safe to use, i.e. GL context is available
- all LayerRenderer share one static 'GL' field now
This commit is contained in:
Hannes Janetzek 2013-09-20 16:28:12 +02:00
parent 83a276becf
commit 7dde869f4a
22 changed files with 219 additions and 234 deletions

View File

@ -15,19 +15,14 @@
* limitations under the License.
******************************************************************************/
package org.oscim.utils;
package org.oscim.renderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
public class Matrix4 {
private static GL20 GL = GLAdapter.get();
public class GLMatrix {
public static final int M00 = 0;// 0;
public static final int M01 = 4;// 1;
@ -96,7 +91,7 @@ public class Matrix4 {
*
* @param mat Matrix to copy
*/
public void copy(Matrix4 m) {
public void copy(GLMatrix m) {
if (m == null || m.val.length != 16)
throw new IllegalArgumentException(INVALID_INPUT);
@ -130,7 +125,7 @@ public class Matrix4 {
*
* @param rhs right hand side
*/
public void multiplyRhs(Matrix4 rhs) {
public void multiplyRhs(GLMatrix rhs) {
matrix4_mul(val, rhs.val);
}
@ -139,7 +134,7 @@ public class Matrix4 {
*
* @param lhs right hand side
*/
public void multiplyLhs(Matrix4 lhs) {
public void multiplyLhs(GLMatrix lhs) {
System.arraycopy(lhs.val, 0, tmp, 0, 16);
matrix4_mul(tmp, val);
System.arraycopy(tmp, 0, val, 0, 16);
@ -156,7 +151,7 @@ public class Matrix4 {
* @param lhs left hand side
* @param rhs right hand side
*/
public void multiplyMM(Matrix4 lhs, Matrix4 rhs) {
public void multiplyMM(GLMatrix lhs, GLMatrix rhs) {
System.arraycopy(lhs.val, 0, tmp, 0, 16);
matrix4_mul(tmp, rhs.val);
System.arraycopy(tmp, 0, val, 0, 16);
@ -167,7 +162,7 @@ public class Matrix4 {
*
* @param mat to transpose
*/
public void transposeM(Matrix4 mat) {
public void transposeM(GLMatrix mat) {
val[M00] = mat.val[M00];
val[M01] = mat.val[M10];
val[M02] = mat.val[M20];
@ -251,8 +246,7 @@ public class Matrix4 {
buffer.clear();
buffer.put(val, 0, 16);
buffer.position(0);
GL = GLAdapter.get();
GL.glUniformMatrix4fv(location, 1, false, buffer);
MapRenderer.GL.glUniformMatrix4fv(location, 1, false, buffer);
}
/**

View File

@ -72,7 +72,7 @@ void JNI(setColorBlend)(JNIEnv *env, jclass* clazz, jint location, jint c1, jint
#endif // 0
#undef JNI
#define JNI(X) JNIEXPORT Java_org_oscim_utils_Matrix4_##X
#define JNI(X) JNIEXPORT Java_org_oscim_renderer_GLMatrix_##X
#define CAST(x) (float *)(uintptr_t) x
#define MAT_SIZE 16 * sizeof(float)

View File

@ -25,6 +25,9 @@ public class GLAdapter {
public static boolean NON_PREMUL_CANVAS;
public static GL20 get(){
if (g == null)
throw new IllegalStateException();
return g;
}
}

View File

@ -21,8 +21,8 @@ import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Point;
import org.oscim.core.Tile;
import org.oscim.renderer.GLMatrix;
import org.oscim.utils.FastMath;
import org.oscim.utils.Matrix4;
/**
* The Viewport class contains a MapPosition and the projection matrices.
@ -44,13 +44,13 @@ public class Viewport {
private final MapPosition mPos = new MapPosition();
private final Matrix4 mProjMatrix = new Matrix4();
private final Matrix4 mProjMatrixI = new Matrix4();
private final Matrix4 mRotMatrix = new Matrix4();
private final Matrix4 mViewMatrix = new Matrix4();
private final Matrix4 mVPMatrix = new Matrix4();
private final Matrix4 mUnprojMatrix = new Matrix4();
private final Matrix4 mTmpMatrix = new Matrix4();
private final GLMatrix mProjMatrix = new GLMatrix();
private final GLMatrix mProjMatrixI = new GLMatrix();
private final GLMatrix mRotMatrix = new GLMatrix();
private final GLMatrix mViewMatrix = new GLMatrix();
private final GLMatrix mVPMatrix = new GLMatrix();
private final GLMatrix mUnprojMatrix = new GLMatrix();
private final GLMatrix mTmpMatrix = new GLMatrix();
// temporary vars: only use in synchronized functions!
private final Point mMovePoint = new Point();
@ -81,7 +81,7 @@ public class Viewport {
float aspect = height / (float) width;
float[] tmp = new float[16];
Matrix4.frustumM(tmp, 0, -s, s,
GLMatrix.frustumM(tmp, 0, -s, s,
aspect * s, -aspect * s, VIEW_NEAR, VIEW_FAR);
mProjMatrix.set(tmp);
@ -89,7 +89,7 @@ public class Viewport {
mProjMatrix.multiplyRhs(mTmpMatrix);
mProjMatrix.get(tmp);
Matrix4.invertM(tmp, 0, tmp, 0);
GLMatrix.invertM(tmp, 0, tmp, 0);
mProjMatrixI.set(tmp);
mHeight = height;
@ -130,7 +130,7 @@ public class Viewport {
* @param proj projection Matrix
* @param vp view and projection
*/
public synchronized void getMatrix(Matrix4 view, Matrix4 proj, Matrix4 vp) {
public synchronized void getMatrix(GLMatrix view, GLMatrix proj, GLMatrix vp) {
if (view != null)
view.copy(mViewMatrix);

View File

@ -18,9 +18,7 @@ package org.oscim.renderer;
import java.nio.Buffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.utils.GlUtils;
public final class BufferObject {
private final static String TAG = BufferObject.class.getName();
@ -176,7 +174,7 @@ public final class BufferObject {
}
if (removed > 0) {
GlUtils.glDeleteBuffers(removed, vboIds);
GLUtils.glDeleteBuffers(removed, vboIds);
counter[t] -= removed;
}
@ -186,7 +184,7 @@ public final class BufferObject {
}
static void createBuffers(int target, int num) {
int[] mVboIds = GlUtils.glGenBuffers(num);
int[] mVboIds = GLUtils.glGenBuffers(num);
int t = (target == GL20.GL_ARRAY_BUFFER) ? 0 : 1;
@ -207,8 +205,8 @@ public final class BufferObject {
counter[1] = 0;
}
static synchronized void init(int num) {
GL = GLAdapter.get();
static synchronized void init(GL20 gl, int num) {
GL = gl;
createBuffers(GL20.GL_ARRAY_BUFFER, num);
counter[0] += num;

View File

@ -15,7 +15,6 @@
package org.oscim.renderer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
@ -24,7 +23,6 @@ import org.oscim.renderer.elements.ExtrusionLayer;
import org.oscim.tiling.MapTile;
import org.oscim.tiling.TileRenderer;
import org.oscim.tiling.TileSet;
import org.oscim.utils.GlUtils;
// TODO move MapTile part to BuildingLayer and make
// this class work on ExtrusionLayers
@ -32,8 +30,6 @@ import org.oscim.utils.GlUtils;
public class ExtrusionRenderer extends LayerRenderer {
private final static String TAG = ExtrusionRenderer.class.getName();
private static final GL20 GL = GLAdapter.get();
private final TileRenderer mTileLayer;
protected float mAlpha = 1;
@ -64,10 +60,10 @@ public class ExtrusionRenderer extends LayerRenderer {
for (int i = 0; i <= SHADER; i++) {
if (i == 0) {
shaderProgram[i] = GlUtils.createProgram(extrusionVertexShader,
shaderProgram[i] = GLUtils.createProgram(extrusionVertexShader,
extrusionFragmentShader);
} else {
shaderProgram[i] = GlUtils.createProgram(extrusionVertexShader,
shaderProgram[i] = GLUtils.createProgram(extrusionVertexShader,
extrusionFragmentShaderZ);
}
@ -128,7 +124,7 @@ public class ExtrusionRenderer extends LayerRenderer {
if (!el.compiled) {
int numShorts = el.mNumVertices * 8;
el.compile(MapRenderer.getShortBuffer(numShorts));
GlUtils.checkGlError("...");
GLUtils.checkGlError("...");
}
if (el.compiled)
@ -196,7 +192,7 @@ public class ExtrusionRenderer extends LayerRenderer {
GLState.enableVertexArrays(uExtVertexPosition, uExtLightPosition);
GL.glUniform1i(uExtMode, 0);
GlUtils.glUniform4fv(uExtColor, 4, mColor);
GLUtils.glUniform4fv(uExtColor, 4, mColor);
GLState.test(false, false);
@ -247,7 +243,7 @@ public class ExtrusionRenderer extends LayerRenderer {
GL.glDepthFunc(GL20.GL_LESS);
GL.glColorMask(false, false, false, false);
GL.glUniform1i(uExtMode, 0);
GlUtils.glUniform4fv(uExtColor, 4, mColor);
GLUtils.glUniform4fv(uExtColor, 4, mColor);
GL.glUniform1f(uExtAlpha, mAlpha);
// draw to depth buffer

View File

@ -12,20 +12,15 @@
* 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/>.
*/
package org.oscim.utils;
package org.oscim.renderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
public class GLMatrix {
public class Matrix4 {
private static final GL20 GL = GLAdapter.get();
private final static String TAG = Matrix4.class.getName();
private final static String TAG = GLMatrix.class.getName();
private final static boolean dbg = false;
private final long pointer;
@ -33,7 +28,7 @@ public class Matrix4 {
private final static String INVALID_INPUT = "Bad Array!";
public Matrix4() {
public GLMatrix() {
pointer = alloc();
buffer = (getBuffer(pointer)).order(ByteOrder.nativeOrder()).asFloatBuffer();
}
@ -67,7 +62,7 @@ public class Matrix4 {
*
* @param mat Matrix to copy
*/
public void copy(Matrix4 mat) {
public void copy(GLMatrix mat) {
copy(pointer, mat.pointer);
}
@ -88,7 +83,7 @@ public class Matrix4 {
*
* @param rhs right hand side
*/
public void multiplyRhs(Matrix4 rhs) {
public void multiplyRhs(GLMatrix rhs) {
smulrhs(pointer, rhs.pointer);
}
@ -97,7 +92,7 @@ public class Matrix4 {
*
* @param lhs right hand side
*/
public void multiplyLhs(Matrix4 lhs) {
public void multiplyLhs(GLMatrix lhs) {
smullhs(pointer, lhs.pointer);
}
@ -112,7 +107,7 @@ public class Matrix4 {
* @param lhs left hand side
* @param rhs right hand side
*/
public void multiplyMM(Matrix4 lhs, Matrix4 rhs) {
public void multiplyMM(GLMatrix lhs, GLMatrix rhs) {
smul(pointer, lhs.pointer, rhs.pointer);
}
@ -121,7 +116,7 @@ public class Matrix4 {
*
* @param mat to transpose
*/
public void transposeM(Matrix4 mat) {
public void transposeM(GLMatrix mat) {
strans(pointer, mat.pointer);
}
@ -176,7 +171,7 @@ public class Matrix4 {
* @param location GL location id
*/
public void setAsUniform(int location) {
GL.glUniformMatrix4fv(location, 1, false, buffer);
MapRenderer.GL.glUniformMatrix4fv(location, 1, false, buffer);
//setAsUniform(pointer, location);
}

View File

@ -15,14 +15,13 @@
package org.oscim.renderer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
public class GLState {
private final static GL20 GL = GLAdapter.get();
private final static String TAG = GLState.class.getName();
private static GL20 GL;
private final static boolean[] vertexArray = { false, false };
private static boolean blend = false;
private static boolean depth = false;
@ -31,7 +30,8 @@ public class GLState {
private static int currentTexId;
public static void init() {
static void init(GL20 gl) {
GL = gl;
vertexArray[0] = false;
vertexArray[1] = false;
blend = false;

View File

@ -1,5 +1,5 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2013 Hannes Janetzek
*
* 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
@ -12,7 +12,7 @@
* 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/>.
*/
package org.oscim.utils;
package org.oscim.renderer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
@ -22,19 +22,21 @@ import java.nio.IntBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.GLState;
import org.oscim.utils.FastMath;
/**
* Utility functions
*/
public class GlUtils {
private static String TAG = GlUtils.class.getName();
private static GL20 GL = GLAdapter.get();
public class GLUtils {
private static String TAG = GLUtils.class.getName();
private static GL20 GL;
static void init(GL20 gl){
GL = gl;
}
public static void setColor(int location, int color, float alpha) {
GL = GLAdapter.get();
if (alpha >= 1)
alpha = ((color >>> 24) & 0xff) / 255f;
else if (alpha < 0)
@ -60,7 +62,6 @@ public class GlUtils {
public static void setColorBlend(int location, int color1, int color2, float mix) {
float a1 = (((color1 >>> 24) & 0xff) / 255f) * (1 - mix);
float a2 = (((color2 >>> 24) & 0xff) / 255f) * mix;
GL = GLAdapter.get();
GL.glUniform4f
(location,
((((color1 >>> 16) & 0xff) / 255f) * a1 + (((color2 >>> 16) & 0xff) / 255f) * a2),
@ -70,7 +71,6 @@ public class GlUtils {
}
public static void setTextureParameter(int min_filter, int mag_filter, int wrap_s, int wrap_t) {
GL = GLAdapter.get();
GL.glTexParameterf(GL20.GL_TEXTURE_2D,
GL20.GL_TEXTURE_MIN_FILTER,
min_filter);
@ -87,9 +87,8 @@ public class GlUtils {
public static int loadTexture(byte[] pixel, int width, int height, int format,
int min_filter, int mag_filter, int wrap_s, int wrap_t) {
int[] textureIds = GlUtils.glGenTextures(1);
GL = GLAdapter.get();
int[] textureIds = GLUtils.glGenTextures(1);
GLState.bindTex2D(textureIds[0]);
setTextureParameter(min_filter, mag_filter, wrap_s, wrap_t);
@ -107,8 +106,6 @@ public class GlUtils {
}
public static int loadStippleTexture(byte[] stipple) {
GL = GLAdapter.get();
int sum = 0;
for (byte flip : stipple)
sum += flip;
@ -186,8 +183,6 @@ public class GlUtils {
* @return gl identifier
*/
public static int createProgram(String vertexSource, String fragmentSource) {
GL = GLAdapter.get();
int vertexShader = loadShader(GL20.GL_VERTEX_SHADER, vertexSource);
if (vertexShader == 0) {
return 0;
@ -224,7 +219,7 @@ public class GlUtils {
* ...
*/
public static void checkGlError(String op) {
GL = GLAdapter.get();
//GL = GLAdapter.get();
int error;
while ((error = GL.glGetError()) != 0) { // GL20.GL_NO_ERROR) {
@ -234,8 +229,6 @@ public class GlUtils {
}
public static boolean checkGlOutOfMemory(String op) {
GL = GLAdapter.get();
int error;
boolean oom = false;
while ((error = GL.glGetError()) != 0) {// GL20.GL_NO_ERROR) {
@ -248,8 +241,6 @@ public class GlUtils {
}
public static void setColor(int handle, float[] c, float alpha) {
GL = GLAdapter.get();
if (alpha >= 1) {
GL.glUniform4f(handle, c[0], c[1], c[2], c[3]);
} else {
@ -307,8 +298,6 @@ public class GlUtils {
}
public static void glUniform4fv(int location, int count, float[] val) {
GL = GLAdapter.get();
FloatBuffer buf = MapRenderer.getFloatBuffer(count * 4);
buf.put(val);
buf.flip();
@ -316,8 +305,6 @@ public class GlUtils {
}
public static int[] glGenBuffers(int num) {
GL = GLAdapter.get();
IntBuffer buf = MapRenderer.getIntBuffer(num);
buf.position(0);
buf.limit(num);
@ -330,8 +317,6 @@ public class GlUtils {
}
public static void glDeleteBuffers(int num, int[] ids) {
GL = GLAdapter.get();
IntBuffer buf = MapRenderer.getIntBuffer(num);
buf.put(ids, 0, num);
buf.position(0);
@ -342,7 +327,6 @@ public class GlUtils {
if (num <= 0)
return null;
GL = GLAdapter.get();
int[] ret = new int[num];
IntBuffer buf = MapRenderer.getIntBuffer(num);
@ -363,8 +347,6 @@ public class GlUtils {
}
public static void glDeleteTextures(int num, int[] ids) {
GL = GLAdapter.get();
IntBuffer buf = MapRenderer.getIntBuffer(num);
buf.put(ids, 0, num);
buf.position(0);

View File

@ -14,6 +14,7 @@
*/
package org.oscim.renderer;
import org.oscim.backend.GL20;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.renderer.MapRenderer.Matrices;
@ -43,12 +44,22 @@ public abstract class LayerRenderer {
return isReady;
}
protected boolean isInitialized;
public LayerRenderer() {
mMapPosition = new MapPosition();
}
////////////////////// MapRender Thread ///////////////////////////
/**
* Called on GL Thread before first update().
* */
protected boolean setup() {
return true;
}
/**
* ////////////////////// MapRender Thread ///////////////////////////
* 1. Called first by MapRenderer: Update the state here.
*
* @param position current MapPosition
@ -74,7 +85,7 @@ public abstract class LayerRenderer {
* @param matrices contains the current view- and projection-matrices.
* 'matrices.mvp' is for temporary use to build the model-
* view-projection to set as uniform.
*/
*/
protected abstract void render(MapPosition position, Matrices matrices);
/**
@ -120,4 +131,10 @@ public abstract class LayerRenderer {
protected void setMatrix(MapPosition position, Matrices matrices) {
setMatrix(position, matrices, true);
}
protected static GL20 GL;
static void init(GL20 gl) {
GL = gl;
}
}

View File

@ -29,15 +29,13 @@ import org.oscim.map.Map;
import org.oscim.map.Viewport;
import org.oscim.renderer.elements.ElementLayers;
import org.oscim.tiling.MapTile;
import org.oscim.utils.GlUtils;
import org.oscim.utils.Matrix4;
import org.oscim.utils.pool.Inlist;
import org.oscim.utils.pool.Pool;
public class MapRenderer {
private static final String TAG = MapRenderer.class.getName();
private static GL20 GL = GLAdapter.get();
static GL20 GL;
private static final int SHORT_BYTES = 2;
private static final int CACHE_TILES_MAX = 250;
@ -56,17 +54,17 @@ public class MapRenderer {
public class Matrices {
/** do not modify! */
public final Matrix4 viewproj = new Matrix4();
/** do not modify! */
public final Matrix4 proj = new Matrix4();
/** do not modify! */
public final Matrix4 view = new Matrix4();
/** do not modify! */
/** Do not modify! */
public final GLMatrix viewproj = new GLMatrix();
/** Do not modify! */
public final GLMatrix proj = new GLMatrix();
/** Do not modify! */
public final GLMatrix view = new GLMatrix();
/** Do not modify! */
public final float[] mapPlane = new float[8];
/** for temporary use by callee */
public final Matrix4 mvp = new Matrix4();
/** For temporary use, to setup MVP-Matrix */
public final GLMatrix mvp = new GLMatrix();
/**
* Set MVP so that coordinates are in screen pixel coordinates with 0,0
@ -177,7 +175,7 @@ public class MapRenderer {
}
public static void setBackgroundColor(int color) {
mClearColor = GlUtils.colorToFloat(color);
mClearColor = GLUtils.colorToFloat(color);
mUpdateColor = true;
}
@ -326,7 +324,7 @@ public class MapRenderer {
renderLayer.render(mMapPosition, mMatrices);
}
if (GlUtils.checkGlOutOfMemory("finish")) {
if (GLUtils.checkGlOutOfMemory("finish")) {
BufferObject.checkBufferUsage(true);
// FIXME also throw out some textures etc
}
@ -353,7 +351,7 @@ public class MapRenderer {
mMatrices.mvp.setScale(0.5f, 0.5f, 1);
mMatrices.proj.multiplyLhs(mMatrices.mvp);
}
GL = GLAdapter.get();
GL.glViewport(0, 0, width, height);
GL.glScissor(0, 0, width, height);
GL.glEnable(GL20.GL_SCISSOR_TEST);
@ -371,7 +369,7 @@ public class MapRenderer {
mNewSurface = false;
// upload quad indices used by Texture- and LineTexRenderer
int[] vboIds = GlUtils.glGenBuffers(2);
int[] vboIds = GLUtils.glGenBuffers(2);
mQuadIndicesID = vboIds[0];
int maxIndices = maxQuads * 6;
@ -411,22 +409,27 @@ public class MapRenderer {
if (mClearColor != null)
mUpdateColor = true;
GLState.init();
GLState.init(GL);
mMap.updateMap(true);
}
public void onSurfaceCreated() {
GL = GLAdapter.get();
Log.d(TAG, "surface created");
// Log.d(TAG, "surface created");
// Log.d(TAG, GL.glGetString(GL20.GL_EXTENSIONS));
// classes that require GL context for initialization
ElementLayers.initRenderer();
GLState.init(GL);
GLUtils.init(GL);
// Set up some vertex buffer objects
BufferObject.init(CACHE_TILES);
BufferObject.init(GL, CACHE_TILES);
// classes that require GL context for initialization
ElementLayers.initRenderer(GL);
LayerRenderer.init(GL);
mNewSurface = true;
}

View File

@ -17,12 +17,11 @@ package org.oscim.renderer.elements;
import java.nio.ShortBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.utils.GlUtils;
/**
* Renderer for a single bitmap, width and height must be power of 2.
@ -152,7 +151,7 @@ public class BitmapLayer extends TextureLayer {
public static final class Renderer {
//private final static String TAG = BitmapRenderer.class.getName();
private static final GL20 GL = GLAdapter.get();
private static GL20 GL;
public final static boolean debug = true;
@ -170,8 +169,10 @@ public class BitmapLayer extends TextureLayer {
final static int VERTICES_PER_SPRITE = 4;
final static int SHORTS_PER_VERTICE = 6;
static void init() {
mTextureProgram = GlUtils.createProgram(textVertexShader,
static void init(GL20 gl) {
GL = gl;
mTextureProgram = GLUtils.createProgram(textVertexShader,
textFragmentShader);
hTextureMVMatrix = GL.glGetUniformLocation(mTextureProgram, "u_mv");
@ -183,7 +184,8 @@ public class BitmapLayer extends TextureLayer {
hAlpha = GL.glGetUniformLocation(mTextureProgram, "u_alpha");
}
public static RenderElement draw(RenderElement renderElement, Matrices m, float scale, float alpha) {
public static RenderElement draw(RenderElement renderElement, Matrices m, float scale,
float alpha) {
//GLState.test(false, false);
GLState.blend(true);

View File

@ -16,21 +16,21 @@ package org.oscim.renderer.elements;
import java.nio.ShortBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.Log;
import org.oscim.renderer.BufferObject;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.backend.Log;
public class ElementLayers {
private final static String TAG = ElementLayers.class.getName();
public static void initRenderer() {
LineLayer.Renderer.init();
LineTexLayer.Renderer.init();
PolygonLayer.Renderer.init();
TextureLayer.Renderer.init();
BitmapLayer.Renderer.init();
TextureItem.init(0);
public static void initRenderer(GL20 gl) {
LineLayer.Renderer.init(gl);
LineTexLayer.Renderer.init(gl);
PolygonLayer.Renderer.init(gl);
TextureLayer.Renderer.init(gl);
BitmapLayer.Renderer.init(gl);
TextureItem.init(gl, 0);
}
// mixed Polygon- and LineLayer

View File

@ -35,8 +35,6 @@ import org.oscim.utils.geom.Triangulator;
public class ExtrusionLayer extends RenderElement {
private final static String TAG = ExtrusionLayer.class.getName();
private static final GL20 GL = GLAdapter.get();
private static final float S = MapRenderer.COORD_SCALE;
private VertexItem mVertices;
private VertexItem mCurVertices;
@ -399,6 +397,7 @@ public class ExtrusionLayer extends RenderElement {
vboIndices = BufferObject.get(GL20.GL_ELEMENT_ARRAY_BUFFER, size);
vboIndices.loadBufferData(sbuf, size);
GL20 GL = GLAdapter.get();
GL.glBindBuffer(GL20.GL_ELEMENT_ARRAY_BUFFER, 0);
// upload vertices

View File

@ -23,12 +23,12 @@ import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.GLState;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.FastMath;
import org.oscim.utils.GlUtils;
/**
*/
@ -64,9 +64,7 @@ public final class LineLayer extends RenderElement {
}
/**
* line extrusion is based on code from GLMap
* (https://github.com/olofsj/GLMap/)
*
* @deprecated
* @param points
* array of points as x,y pairs.
* @param index
@ -86,6 +84,8 @@ public final class LineLayer extends RenderElement {
addLine(geom.points, geom.index, -1, true);
else if (geom.isLine())
addLine(geom.points, geom.index, -1, false);
else
Log.d(TAG, "geometry must be LINE or POLYGON");
}
public void addLine(float[] points, int numPoints, boolean closed) {
@ -598,17 +598,17 @@ public final class LineLayer extends RenderElement {
private static int[] hLineMode = new int[2];
public static int mTexID;
static boolean init() {
GL = GLAdapter.get();
static boolean init(GL20 gl) {
GL = gl;
lineProgram[0] = GlUtils.createProgram(lineVertexShader,
lineProgram[0] = GLUtils.createProgram(lineVertexShader,
lineFragmentShader);
if (lineProgram[0] == 0) {
Log.e(TAG, "Could not create line program.");
//return false;
}
lineProgram[1] = GlUtils.createProgram(lineVertexShader,
lineProgram[1] = GLUtils.createProgram(lineVertexShader,
lineSimpleFragmentShader);
if (lineProgram[1] == 0) {
Log.e(TAG, "Could not create simple line program.");
@ -642,7 +642,7 @@ public final class LineLayer extends RenderElement {
}
}
mTexID = GlUtils.loadTexture(pixel, 128, 128, GL20.GL_ALPHA,
mTexID = GLUtils.loadTexture(pixel, 128, 128, GL20.GL_ALPHA,
GL20.GL_NEAREST, GL20.GL_NEAREST,
GL20.GL_MIRRORED_REPEAT, GL20.GL_MIRRORED_REPEAT);
@ -650,7 +650,8 @@ public final class LineLayer extends RenderElement {
return true;
}
public static RenderElement draw(ElementLayers layers, RenderElement curLayer, MapPosition pos,
public static RenderElement draw(ElementLayers layers, RenderElement curLayer,
MapPosition pos,
Matrices m, float div, int mode) {
if (curLayer == null)
@ -717,12 +718,12 @@ public final class LineLayer extends RenderElement {
float width;
if (line.fade < zoom) {
GlUtils.setColor(uLineColor, line.color, 1);
GLUtils.setColor(uLineColor, line.color, 1);
} else if (line.fade > zoom) {
continue;
} else {
float alpha = (float) (scale > 1.2 ? scale : 1.2) - 1;
GlUtils.setColor(uLineColor, line.color, alpha);
GLUtils.setColor(uLineColor, line.color, alpha);
}
if (mode == 0 && blur && line.blur == 0) {

View File

@ -19,18 +19,17 @@ import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.GlUtils;
/**
* RenderElement for textured or stippled lines
*
* this would be all so much simpler with geometry shaders...
*/
public final class LineTexLayer extends RenderElement {
@ -99,6 +98,10 @@ public final class LineTexLayer extends RenderElement {
this.evenSegment = true;
}
public void addLine(GeometryBuffer geom) {
addLine(geom.points, geom.index);
}
public void addLine(float[] points, short[] index) {
if (vertexItems == null) {
@ -247,11 +250,12 @@ public final class LineTexLayer extends RenderElement {
public final static class Renderer {
private static final GL20 GL = GLAdapter.get();
private static GL20 GL;
// factor to normalize extrusion vector and scale to coord scale
private final static float COORD_SCALE_BY_DIR_SCALE =
MapRenderer.COORD_SCALE / LineLayer.DIR_SCALE;
MapRenderer.COORD_SCALE
/ LineLayer.DIR_SCALE;
private static int shader;
private static int hVertexPosition0;
@ -269,8 +273,10 @@ public final class LineTexLayer extends RenderElement {
private static int mVertexFlipID;
public static void init() {
shader = GlUtils.createProgram(vertexShader, fragmentShader);
public static void init(GL20 gl) {
GL = gl;
shader = GLUtils.createProgram(vertexShader, fragmentShader);
if (shader == 0) {
Log.e(TAG, "Could not create program.");
return;
@ -290,13 +296,13 @@ public final class LineTexLayer extends RenderElement {
hVertexLength1 = GL.glGetAttribLocation(shader, "a_len1");
hVertexFlip = GL.glGetAttribLocation(shader, "a_flip");
int[] vboIds = GlUtils.glGenBuffers(1);
int[] vboIds = GLUtils.glGenBuffers(1);
mVertexFlipID = vboIds[0];
// bytes: 0, 1, 0, 1, 0, ...
byte[] flip = new byte[MapRenderer.maxQuads * 4];
for (int i = 0; i < flip.length; i++)
flip[i] = (byte)(i % 2);
flip[i] = (byte) (i % 2);
ByteBuffer buf = ByteBuffer.allocateDirect(flip.length)
.order(ByteOrder.nativeOrder());
@ -306,7 +312,7 @@ public final class LineTexLayer extends RenderElement {
ShortBuffer sbuf = buf.asShortBuffer();
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, mVertexFlipID);
GL.glBufferData(GL20.GL_ARRAY_BUFFER, flip.length , sbuf,
GL.glBufferData(GL20.GL_ARRAY_BUFFER, flip.length, sbuf,
GL20.GL_STATIC_DRAW);
GL.glBindBuffer(GL20.GL_ARRAY_BUFFER, 0);
@ -361,8 +367,8 @@ public final class LineTexLayer extends RenderElement {
LineTexLayer ll = (LineTexLayer) l;
Line line = ll.line;
GlUtils.setColor(hTexColor, line.stippleColor, 1);
GlUtils.setColor(hBgColor, line.color, 1);
GLUtils.setColor(hTexColor, line.stippleColor, 1);
GLUtils.setColor(hBgColor, line.color, 1);
float pScale = (int) (s + 0.5f);
if (pScale < 1)
@ -500,8 +506,7 @@ public final class LineTexLayer extends RenderElement {
+ " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
+ " } "; //*/
/*
* final static String fragmentShader = ""
/* final static String fragmentShader = ""
* + "#extension GL_OES_standard_derivatives : enable\n"
* + " precision mediump float;"
* + " uniform sampler2D tex;"
@ -522,10 +527,8 @@ public final class LineTexLayer extends RenderElement {
* + " gl_FragColor = u_bgcolor * stipple_p;"
* // +
* " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
* + "}"; //
*/
/*
* final static String fragmentShader = ""
* + "}"; // */
/* final static String fragmentShader = ""
* + "#extension GL_OES_standard_derivatives : enable\n"
* + " precision mediump float;"
* + " uniform sampler2D tex;"
@ -544,8 +547,7 @@ public final class LineTexLayer extends RenderElement {
* + " float stipple_p = smoothstep(0.495, 0.505, dist);"
* +
* " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
* + " } "; //
*/
* + " } "; // */
}
}

View File

@ -20,18 +20,17 @@ import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.GLMatrix;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.theme.renderinstruction.Area;
import org.oscim.utils.FastMath;
import org.oscim.utils.GlUtils;
import org.oscim.utils.Matrix4;
public final class PolygonLayer extends RenderElement {
private static final String TAG = PolygonLayer.class.getName();
@ -144,21 +143,21 @@ public final class PolygonLayer extends RenderElement {
private static boolean enableTexture = false;
static boolean init() {
GL = GLAdapter.get();
static boolean init(GL20 gl) {
GL = gl;
for (int i = 0; i < numShaders; i++) {
// Set up the program for rendering polygons
if (i == 0) {
if (MapRenderer.debugView)
polygonProgram[i] = GlUtils.createProgram(polygonVertexShaderZ,
polygonProgram[i] = GLUtils.createProgram(polygonVertexShaderZ,
polygonFragmentShaderZ);
else
polygonProgram[i] = GlUtils.createProgram(polygonVertexShader,
polygonProgram[i] = GLUtils.createProgram(polygonVertexShader,
polygonFragmentShader);
} else if (i == 1) {
polygonProgram[i] = GlUtils.createProgram(textureVertexShader,
polygonProgram[i] = GLUtils.createProgram(textureVertexShader,
textureFragmentShader);
}
@ -210,17 +209,17 @@ public final class PolygonLayer extends RenderElement {
}
GLState.blend(true);
GlUtils.setColor(hPolygonColor[shader], a.color, f);
GLUtils.setColor(hPolygonColor[shader], a.color, f);
} else if (a.blend > 0 && a.blend <= zoom) {
/* blend colors (not alpha) */
GLState.blend(false);
if (a.blend == zoom)
GlUtils.setColorBlend(hPolygonColor[shader],
GLUtils.setColorBlend(hPolygonColor[shader],
a.color, a.blendColor, scale - 1.0f);
else
GlUtils.setColor(hPolygonColor[shader], a.blendColor, 1);
GLUtils.setColor(hPolygonColor[shader], a.blendColor, 1);
} else {
if (a.color < 0xff000000)
@ -228,7 +227,7 @@ public final class PolygonLayer extends RenderElement {
else
GLState.blend(false);
GlUtils.setColor(hPolygonColor[shader], a.color, 1);
GLUtils.setColor(hPolygonColor[shader], a.color, 1);
}
// set stencil buffer mask used to draw this layer
@ -433,7 +432,7 @@ public final class PolygonLayer extends RenderElement {
*/
if (color != 0) {
GlUtils.setColor(hPolygonColor[0], color, 1);
GLUtils.setColor(hPolygonColor[0], color, 1);
GLState.blend(true);
} else {
// disable drawing to framebuffer (will be re-enabled in fill)
@ -458,7 +457,7 @@ public final class PolygonLayer extends RenderElement {
private static float[] debugFillColor2 = { .8f, .8f, .8f, .8f };
private static FloatBuffer mDebugFill;
static void debugDraw(Matrix4 m, float[] coords, int color) {
static void debugDraw(GLMatrix m, float[] coords, int color) {
GLState.test(false, false);
if (mDebugFill == null) {
mDebugFill = ByteBuffer.allocateDirect(32).order(ByteOrder.nativeOrder())
@ -478,13 +477,13 @@ public final class PolygonLayer extends RenderElement {
m.setAsUniform(hPolygonMatrix[0]);
if (color == 0)
GlUtils.glUniform4fv(hPolygonColor[0], 1, debugFillColor);
GLUtils.glUniform4fv(hPolygonColor[0], 1, debugFillColor);
else
GlUtils.glUniform4fv(hPolygonColor[0], 1, debugFillColor2);
GLUtils.glUniform4fv(hPolygonColor[0], 1, debugFillColor2);
GL.glDrawArrays(GL20.GL_TRIANGLE_STRIP, 0, 4);
GlUtils.checkGlError("draw debug");
GLUtils.checkGlError("draw debug");
}
private final static String polygonVertexShader = ""

View File

@ -18,12 +18,11 @@ import java.util.ArrayList;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Color;
import org.oscim.renderer.GLState;
import org.oscim.utils.GlUtils;
import org.oscim.renderer.GLUtils;
import org.oscim.utils.pool.Inlist;
import org.oscim.utils.pool.SyncPool;
@ -31,7 +30,8 @@ import org.oscim.utils.pool.SyncPool;
public class TextureItem extends Inlist<TextureItem> {
private final static String TAG = TextureItem.class.getName();
private static final GL20 GL = GLAdapter.get();
private static GL20 GL;
// texture ID
public int id;
@ -135,7 +135,7 @@ public class TextureItem extends Inlist<TextureItem> {
pool = null;
}
int[] textureIds = GlUtils.glGenTextures(num);
int[] textureIds = GLUtils.glGenTextures(num);
for (int i = 0; i < num; i++) {
TextureItem to = new TextureItem(textureIds[i]);
@ -216,7 +216,7 @@ public class TextureItem extends Inlist<TextureItem> {
/**
* This function may only be used in GLRenderer Thread.
*
*
* @param t
* the TextureObjet to compile and upload
*/
@ -231,11 +231,11 @@ public class TextureItem extends Inlist<TextureItem> {
int size = mTextures.size();
if (size > 0) {
int[] tmp = new int[size];
for (int i = 0; i < size; i++){
for (int i = 0; i < size; i++) {
tmp[i] = mTextures.get(i).intValue();
}
mTextures.clear();
GlUtils.glDeleteTextures(size, tmp);
GLUtils.glDeleteTextures(size, tmp);
mTexCnt -= size;
}
@ -243,20 +243,20 @@ public class TextureItem extends Inlist<TextureItem> {
if (t.id < 0) {
mTexCnt++;
int[] textureIds = GlUtils.glGenTextures(1);
int[] textureIds = GLUtils.glGenTextures(1);
t.id = textureIds[0];
initTexture(t);
if (TextureLayer.Renderer.debug)
Log.d(TAG, "fill:" + pool.getFill()
+ " count:" + mTexCnt
+ " new texture " + t.id);
+ " count:" + mTexCnt
+ " new texture " + t.id);
}
//Log.d(TAG, "UPLOAD ID: " + t.id);
uploadTexture(t, t.bitmap,
mBitmapFormat, mBitmapType,
TEXTURE_WIDTH, TEXTURE_HEIGHT);
mBitmapFormat, mBitmapType,
TEXTURE_WIDTH, TEXTURE_HEIGHT);
if (!t.ownBitmap)
TextureItem.releaseBitmap(t);
@ -267,7 +267,7 @@ public class TextureItem extends Inlist<TextureItem> {
}
public static void uploadTexture(TextureItem t, Bitmap bitmap,
int format, int type, int w, int h) {
int format, int type, int w, int h) {
if (t == null) {
Log.d(TAG, "no texture!");
@ -287,31 +287,33 @@ public class TextureItem extends Inlist<TextureItem> {
}
if (TextureLayer.Renderer.debug)
GlUtils.checkGlError(TAG);
GLUtils.checkGlError(TAG);
}
private static void initTexture(TextureItem t) {
GLState.bindTex2D(t.id);
GL.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MIN_FILTER,
GL20.GL_LINEAR);
GL20.GL_LINEAR);
GL.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_MAG_FILTER,
GL20.GL_LINEAR);
GL20.GL_LINEAR);
if (t.repeat) {
GL.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_WRAP_S,
GL20.GL_REPEAT);
GL20.GL_REPEAT);
GL.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_WRAP_T,
GL20.GL_REPEAT);
GL20.GL_REPEAT);
} else {
GL.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_WRAP_S,
GL20.GL_CLAMP_TO_EDGE);
GL20.GL_CLAMP_TO_EDGE);
GL.glTexParameterf(GL20.GL_TEXTURE_2D, GL20.GL_TEXTURE_WRAP_T,
GL20.GL_CLAMP_TO_EDGE);
GL20.GL_CLAMP_TO_EDGE);
}
}
static void init(int num) {
static void init(GL20 gl, int num) {
GL = gl;
Log.d(TAG, "init textures " + num);
mTexCnt = num;
pool.init(num);

View File

@ -19,11 +19,10 @@ import static org.oscim.renderer.MapRenderer.COORD_SCALE;
import java.nio.ShortBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.utils.GlUtils;
public abstract class TextureLayer extends RenderElement {
// holds textures and offset in vbo
@ -88,7 +87,7 @@ public abstract class TextureLayer extends RenderElement {
public static final class Renderer {
//private final static String TAG = TextureRenderer.class.getName();
private static final GL20 GL = GLAdapter.get();
private static GL20 GL;
public final static boolean debug = false;
@ -105,8 +104,10 @@ public abstract class TextureLayer extends RenderElement {
final static int VERTICES_PER_SPRITE = 4;
final static int SHORTS_PER_VERTICE = 6;
static void init() {
mTextureProgram = GlUtils.createProgram(textVertexShader,
static void init(GL20 gl) {
GL = gl;
mTextureProgram = GLUtils.createProgram(textVertexShader,
textFragmentShader);
hTextureMVMatrix = GL.glGetUniformLocation(mTextureProgram, "u_mv");

View File

@ -19,13 +19,12 @@ import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.core.MapPosition;
import org.oscim.map.Map;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.LayerRenderer;
import org.oscim.utils.GlUtils;
import org.oscim.renderer.MapRenderer.Matrices;
/*
@ -37,8 +36,6 @@ import org.oscim.utils.GlUtils;
public class CustomRenderer extends LayerRenderer {
private static final GL20 GL = GLAdapter.get();
private final Map mMap;
private int mProgramObject;
@ -118,12 +115,12 @@ public class CustomRenderer extends LayerRenderer {
// Draw the triangle
GL.glDrawArrays(GL20.GL_TRIANGLE_STRIP, 0, 4);
GlUtils.checkGlError("...");
GLUtils.checkGlError("...");
}
private boolean init() {
// Load the vertex/fragment shaders
int programObject = GlUtils.createProgram(vShaderStr, fShaderStr);
int programObject = GLUtils.createProgram(vShaderStr, fShaderStr);
if (programObject == 0)
return false;

View File

@ -17,16 +17,15 @@ package org.oscim.renderer.test;
import java.nio.FloatBuffer;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.canvas.Color;
import org.oscim.core.MapPosition;
import org.oscim.renderer.BufferObject;
import org.oscim.renderer.GLState;
import org.oscim.renderer.GLUtils;
import org.oscim.renderer.LayerRenderer;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.renderer.GLState;
import org.oscim.renderer.LayerRenderer;
import org.oscim.utils.FastMath;
import org.oscim.utils.GlUtils;
/*
@ -38,8 +37,6 @@ import org.oscim.utils.GlUtils;
public class CustomRenderer2 extends LayerRenderer {
private static final GL20 GL = GLAdapter.get();
private int mProgramObject;
private int hVertexPosition;
private int hMatrixPosition;
@ -143,13 +140,13 @@ public class CustomRenderer2 extends LayerRenderer {
| (int) (0xff * fx) << 8
| (int) (0xff * fz);
GlUtils.setColor(hColorPosition, c, alpha);
GLUtils.setColor(hColorPosition, c, alpha);
GL.glDrawArrays(GL20.GL_TRIANGLE_FAN, 0, 6);
}
}
GlUtils.setColor(hColorPosition, Color.DKGRAY, 0.3f);
GLUtils.setColor(hColorPosition, Color.DKGRAY, 0.3f);
for (int y = -offset_y; y < offset_y; y++) {
for (int x = -offset_x; x < offset_x; x++) {
@ -161,12 +158,12 @@ public class CustomRenderer2 extends LayerRenderer {
}
}
GlUtils.checkGlError("...");
GLUtils.checkGlError("...");
}
private boolean init() {
// Load the vertex/fragment shaders
int programObject = GlUtils.createProgram(vShaderStr, fShaderStr);
int programObject = GLUtils.createProgram(vShaderStr, fShaderStr);
if (programObject == 0)
return false;

View File

@ -18,21 +18,20 @@ import static org.oscim.tiling.MapTile.STATE_NEW_DATA;
import static org.oscim.tiling.MapTile.STATE_READY;
import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter;
import org.oscim.backend.Log;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.renderer.BufferObject;
import org.oscim.renderer.GLMatrix;
import org.oscim.renderer.LayerRenderer;
import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.renderer.elements.BitmapLayer;
import org.oscim.renderer.elements.RenderElement;
import org.oscim.renderer.elements.LineLayer;
import org.oscim.renderer.elements.LineTexLayer;
import org.oscim.renderer.elements.PolygonLayer;
import org.oscim.renderer.elements.RenderElement;
import org.oscim.utils.FastMath;
import org.oscim.utils.Matrix4;
import org.oscim.utils.ScanBox;
import org.oscim.utils.quadtree.QuadTree;
@ -335,8 +334,6 @@ public class TileRenderer extends LayerRenderer {
}
};
private static final GL20 GL = GLAdapter.get();
// Counter increases polygon-offset for each tile drawn.
private int mOffsetCnt;
@ -345,7 +342,7 @@ public class TileRenderer extends LayerRenderer {
private int mDrawSerial = 0;
private Matrices mMatrices;
private final Matrix4 mProjMatrix = new Matrix4();
private final GLMatrix mProjMatrix = new GLMatrix();
/**
* Draw tiles: