This commit is contained in:
Hannes Janetzek
2012-10-13 04:58:02 +02:00
parent 4a06553ddc
commit 9efe46e3ba
10 changed files with 440 additions and 1102 deletions

View File

@@ -468,22 +468,14 @@ public class GLRenderer implements GLSurfaceView.Renderer {
// Log.d(TAG, "visible: " + tileCnt);
uploadCnt = 0;
// int updateTextures = 0;
// compile data and upload to VBOsi
for (int i = 0; i < tileCnt; i++) {
MapTile tile = tiles[i];
// if (!isVisible(mapPosition, tile))
// continue;
if (!tile.isVisible)
continue;
// if (MapView.staticLabeling) {
// if (tile.texture == null && TextRenderer.drawToTexture(tile))
// updateTextures++;
// }
if (tile.newData) {
uploadTileData(tile);
continue;
@@ -527,11 +519,6 @@ public class GLRenderer implements GLSurfaceView.Renderer {
}
// }
// if (MapView.staticLabeling) {
// if (updateTextures > 0)
// TextRenderer.compileTextures();
// }
GLES20.glEnable(GL_DEPTH_TEST);
GLES20.glEnable(GL_POLYGON_OFFSET_FILL);
@@ -560,40 +547,6 @@ public class GLRenderer implements GLSurfaceView.Renderer {
GLES20.glEnable(GL_BLEND);
// if (MapView.staticLabeling) {
// int z = mapPosition.zoomLevel;
// float s = mapPosition.scale;
// int zoomLevelDiff = Math.max(z - TileGenerator.STROKE_MAX_ZOOM_LEVEL,
// 0);
// float scale = (float) Math.pow(1.4, zoomLevelDiff);
// if (scale < 1)
// scale = 1;
//
// if (z >= TileGenerator.STROKE_MAX_ZOOM_LEVEL)
// TextRenderer.beginDraw(scale / FloatMath.sqrt(s), mProjMatrix);
// else
// TextRenderer.beginDraw(1f / s, mProjMatrix);
//
// for (int i = 0; i < tileCnt; i++) {
// MapTile t = tiles[i];
// if (!t.isVisible)
// continue;
//
// if (t.holder == null) {
// if (t.texture != null) {
// setMatrix(mMVPMatrix, t, 1, false);
// TextRenderer.drawTile(t, mMVPMatrix);
// }
// } else {
// if (t.holder.texture != null) {
// setMatrix(mMVPMatrix, t, 1, false);
// TextRenderer.drawTile(t.holder, mMVPMatrix);
// }
// }
// }
// TextRenderer.endDraw();
// }
// call overlay renderer
for (Overlay overlay : mOverlays) {
if (overlay.newData) {

View File

@@ -32,24 +32,10 @@ public final class Shaders {
+ " gl_Position = u_mvp * vec4(a_position + dir, 0.0,1.0);"
// last two bits of a_st hold the texture coordinates
+ " v_st = u_width * (abs(mod(a_st,4.0)) - 1.0);"
// TODO use bit operations when available (gles 1.3)
// use bit operations when available (gles 1.3)
// + " v_st = u_width * vec2(ivec2(a_st) & 3 - 1);"
+ "}";
// final static String lineVertexShader = ""
// + "precision mediump float;"
// + "uniform mat4 mvp;"
// + "attribute vec4 a_position;"
// + "attribute vec2 a_st;"
// + "varying vec2 v_st;"
// + "uniform float u_width;"
// + "const float dscale = 8.0/1000.0;"
// + "void main() {"
// + " vec2 dir = dscale * u_width * a_position.zw;"
// + " gl_Position = mvp * vec4(a_position.xy + dir, 0.0,1.0);"
// + " v_st = u_width * a_st;"
// + "}";
final static String lineSimpleFragmentShader = ""
+ "precision mediump float;"
+ "uniform float u_wscale;"
@@ -57,7 +43,6 @@ public final class Shaders {
+ "uniform int u_mode;"
+ "uniform vec4 u_color;"
+ "varying vec2 v_st;"
+ "const float zero = 0.0;"
+ "void main() {"
+ " float len;"
+ " if (u_mode == 0)"
@@ -66,108 +51,31 @@ public final class Shaders {
+ " len = u_width - length(v_st);"
// fade to alpha. u_wscale is the width in pixel which should be
// faded, u_width - len the position of this fragment on the
// perpendicular to this line segment
+ " vec4 color = u_color;"
+ " if (len < u_wscale)"
+ " color *= len / u_wscale;"
+ " gl_FragColor = color;"
// smoothstep(zero, u_wscale, u_width - len) * u_color;"
// perpendicular to this line segment, only works with no
// perspective
+ " gl_FragColor = u_color * min(1.0, len / u_wscale);"
+ "}";
// final static String lineFragmentShader = ""
// + "#extension GL_OES_standard_derivatives : enable\n"
// + "precision mediump float;\n"
// + "uniform float u_wscale;"
// + "uniform float u_width;"
// + "uniform vec4 u_color;"
// + "varying vec2 v_st;"
// + "const float zero = 0.0;"
// + "const vec4 col1 = vec4(0.5,0.0,0.0,0.5);"
// + "const vec4 col2 = vec4(0.0,0.0,0.5,0.5);"
// + "void main() {"
// + " vec4 color = u_color;"
// + " float width = u_width;"
// + " float len;"
// + " if (v_st.t == zero)"
// + " len = abs(v_st.s);"
// + " else "
// + " len = length(v_st);"
// + " vec2 st_width = fwidth(v_st);"
// + " float fuzz = max(st_width.s, st_width.t);"
// // + " if (v_st.s > 0.0){"
// // + " color = col1;"
// + " color *= (1.0 - len) / (fuzz + u_wscale);"
// // + " }else{"
// // + " color = col2;"
// // + " color *= 1.0 - (fuzz + u_wscale) / (len - 1.0);"
// // + " }"
// + " gl_FragColor = color;"
// + "}";
// final static String lineFragmentShader = ""
// + "#extension GL_OES_standard_derivatives : enable\n"
// + "precision mediump float;\n"
// + "uniform float u_wscale;"
// + "uniform float u_width;"
// + "uniform vec4 u_color;"
// + "varying vec2 v_st;"
// + "const float zero = 0.0;"
// + "const vec4 col1 = vec4(0.5,0.0,0.0,0.5);"
// + "const vec4 col2 = vec4(0.0,0.0,0.5,0.5);"
// + "void main() {"
// + " vec4 color = u_color;"
// + " float width = u_width;"
// + " float len;"
// + " if (v_st.t == zero)"
// + " len = abs(v_st.s);"
// + " else "
// + " len = length(v_st);"
// + " vec2 st_width = fwidth(v_st);"
// + " float fuzz = max(st_width.s, st_width.t);"
// + " if (u_width > 1.0) fuzz *= 1.2;"
// + " color *= (u_width - len) / (fuzz + u_wscale);"
// + " if (v_st.s > 0.0){"
// + " if (u_width - len < fuzz + u_wscale)"
// + " color = col1 * (u_width - len) / (fuzz + u_wscale);"
// + " }else{"
// + " if (u_width - len < fuzz + u_wscale)"
// + " color = col2 * (u_width - len) / (fuzz + u_wscale);"
// + "}"
// // + " color *= (fuzz + u_wscale);"
// // " color *= smoothstep(zero, fuzz + u_wscale, u_width - len);"
// + " gl_FragColor = color;"
// + "}";
final static String lineFragmentShader = ""
+ "#extension GL_OES_standard_derivatives : enable\n"
+ "precision mediump float;\n"
+ "precision mediump float;"
+ "uniform float u_wscale;"
+ "uniform float u_width;"
+ "uniform int u_mode;"
+ "uniform vec4 u_color;"
+ "varying vec2 v_st;"
// + "const vec4 col1 = vec4(0.5,0.0,0.0,0.5);"
// + "const vec4 col2 = vec4(0.0,0.0,0.5,0.5);"
+ "const float zero = 0.0;"
+ "void main() {"
+ " vec4 color = u_color;"
+ " float width = u_width;"
+ " float len;"
+ " if (u_mode == 0)"
+ " float fuzz;"
+ " if (u_mode == 0){"
+ " len = u_width - abs(v_st.s);"
+ " else "
+ " fuzz = u_wscale + fwidth(v_st.s);"
+ " } else {"
+ " len = u_width - length(v_st);"
+ " vec2 st_width = fwidth(v_st);"
+ " float fuzz = max(st_width.s, st_width.t);"
// + " if (u_width > 1.0) fuzz *= 1.2;"
+ " fuzz += u_wscale;"
+ " if (len < fuzz){"
// + " if (v_st.s > zero)"
+ " color *= len / fuzz;"
// + " else"
// + " color = col2 * (u_width - len) / fuzz;"
+ " vec2 st_width = fwidth(v_st);"
+ " fuzz = u_wscale + max(st_width.s, st_width.t);"
+ " }"
+ " gl_FragColor = color;"
+ " gl_FragColor = u_color * min(1.0, len / fuzz);"
+ "}";
final static String polygonVertexShader = ""
@@ -209,48 +117,6 @@ public final class Shaders {
+ " tex_c = tex_coord * div;"
+ "}";
// final static String textVertexShader = ""
// + "precision highp float; "
// + "attribute vec4 vertex;"
// + "attribute vec2 tex_coord;"
// + "uniform mat4 mvp;"
// + "uniform mat4 viewMatrix;"
// + "uniform float scale;"
// + "varying vec2 tex_c;"
// + "const vec2 div = vec2(1.0/4096.0,1.0/2048.0);"
// + "void main() {"
// + " vec4 pos;"
// + " if (mod(vertex.x, 2.0) == 0.0){"
// + " pos = mvp * vec4(vertex.xy + vertex.zw / scale, 0.0, 1.0);"
// + " } else {"
// + " vec4 dir = viewMatrix * vec4(vertex.zw / scale, 0.0, 1.0);"
// + " pos = mvp * vec4(vertex.xy + dir.xy, 0.0, 1.0);"
// + " }"
// + " pos.z = 0.0;"
// + " gl_Position = pos;"
// + " tex_c = tex_coord * div;"
// + "}";
// final static String textVertexShader = ""
// + "precision highp float; "
// + "attribute vec4 vertex;"
// + "attribute vec2 tex_coord;"
// + "uniform mat4 mvp;"
// + "uniform mat4 viewMatrix;"
// + "uniform float scale;"
// + "varying vec2 tex_c;"
// + "const vec2 div = vec2(1.0/4096.0,1.0/2048.0);"
// + "void main() {"
// + " if (mod(vertex.x, 2.0) == 0.0){"
// +
// " gl_Position = mvp * vec4(vertex.xy + vertex.zw / scale, 0.0, 1.0);"
// + " } else {"
// + " vec4 dir = viewMatrix * vec4(vertex.zw / scale, 0.0, 1.0);"
// + " gl_Position = mvp * vec4(vertex.xy + dir.xy, 0.0, 1.0);"
// + " }"
// + " tex_c = tex_coord * div;"
// + "}";
final static String textFragmentShader = ""
+ "precision highp float;"
+ "uniform sampler2D tex;"
@@ -280,24 +146,28 @@ public final class Shaders {
// + " v_st = u_mode[1] * vec2(-a_st2.s , a_st2.t);"
// + "}";
// final static String lineVertexShader = ""
// + "precision mediump float;"
// + "uniform mat4 mvp;"
// + "attribute vec4 a_position;"
// + "attribute vec2 a_st;"
// + "varying vec2 v_st;"
// + "uniform float u_width;"
// + "const float dscale = 8.0/1000.0;"
// + "void main() {"
// + " vec2 dir = dscale * u_width * a_position.zw;"
// + " gl_Position = mvp * vec4(a_position.xy + dir, 0.0,1.0);"
// + " v_st = u_width * a_st;"
// + "}";
// final static String lineFragmentShader = ""
// + "#extension GL_OES_standard_derivatives : enable\n"
// + "precision mediump float;"
// + "uniform vec2 u_mode;"
// + "uniform float u_wscale;"
// + "uniform float u_width;"
// + "uniform int u_mode;"
// + "uniform vec4 u_color;"
// + "varying vec2 v_st;"
// + "const float zero = 0.0;"
// + "void main() {"
// + " vec4 color = u_color;"
// + " float width = u_mode[1];"
// + " float len;"
// + " if (v_st.t == zero)"
// + " len = abs(v_st.s);"
// + " else "
// + " len = length(v_st);"
// + " vec2 st_width = fwidth(v_st);"
// + " float fuzz = max(st_width.s, st_width.t);"
// + " color.a *= smoothstep(-pixel, fuzz*pixel, width - (len * width));"
// + " gl_FragColor = color;"
// + " gl_FragColor = u_color * 0.5;"
// + "}";
}

View File

@@ -1,458 +0,0 @@
/*
* Copyright 2012 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
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* 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/>.
*/
package org.oscim.renderer;
//import java.nio.ByteBuffer;
//import java.nio.ByteOrder;
//import java.nio.ShortBuffer;
//
//import org.oscim.renderer.layer.TextItem;
//import org.oscim.utils.GlUtils;
//
//import android.graphics.Bitmap;
//import android.graphics.Canvas;
//import android.graphics.Color;
//import android.graphics.Paint;
//import android.opengl.GLES20;
//import android.opengl.GLUtils;
//import android.util.FloatMath;
//import android.util.Log;
//
//public class TextRenderer {
// private static String TAG = "TextRenderer";
//
// private final static int TEXTURE_WIDTH = 256;
// private final static int TEXTURE_HEIGHT = 256;
// private final static float SCALE = 8.0f;
// private final static int LBIT_MASK = 0xfffffffe;
// // private final static int L2BIT_MASK = 0xfffffffc;
//
// final static int INDICES_PER_SPRITE = 6;
// final static int VERTICES_PER_SPRITE = 4;
// final static int SHORTS_PER_VERTICE = 6;
// final static int MAX_LABELS = 35;
//
// private static Bitmap mBitmap;
// private static Canvas mCanvas;
// private static int mFontPadX = 1;
// private static int mFontPadY = 1;
// private static int mBitmapFormat;
// private static int mBitmapType;
// private static ShortBuffer mShortBuffer;
// private static TextTexture[] mTextures;
//
// private static int mIndicesVBO;
// private static int mVerticesVBO;
//
// private static int mTextProgram;
// private static int hTextMVMatrix;
// private static int hTextProjectionMatrix;
// private static int hTextVertex;
// private static int hTextScale;
// private static int hTextScreenScale;
// private static int hTextTextureCoord;
//
// private static Paint mPaint = new Paint(Color.BLACK);
//
// private static boolean debug = false;
// private static short[] debugVertices = {
//
// 0, 0,
// 0, TEXTURE_HEIGHT * 4,
//
// 0, TEXTURE_HEIGHT - 1,
// 0, 0,
//
// TEXTURE_WIDTH - 1, 0,
// TEXTURE_WIDTH * 4, TEXTURE_HEIGHT * 4,
//
// TEXTURE_WIDTH - 1, TEXTURE_HEIGHT - 1,
// TEXTURE_WIDTH * 4, 0,
//
// };
//
// static void init() {
// mTextProgram = GlUtils.createProgram(Shaders.textVertexShader,
// Shaders.textFragmentShader);
//
// hTextMVMatrix = GLES20.glGetUniformLocation(mTextProgram, "u_mv");
// hTextProjectionMatrix = GLES20.glGetUniformLocation(mTextProgram, "u_proj");
// hTextScale = GLES20.glGetUniformLocation(mTextProgram, "u_scale");
// hTextScreenScale = GLES20.glGetUniformLocation(mTextProgram, "u_swidth");
// hTextVertex = GLES20.glGetAttribLocation(mTextProgram, "vertex");
// hTextTextureCoord = GLES20.glGetAttribLocation(mTextProgram, "tex_coord");
//
// }
//
// static boolean setup(int numTextures) {
// int bufferSize = numTextures
// * MAX_LABELS * VERTICES_PER_SPRITE
// * SHORTS_PER_VERTICE * (Short.SIZE / 8);
//
// // if (mBitmap == null) {
// mBitmap = Bitmap.createBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT,
// Bitmap.Config.ARGB_8888);
// mCanvas = new Canvas(mBitmap);
//
// mBitmapFormat = GLUtils.getInternalFormat(mBitmap);
// mBitmapType = GLUtils.getType(mBitmap);
//
// ByteBuffer buf = ByteBuffer.allocateDirect(bufferSize)
// .order(ByteOrder.nativeOrder());
//
// mShortBuffer = buf.asShortBuffer();
// // }
//
// int[] textureIds = new int[numTextures];
// TextTexture[] textures = new TextTexture[numTextures];
// GLES20.glGenTextures(numTextures, textureIds, 0);
//
// for (int i = 0; i < numTextures; i++) {
// // setup filters for texture
// GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureIds[i]);
//
// GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MIN_FILTER,
// GLES20.GL_LINEAR);
// GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_MAG_FILTER,
// GLES20.GL_LINEAR);
// GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_S,
// GLES20.GL_CLAMP_TO_EDGE); // Set U Wrapping
// GLES20.glTexParameterf(GLES20.GL_TEXTURE_2D, GLES20.GL_TEXTURE_WRAP_T,
// GLES20.GL_CLAMP_TO_EDGE); // Set V Wrapping
//
// // load the generated bitmap onto the texture
// GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, mBitmapFormat, mBitmap,
// mBitmapType, 0);
//
// textures[i] = new TextTexture(textureIds[i]);
// }
//
// GlUtils.checkGlError("init textures");
//
// mTextures = textures;
//
// // Setup triangle indices
// short[] indices = new short[MAX_LABELS * INDICES_PER_SPRITE];
// int len = indices.length;
// short j = 0;
// for (int i = 0; i < len; i += INDICES_PER_SPRITE, j += VERTICES_PER_SPRITE) {
// indices[i + 0] = (short) (j + 0);
// indices[i + 1] = (short) (j + 1);
// indices[i + 2] = (short) (j + 2);
// indices[i + 3] = (short) (j + 2);
// indices[i + 4] = (short) (j + 3);
// indices[i + 5] = (short) (j + 0);
// }
//
// mShortBuffer.clear();
// mShortBuffer.put(indices, 0, len);
// mShortBuffer.flip();
//
// int[] mVboIds = new int[2];
// GLES20.glGenBuffers(2, mVboIds, 0);
// mIndicesVBO = mVboIds[0];
// mVerticesVBO = mVboIds[1];
//
// GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mIndicesVBO);
// GLES20.glBufferData(GLES20.GL_ELEMENT_ARRAY_BUFFER, len * (Short.SIZE / 8),
// mShortBuffer, GLES20.GL_STATIC_DRAW);
// GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
//
// mShortBuffer.clear();
// GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVerticesVBO);
// GLES20.glBufferData(GLES20.GL_ARRAY_BUFFER, bufferSize,
// mShortBuffer, GLES20.GL_DYNAMIC_DRAW);
// GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
//
// return true;
// }
//
// static boolean drawToTexture(MapTile tile) {
// TextTexture tex = null;
//
// if (tile.labels == null)
// return false;
//
// for (int i = 0; i < mTextures.length; i++) {
// tex = mTextures[i];
// if (tex.tile == null)
// break;
//
// if (!tex.tile.isLocked())
// break;
//
// tex = null;
// }
//
// if (tex == null) {
// for (int i = 0; i < mTextures.length; i++) {
// tex = mTextures[i];
// if (!tex.tile.isVisible)
// break;
//
// tex = null;
// }
// }
//
// if (tex == null) {
// Log.d(TAG, "no textures left");
// return false;
// }
// if (tex.tile != null)
// tex.tile.texture = null;
//
// mBitmap.eraseColor(Color.TRANSPARENT);
//
// int pos = 0;
// short[] buf = tex.vertices;
//
// float y = 0;
// float x = mFontPadX;
// float width, height;
//
// int max = MAX_LABELS;
//
// if (debug) {
// mCanvas.drawLine(debugVertices[0], debugVertices[1], debugVertices[4],
// debugVertices[5], mPaint);
// mCanvas.drawLine(debugVertices[0], debugVertices[1], debugVertices[8],
// debugVertices[9], mPaint);
//
// mCanvas.drawLine(debugVertices[12], debugVertices[13], debugVertices[4],
// debugVertices[5], mPaint);
// mCanvas.drawLine(debugVertices[12], debugVertices[13], debugVertices[8],
// debugVertices[9], mPaint);
// }
//
// int advanceY = 0;
//
// TextItem t = tile.labels;
// float yy;
//
// for (int i = 0; t != null && i < max; t = t.next, i++) {
// if (t.text.caption)
// continue;
//
// height = (int) (t.text.fontHeight) + 2 * mFontPadY;
// width = t.width + 2 * mFontPadX;
//
// if (height > advanceY)
// advanceY = (int) height;
//
// if (x + width > TEXTURE_WIDTH) {
// x = mFontPadX;
// y += advanceY;
// advanceY = (int) height;
// }
//
// yy = y + (height - 1) - t.text.fontDescent - mFontPadY;
// if (yy > TEXTURE_HEIGHT) {
// Log.d(TAG, "reached max labels");
// break;
// // continue;
// }
//
// if (t.text.stroke != null)
// mCanvas.drawText(t.string, x + t.width / 2, yy, t.text.stroke);
//
// mCanvas.drawText(t.string, x + t.width / 2, yy, t.text.paint);
//
// if (width > TEXTURE_WIDTH)
// width = TEXTURE_WIDTH;
//
// float hw = width / 2.0f;
// float hh = height / 2.0f;
// short x1, x2, x3, x4, y1, y2, y3, y4;
//
// if (t.text.caption) {
// x1 = x3 = (short) (SCALE * (-hw));
// y1 = y3 = (short) (SCALE * (hh));
// x2 = x4 = (short) (SCALE * (hw));
// y2 = y4 = (short) (SCALE * (-hh));
// } else {
// float vx = t.x1 - t.x2;
// float vy = t.y1 - t.y2;
// float a = FloatMath.sqrt(vx * vx + vy * vy);
// vx = vx / a;
// vy = vy / a;
//
// float ux = -vy;
// float uy = vx;
//
// // int dx = (int) (vx * SCALE) & L2BIT_MASK;
// // int dy = (int) (vy * SCALE) & L2BIT_MASK;
// //
// // x1 = (short) dx;
// // y1 = (short) dy;
// //
// // x2 = (short) (dx | 1);
// // y3 = (short) (dy | 1);
// //
// // x4 = (short) (dx | 3);
// // y4 = (short) (dy | 3);
// //
// // x3 = (short) (dx | 2);
// // y2 = (short) (dy | 2);
//
// x1 = (short) (SCALE * (vx * hw - ux * hh));
// y1 = (short) (SCALE * (vy * hw - uy * hh));
// x2 = (short) (SCALE * (-vx * hw - ux * hh));
// y3 = (short) (SCALE * (-vy * hw - uy * hh));
// x4 = (short) (SCALE * (-vx * hw + ux * hh));
// y4 = (short) (SCALE * (-vy * hw + uy * hh));
// x3 = (short) (SCALE * (vx * hw + ux * hh));
// y2 = (short) (SCALE * (vy * hw + uy * hh));
//
// }
// short u1 = (short) (SCALE * x);
// short v1 = (short) (SCALE * y);
// short u2 = (short) (SCALE * (x + width));
// short v2 = (short) (SCALE * (y + height));
//
// // pack caption/way-text info in lowest bit
// int tmp = (int) (SCALE * t.x) & LBIT_MASK;
// short tx = (short) (tmp | (t.text.caption ? 1 : 0));
//
// short ty = (short) (SCALE * t.y);
//
// // top-left
// buf[pos++] = tx;
// buf[pos++] = ty;
// buf[pos++] = x1;
// buf[pos++] = y1;
// buf[pos++] = u1;
// buf[pos++] = v2;
//
// // top-right
// buf[pos++] = tx;
// buf[pos++] = ty;
// buf[pos++] = x2;
// buf[pos++] = y3;
// buf[pos++] = u2;
// buf[pos++] = v2;
//
// // bot-right
// buf[pos++] = tx;
// buf[pos++] = ty;
// buf[pos++] = x4;
// buf[pos++] = y4;
// buf[pos++] = u2;
// buf[pos++] = v1;
//
// // bot-left
// buf[pos++] = tx;
// buf[pos++] = ty;
// buf[pos++] = x3;
// buf[pos++] = y2;
// buf[pos++] = u1;
// buf[pos++] = v1;
//
// x += width;
//
// if (y > TEXTURE_HEIGHT) {
// Log.d(TAG, "reached max labels: texture is full");
// break;
// }
// }
//
// tex.length = pos;
// tile.texture = tex;
// tex.tile = tile;
//
// GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tex.id);
// GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap,
// mBitmapFormat, mBitmapType);
//
// // FIXME shouldnt be needed here, still looking for sometimes corrupted
// // labels..
// GLES20.glFlush();
//
// return true;
// }
//
// static void compileTextures() {
// int offset = 0;
// TextTexture tex;
//
// GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVerticesVBO);
//
// mShortBuffer.clear();
//
// for (int i = 0; i < mTextures.length; i++) {
// tex = mTextures[i];
// if (tex.tile == null) // || !tex.tile.isLocked)
// continue;
//
// mShortBuffer.put(tex.vertices, 0, tex.length);
// tex.offset = offset;
// offset += tex.length;
// }
//
// mShortBuffer.flip();
//
// GLES20.glBufferSubData(GLES20.GL_ARRAY_BUFFER, 0, offset * (Short.SIZE / 8),
// mShortBuffer);
// }
//
// static void beginDraw(float scale, float[] projection) {
// GLES20.glUseProgram(mTextProgram);
//
// // GLES20.glEnableVertexAttribArray(hTextTextureCoord);
// // GLES20.glEnableVertexAttribArray(hTextVertex);
//
// int va = hTextTextureCoord;
// if (!GLRenderer.vertexArray[va]) {
// GLES20.glEnableVertexAttribArray(va);
// GLRenderer.vertexArray[va] = true;
// }
//
// va = hTextVertex;
// if (!GLRenderer.vertexArray[va]) {
// GLES20.glEnableVertexAttribArray(va);
// GLRenderer.vertexArray[va] = true;
// }
//
// GLES20.glUniform1f(hTextScale, scale);
// GLES20.glUniform1f(hTextScreenScale, 1f / GLRenderer.mWidth);
// GLES20.glUniformMatrix4fv(hTextProjectionMatrix, 1, false, projection, 0);
//
// GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, mIndicesVBO);
// GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, mVerticesVBO);
// }
//
// static void endDraw() {
// GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, 0);
//
// // GLES20.glDisableVertexAttribArray(hTextTextureCoord);
// // GLES20.glDisableVertexAttribArray(hTextVertex);
// }
//
// static void drawTile(MapTile tile, float[] matrix) {
//
// GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, tile.texture.id);
//
// GLES20.glUniformMatrix4fv(hTextMVMatrix, 1, false, matrix, 0);
//
// GLES20.glVertexAttribPointer(hTextVertex, 4,
// GLES20.GL_SHORT, false, 12, tile.texture.offset * (Short.SIZE / 8));
//
// GLES20.glVertexAttribPointer(hTextTextureCoord, 2,
// GLES20.GL_SHORT, false, 12, tile.texture.offset * (Short.SIZE / 8)
// + 8);
//
// GLES20.glDrawElements(GLES20.GL_TRIANGLES, (tile.texture.length / 24) *
// INDICES_PER_SPRITE, GLES20.GL_UNSIGNED_SHORT, 0);
// }
// }

View File

@@ -1,33 +0,0 @@
/*
* Copyright 2012 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
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* 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/>.
*/
package org.oscim.renderer;
//public class TextTexture {
//
// final short[] vertices;
// final int id;
// int length;
// int offset;
// MapTile tile;
//
// TextTexture(int textureID) {
// vertices = new short[TextRenderer.MAX_LABELS *
// TextRenderer.VERTICES_PER_SPRITE *
// TextRenderer.SHORTS_PER_VERTICE];
//
// id = textureID;
// }
//
// }