- use mediump shader for textures
- increase TextureItem width, so that 'USA' label is drawn completely on high dpi.. at least for now
This commit is contained in:
parent
47ad1d3617
commit
50b37d2342
@ -15,10 +15,14 @@
|
|||||||
|
|
||||||
package org.oscim.renderer;
|
package org.oscim.renderer;
|
||||||
|
|
||||||
|
import static org.oscim.renderer.GLRenderer.COORD_SCALE;
|
||||||
|
import static org.oscim.renderer.layer.TextureItem.TEXTURE_HEIGHT;
|
||||||
|
import static org.oscim.renderer.layer.TextureItem.TEXTURE_WIDTH;
|
||||||
|
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
import org.oscim.renderer.layer.Layer;
|
import org.oscim.renderer.layer.Layer;
|
||||||
import org.oscim.renderer.layer.TextureLayer;
|
|
||||||
import org.oscim.renderer.layer.TextureItem;
|
import org.oscim.renderer.layer.TextureItem;
|
||||||
|
import org.oscim.renderer.layer.TextureLayer;
|
||||||
import org.oscim.utils.GlUtils;
|
import org.oscim.utils.GlUtils;
|
||||||
|
|
||||||
import android.opengl.GLES20;
|
import android.opengl.GLES20;
|
||||||
@ -105,8 +109,12 @@ public final class TextureRenderer {
|
|||||||
return layer.next;
|
return layer.next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private final static double TEX_COORD_DIV_X = 1.0 / (TEXTURE_WIDTH * COORD_SCALE);
|
||||||
|
private final static double TEX_COORD_DIV_Y = 1.0 / (TEXTURE_HEIGHT * COORD_SCALE);
|
||||||
|
private final static double COORD_DIV = 1.0 / GLRenderer.COORD_SCALE;
|
||||||
|
|
||||||
private final static String textVertexShader = ""
|
private final static String textVertexShader = ""
|
||||||
+ "precision highp float; "
|
+ "precision mediump float; "
|
||||||
+ "attribute vec4 vertex;"
|
+ "attribute vec4 vertex;"
|
||||||
+ "attribute vec2 tex_coord;"
|
+ "attribute vec2 tex_coord;"
|
||||||
+ "uniform mat4 u_mv;"
|
+ "uniform mat4 u_mv;"
|
||||||
@ -114,8 +122,8 @@ public final class TextureRenderer {
|
|||||||
+ "uniform float u_scale;"
|
+ "uniform float u_scale;"
|
||||||
+ "uniform float u_swidth;"
|
+ "uniform float u_swidth;"
|
||||||
+ "varying vec2 tex_c;"
|
+ "varying vec2 tex_c;"
|
||||||
+ "const vec2 div = vec2(1.0/2048.0,1.0/2048.0);"
|
+ "const vec2 div = vec2(" + TEX_COORD_DIV_X + "," + TEX_COORD_DIV_Y + ");"
|
||||||
+ "const float coord_scale = 0.125;"
|
+ "const float coord_scale = " + COORD_DIV + ";"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
+ " vec4 pos;"
|
+ " vec4 pos;"
|
||||||
+ " vec2 dir = vertex.zw;"
|
+ " vec2 dir = vertex.zw;"
|
||||||
@ -130,7 +138,7 @@ public final class TextureRenderer {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
private final static String textFragmentShader = ""
|
private final static String textFragmentShader = ""
|
||||||
+ "precision highp float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform sampler2D tex;"
|
+ "uniform sampler2D tex;"
|
||||||
+ "varying vec2 tex_c;"
|
+ "varying vec2 tex_c;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
|
|||||||
@ -14,17 +14,17 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.renderer.layer;
|
package org.oscim.renderer.layer;
|
||||||
|
|
||||||
|
import static org.oscim.renderer.GLRenderer.COORD_SCALE;
|
||||||
|
import static org.oscim.renderer.layer.TextureItem.TEXTURE_HEIGHT;
|
||||||
|
import static org.oscim.renderer.layer.TextureItem.TEXTURE_WIDTH;
|
||||||
|
|
||||||
import org.oscim.renderer.TextureRenderer;
|
import org.oscim.renderer.TextureRenderer;
|
||||||
|
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
|
|
||||||
public final class TextLayer extends TextureLayer {
|
public final class TextLayer extends TextureLayer {
|
||||||
|
|
||||||
//private static String TAG = TextureLayer.class.getName();
|
//private static String TAG = TextureLayer.class.getName();
|
||||||
|
|
||||||
private final static int TEXTURE_WIDTH = TextureItem.TEXTURE_WIDTH;
|
|
||||||
private final static int TEXTURE_HEIGHT = TextureItem.TEXTURE_HEIGHT;
|
|
||||||
private final static float SCALE = 8.0f;
|
|
||||||
private final static int LBIT_MASK = 0xfffffffe;
|
private final static int LBIT_MASK = 0xfffffffe;
|
||||||
|
|
||||||
private static int mFontPadX = 1;
|
private static int mFontPadX = 1;
|
||||||
@ -151,10 +151,10 @@ public final class TextLayer extends TextureLayer {
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
// texture coordinates
|
// texture coordinates
|
||||||
short u1 = (short) (SCALE * x);
|
short u1 = (short) (COORD_SCALE * x);
|
||||||
short v1 = (short) (SCALE * y);
|
short v1 = (short) (COORD_SCALE * y);
|
||||||
short u2 = (short) (SCALE * (x + width));
|
short u2 = (short) (COORD_SCALE * (x + width));
|
||||||
short v2 = (short) (SCALE * (y + height));
|
short v2 = (short) (COORD_SCALE * (y + height));
|
||||||
|
|
||||||
while (it != null) {
|
while (it != null) {
|
||||||
|
|
||||||
@ -162,10 +162,10 @@ public final class TextLayer extends TextureLayer {
|
|||||||
|
|
||||||
if (it.text.caption) {
|
if (it.text.caption) {
|
||||||
//if (it.origin == 0) {
|
//if (it.origin == 0) {
|
||||||
x1 = x3 = (short) (SCALE * -hw);
|
x1 = x3 = (short) (COORD_SCALE * -hw);
|
||||||
x2 = x4 = (short) (SCALE * hw);
|
x2 = x4 = (short) (COORD_SCALE * hw);
|
||||||
y1 = y2 = (short) (SCALE * hh);
|
y1 = y2 = (short) (COORD_SCALE * hh);
|
||||||
y3 = y4 = (short) (SCALE * -hh);
|
y3 = y4 = (short) (COORD_SCALE * -hh);
|
||||||
//} else {
|
//} else {
|
||||||
// x1 = x3 = (short) (SCALE * 0);
|
// x1 = x3 = (short) (SCALE * 0);
|
||||||
// x2 = x4 = (short) (SCALE * width);
|
// x2 = x4 = (short) (SCALE * width);
|
||||||
@ -189,23 +189,23 @@ public final class TextLayer extends TextureLayer {
|
|||||||
vy *= hw;
|
vy *= hw;
|
||||||
|
|
||||||
// top-left
|
// top-left
|
||||||
x1 = (short) (SCALE * (vx - ux));
|
x1 = (short) (COORD_SCALE * (vx - ux));
|
||||||
y1 = (short) (SCALE * (vy - uy));
|
y1 = (short) (COORD_SCALE * (vy - uy));
|
||||||
// top-right
|
// top-right
|
||||||
x2 = (short) (SCALE * (-vx - ux));
|
x2 = (short) (COORD_SCALE * (-vx - ux));
|
||||||
y2 = (short) (SCALE * (-vy - uy));
|
y2 = (short) (COORD_SCALE * (-vy - uy));
|
||||||
// bot-right
|
// bot-right
|
||||||
x4 = (short) (SCALE * (-vx + ux2));
|
x4 = (short) (COORD_SCALE * (-vx + ux2));
|
||||||
y4 = (short) (SCALE * (-vy + uy2));
|
y4 = (short) (COORD_SCALE * (-vy + uy2));
|
||||||
// bot-left
|
// bot-left
|
||||||
x3 = (short) (SCALE * (vx + ux2));
|
x3 = (short) (COORD_SCALE * (vx + ux2));
|
||||||
y3 = (short) (SCALE * (vy + uy2));
|
y3 = (short) (COORD_SCALE * (vy + uy2));
|
||||||
}
|
}
|
||||||
|
|
||||||
// add vertices
|
// add vertices
|
||||||
int tmp = (int) (SCALE * it.x) & LBIT_MASK;
|
int tmp = (int) (COORD_SCALE * it.x) & LBIT_MASK;
|
||||||
short tx = (short) (tmp | (it.text.caption ? 1 : 0));
|
short tx = (short) (tmp | (it.text.caption ? 1 : 0));
|
||||||
short ty = (short) (SCALE * it.y);
|
short ty = (short) (COORD_SCALE * it.y);
|
||||||
|
|
||||||
if (pos == VertexItem.SIZE) {
|
if (pos == VertexItem.SIZE) {
|
||||||
vi.used = VertexItem.SIZE;
|
vi.used = VertexItem.SIZE;
|
||||||
|
|||||||
@ -90,7 +90,7 @@ public class TextureItem extends Inlist<TextureItem> {
|
|||||||
|
|
||||||
private static ArrayList<Bitmap> mBitmaps;
|
private static ArrayList<Bitmap> mBitmaps;
|
||||||
|
|
||||||
public final static int TEXTURE_WIDTH = 256;
|
public final static int TEXTURE_WIDTH = 512;
|
||||||
public final static int TEXTURE_HEIGHT = 256;
|
public final static int TEXTURE_HEIGHT = 256;
|
||||||
|
|
||||||
private static int mBitmapFormat;
|
private static int mBitmapFormat;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user