share GL reference in RenderElement
This commit is contained in:
parent
47b8a379a4
commit
39c0fcafea
@ -27,6 +27,7 @@ import org.oscim.renderer.MapRenderer.Matrices;
|
|||||||
* Renderer for a single bitmap, width and height must be power of 2.
|
* Renderer for a single bitmap, width and height must be power of 2.
|
||||||
*/
|
*/
|
||||||
public class BitmapLayer extends TextureLayer {
|
public class BitmapLayer extends TextureLayer {
|
||||||
|
|
||||||
// private final static String TAG = BitmapLayer.class.getName();
|
// private final static String TAG = BitmapLayer.class.getName();
|
||||||
private Bitmap mBitmap;
|
private Bitmap mBitmap;
|
||||||
private final boolean mReuseBitmap;
|
private final boolean mReuseBitmap;
|
||||||
@ -37,7 +38,8 @@ public class BitmapLayer extends TextureLayer {
|
|||||||
* it is compiled to texture.
|
* it is compiled to texture.
|
||||||
*/
|
*/
|
||||||
public BitmapLayer(boolean reuseBitmap) {
|
public BitmapLayer(boolean reuseBitmap) {
|
||||||
type = RenderElement.BITMAP;
|
super(RenderElement.BITMAP);
|
||||||
|
|
||||||
mReuseBitmap = reuseBitmap;
|
mReuseBitmap = reuseBitmap;
|
||||||
mVertices = new short[24];
|
mVertices = new short[24];
|
||||||
|
|
||||||
@ -151,7 +153,6 @@ public class BitmapLayer extends TextureLayer {
|
|||||||
public static final class Renderer {
|
public static final class Renderer {
|
||||||
|
|
||||||
//private final static String TAG = BitmapRenderer.class.getName();
|
//private final static String TAG = BitmapRenderer.class.getName();
|
||||||
private static GL20 GL;
|
|
||||||
|
|
||||||
public final static boolean debug = true;
|
public final static boolean debug = true;
|
||||||
|
|
||||||
@ -169,9 +170,7 @@ public class BitmapLayer extends TextureLayer {
|
|||||||
final static int VERTICES_PER_SPRITE = 4;
|
final static int VERTICES_PER_SPRITE = 4;
|
||||||
final static int SHORTS_PER_VERTICE = 6;
|
final static int SHORTS_PER_VERTICE = 6;
|
||||||
|
|
||||||
static void init(GL20 gl) {
|
static void init() {
|
||||||
GL = gl;
|
|
||||||
|
|
||||||
mTextureProgram = GLUtils.createProgram(textVertexShader,
|
mTextureProgram = GLUtils.createProgram(textVertexShader,
|
||||||
textFragmentShader);
|
textFragmentShader);
|
||||||
|
|
||||||
|
|||||||
@ -25,11 +25,13 @@ public class ElementLayers {
|
|||||||
private final static String TAG = ElementLayers.class.getName();
|
private final static String TAG = ElementLayers.class.getName();
|
||||||
|
|
||||||
public static void initRenderer(GL20 gl) {
|
public static void initRenderer(GL20 gl) {
|
||||||
LineLayer.Renderer.init(gl);
|
RenderElement.GL = gl;
|
||||||
LineTexLayer.Renderer.init(gl);
|
|
||||||
PolygonLayer.Renderer.init(gl);
|
LineLayer.Renderer.init();
|
||||||
TextureLayer.Renderer.init(gl);
|
LineTexLayer.Renderer.init();
|
||||||
BitmapLayer.Renderer.init(gl);
|
PolygonLayer.Renderer.init();
|
||||||
|
TextureLayer.Renderer.init();
|
||||||
|
BitmapLayer.Renderer.init();
|
||||||
TextureItem.init(gl, 0);
|
TextureItem.init(gl, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public class ExtrusionLayer extends RenderElement {
|
|||||||
private final float mGroundResolution;
|
private final float mGroundResolution;
|
||||||
|
|
||||||
public ExtrusionLayer(int level, float groundResolution) {
|
public ExtrusionLayer(int level, float groundResolution) {
|
||||||
this.type = RenderElement.EXTRUSION;
|
super(RenderElement.EXTRUSION);
|
||||||
this.level = level;
|
this.level = level;
|
||||||
|
|
||||||
mGroundResolution = groundResolution;
|
mGroundResolution = groundResolution;
|
||||||
|
|||||||
@ -50,8 +50,8 @@ public final class LineLayer extends RenderElement {
|
|||||||
public boolean roundCap;
|
public boolean roundCap;
|
||||||
|
|
||||||
LineLayer(int layer) {
|
LineLayer(int layer) {
|
||||||
|
super(RenderElement.LINE);
|
||||||
this.level = layer;
|
this.level = layer;
|
||||||
this.type = RenderElement.LINE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addOutline(LineLayer link) {
|
public void addOutline(LineLayer link) {
|
||||||
@ -580,8 +580,6 @@ public final class LineLayer extends RenderElement {
|
|||||||
|
|
||||||
public static final class Renderer {
|
public static final class Renderer {
|
||||||
|
|
||||||
private static GL20 GL;
|
|
||||||
|
|
||||||
private static final int LINE_VERTICES_DATA_POS_OFFSET = 0;
|
private static final int LINE_VERTICES_DATA_POS_OFFSET = 0;
|
||||||
|
|
||||||
// factor to normalize extrusion vector and scale to coord scale
|
// factor to normalize extrusion vector and scale to coord scale
|
||||||
@ -598,8 +596,7 @@ public final class LineLayer extends RenderElement {
|
|||||||
private static int[] hLineMode = new int[2];
|
private static int[] hLineMode = new int[2];
|
||||||
public static int mTexID;
|
public static int mTexID;
|
||||||
|
|
||||||
static boolean init(GL20 gl) {
|
static boolean init() {
|
||||||
GL = gl;
|
|
||||||
|
|
||||||
lineProgram[0] = GLUtils.createProgram(lineVertexShader,
|
lineProgram[0] = GLUtils.createProgram(lineVertexShader,
|
||||||
lineFragmentShader);
|
lineFragmentShader);
|
||||||
|
|||||||
@ -93,8 +93,9 @@ public final class LineTexLayer extends RenderElement {
|
|||||||
private boolean evenSegment;
|
private boolean evenSegment;
|
||||||
|
|
||||||
LineTexLayer(int layer) {
|
LineTexLayer(int layer) {
|
||||||
|
super(RenderElement.TEXLINE);
|
||||||
|
|
||||||
this.level = layer;
|
this.level = layer;
|
||||||
this.type = RenderElement.TEXLINE;
|
|
||||||
this.evenSegment = true;
|
this.evenSegment = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,8 +251,6 @@ public final class LineTexLayer extends RenderElement {
|
|||||||
|
|
||||||
public final static class Renderer {
|
public final static class Renderer {
|
||||||
|
|
||||||
private static GL20 GL;
|
|
||||||
|
|
||||||
// factor to normalize extrusion vector and scale to coord scale
|
// factor to normalize extrusion vector and scale to coord scale
|
||||||
private final static float COORD_SCALE_BY_DIR_SCALE =
|
private final static float COORD_SCALE_BY_DIR_SCALE =
|
||||||
MapRenderer.COORD_SCALE
|
MapRenderer.COORD_SCALE
|
||||||
@ -273,8 +272,7 @@ public final class LineTexLayer extends RenderElement {
|
|||||||
|
|
||||||
private static int mVertexFlipID;
|
private static int mVertexFlipID;
|
||||||
|
|
||||||
public static void init(GL20 gl) {
|
public static void init() {
|
||||||
GL = gl;
|
|
||||||
|
|
||||||
shader = GLUtils.createProgram(vertexShader, fragmentShader);
|
shader = GLUtils.createProgram(vertexShader, fragmentShader);
|
||||||
if (shader == 0) {
|
if (shader == 0) {
|
||||||
|
|||||||
@ -46,8 +46,9 @@ public final class PolygonLayer extends RenderElement {
|
|||||||
public Area area;
|
public Area area;
|
||||||
|
|
||||||
PolygonLayer(int layer) {
|
PolygonLayer(int layer) {
|
||||||
this.level = layer;
|
super(RenderElement.POLYGON);
|
||||||
this.type = RenderElement.POLYGON;
|
|
||||||
|
level = layer;
|
||||||
curItem = VertexItem.pool.get();
|
curItem = VertexItem.pool.get();
|
||||||
vertexItems = curItem;
|
vertexItems = curItem;
|
||||||
}
|
}
|
||||||
@ -123,7 +124,7 @@ public final class PolygonLayer extends RenderElement {
|
|||||||
|
|
||||||
public static final class Renderer {
|
public static final class Renderer {
|
||||||
|
|
||||||
private static GL20 GL;
|
//private static GL20 GL;
|
||||||
|
|
||||||
private static final int POLYGON_VERTICES_DATA_POS_OFFSET = 0;
|
private static final int POLYGON_VERTICES_DATA_POS_OFFSET = 0;
|
||||||
private static final int STENCIL_BITS = 8;
|
private static final int STENCIL_BITS = 8;
|
||||||
@ -144,8 +145,7 @@ public final class PolygonLayer extends RenderElement {
|
|||||||
private static int[] hPolygonColor = new int[numShaders];
|
private static int[] hPolygonColor = new int[numShaders];
|
||||||
private static int[] hPolygonScale = new int[numShaders];
|
private static int[] hPolygonScale = new int[numShaders];
|
||||||
|
|
||||||
static boolean init(GL20 gl) {
|
static boolean init() {
|
||||||
GL = gl;
|
|
||||||
|
|
||||||
for (int i = 0; i < numShaders; i++) {
|
for (int i = 0; i < numShaders; i++) {
|
||||||
|
|
||||||
|
|||||||
@ -16,9 +16,12 @@ package org.oscim.renderer.elements;
|
|||||||
|
|
||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
|
import org.oscim.backend.GL20;
|
||||||
import org.oscim.utils.pool.Inlist;
|
import org.oscim.utils.pool.Inlist;
|
||||||
|
|
||||||
public abstract class RenderElement extends Inlist<RenderElement> {
|
public abstract class RenderElement extends Inlist<RenderElement> {
|
||||||
|
protected static GL20 GL;
|
||||||
|
|
||||||
public final static byte LINE = 0;
|
public final static byte LINE = 0;
|
||||||
public final static byte POLYGON = 1;
|
public final static byte POLYGON = 1;
|
||||||
public final static byte TEXLINE = 2;
|
public final static byte TEXLINE = 2;
|
||||||
@ -26,7 +29,11 @@ public abstract class RenderElement extends Inlist<RenderElement> {
|
|||||||
public final static byte BITMAP = 4;
|
public final static byte BITMAP = 4;
|
||||||
public final static byte EXTRUSION = 5;
|
public final static byte EXTRUSION = 5;
|
||||||
|
|
||||||
public byte type = -1;
|
protected RenderElement(byte type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public final byte type;
|
||||||
|
|
||||||
// drawing order from bottom to top
|
// drawing order from bottom to top
|
||||||
int level;
|
int level;
|
||||||
|
|||||||
@ -38,7 +38,7 @@ public final class TextLayer extends TextureLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public TextLayer() {
|
public TextLayer() {
|
||||||
type = RenderElement.SYMBOL;
|
super(RenderElement.SYMBOL);
|
||||||
//mCanvas = Graphics.res.getCanvas();
|
//mCanvas = Graphics.res.getCanvas();
|
||||||
mCanvas = CanvasAdapter.g.getCanvas();
|
mCanvas = CanvasAdapter.g.getCanvas();
|
||||||
fixed = true;
|
fixed = true;
|
||||||
|
|||||||
@ -25,6 +25,11 @@ import org.oscim.renderer.MapRenderer;
|
|||||||
import org.oscim.renderer.MapRenderer.Matrices;
|
import org.oscim.renderer.MapRenderer.Matrices;
|
||||||
|
|
||||||
public abstract class TextureLayer extends RenderElement {
|
public abstract class TextureLayer extends RenderElement {
|
||||||
|
|
||||||
|
protected TextureLayer(byte type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
// holds textures and offset in vbo
|
// holds textures and offset in vbo
|
||||||
public TextureItem textures;
|
public TextureItem textures;
|
||||||
|
|
||||||
@ -87,8 +92,6 @@ public abstract class TextureLayer extends RenderElement {
|
|||||||
public static final class Renderer {
|
public static final class Renderer {
|
||||||
//private final static String TAG = TextureRenderer.class.getName();
|
//private final static String TAG = TextureRenderer.class.getName();
|
||||||
|
|
||||||
private static GL20 GL;
|
|
||||||
|
|
||||||
public final static boolean debug = false;
|
public final static boolean debug = false;
|
||||||
|
|
||||||
private static int mTextureProgram;
|
private static int mTextureProgram;
|
||||||
@ -104,8 +107,7 @@ public abstract class TextureLayer extends RenderElement {
|
|||||||
final static int VERTICES_PER_SPRITE = 4;
|
final static int VERTICES_PER_SPRITE = 4;
|
||||||
final static int SHORTS_PER_VERTICE = 6;
|
final static int SHORTS_PER_VERTICE = 6;
|
||||||
|
|
||||||
static void init(GL20 gl) {
|
static void init() {
|
||||||
GL = gl;
|
|
||||||
|
|
||||||
mTextureProgram = GLUtils.createProgram(textVertexShader,
|
mTextureProgram = GLUtils.createProgram(textVertexShader,
|
||||||
textFragmentShader);
|
textFragmentShader);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user