Merge pull request #540 from Gustl22/short_bucket
Buckets: assign short qualifier
This commit is contained in:
commit
b4c8305f0d
@ -122,7 +122,7 @@ public class BitmapBucket extends TextureBucket {
|
|||||||
buf[pos++] = texMax;
|
buf[pos++] = texMax;
|
||||||
buf[pos++] = texMax;
|
buf[pos++] = texMax;
|
||||||
|
|
||||||
this.vertexOffset = vboData.position() * 2;
|
this.vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||||
vboData.put(buf);
|
vboData.put(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +606,7 @@ public class ExtrusionBucket extends RenderBucket {
|
|||||||
iOffset += idx[i];
|
iOffset += idx[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
vertexOffset = vboData.position() * 2;
|
vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||||
vertexItems.compile(vboData);
|
vertexItems.compile(vboData);
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
|
@ -35,8 +35,8 @@ import static org.oscim.renderer.MapRenderer.COORD_SCALE;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Note:
|
* Note:
|
||||||
* Coordinates must be in range +/- (Short.MAX_VALUE / COORD_SCALE) and the maximum
|
* Coordinates must be in range +/- (Short.MAX_VALUE / COORD_SCALE) if using GL.SHORT.
|
||||||
* resolution for coordinates is 0.25 as points will be converted
|
* The maximum resolution for coordinates is 0.25 as points will be converted
|
||||||
* to fixed point values.
|
* to fixed point values.
|
||||||
*/
|
*/
|
||||||
public class LineBucket extends RenderBucket {
|
public class LineBucket extends RenderBucket {
|
||||||
@ -360,7 +360,7 @@ public class LineBucket extends RenderBucket {
|
|||||||
vNextX = nextX - curX;
|
vNextX = nextX - curX;
|
||||||
vNextY = nextY - curY;
|
vNextY = nextY - curY;
|
||||||
a = Math.sqrt(vNextX * vNextX + vNextY * vNextY);
|
a = Math.sqrt(vNextX * vNextX + vNextY * vNextY);
|
||||||
/* skip too short segmets */
|
/* skip two vertex segments */
|
||||||
if (a < mMinDist) {
|
if (a < mMinDist) {
|
||||||
numVertices -= 2;
|
numVertices -= 2;
|
||||||
continue;
|
continue;
|
||||||
|
@ -68,11 +68,11 @@ import static org.oscim.renderer.MapRenderer.bindQuadIndicesVBO;
|
|||||||
* flip 0 1 0 1 0 1 0 1
|
* flip 0 1 0 1 0 1 0 1
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
* <p/>
|
||||||
* Vertex layout:
|
* Vertex layout (here: 1 unit == 1 short):
|
||||||
* [2 short] position,
|
* [2 unit] position,
|
||||||
* [2 short] extrusion,
|
* [2 unit] extrusion,
|
||||||
* [1 short] line length
|
* [1 unit] line length
|
||||||
* [1 short] unused
|
* [1 unit] unused
|
||||||
* <p/>
|
* <p/>
|
||||||
* indices, for two blocks:
|
* indices, for two blocks:
|
||||||
* 0, 1, 2,
|
* 0, 1, 2,
|
||||||
@ -341,8 +341,11 @@ public final class LineTexBucket extends LineBucket {
|
|||||||
GL.REPEAT, GL.REPEAT);
|
GL.REPEAT, GL.REPEAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static int STRIDE = 12;
|
/* posX, posY, extrX, extrY, length, unused */
|
||||||
private final static int LEN_OFFSET = 8;
|
private final static int STRIDE = 6 * RenderBuckets.SHORT_BYTES;
|
||||||
|
|
||||||
|
/* offset for line length, unused; skip first 4 units */
|
||||||
|
private final static int LEN_OFFSET = 4 * RenderBuckets.SHORT_BYTES;
|
||||||
|
|
||||||
public static RenderBucket draw(RenderBucket b, GLViewport v,
|
public static RenderBucket draw(RenderBucket b, GLViewport v,
|
||||||
float div, RenderBuckets buckets) {
|
float div, RenderBuckets buckets) {
|
||||||
@ -420,8 +423,8 @@ public final class LineTexBucket extends LineBucket {
|
|||||||
if (numIndices > MAX_INDICES)
|
if (numIndices > MAX_INDICES)
|
||||||
numIndices = MAX_INDICES;
|
numIndices = MAX_INDICES;
|
||||||
|
|
||||||
/* i / 6 * (24 shorts per block * 2 short bytes) */
|
/* i * (24 units per block / 6) * unit bytes) */
|
||||||
int add = (b.vertexOffset + i * 8) + vOffset;
|
int add = (b.vertexOffset + i * 4 * RenderBuckets.SHORT_BYTES) + vOffset;
|
||||||
|
|
||||||
gl.vertexAttribPointer(aPos0, 4, GL.SHORT, false, STRIDE,
|
gl.vertexAttribPointer(aPos0, 4, GL.SHORT, false, STRIDE,
|
||||||
add + STRIDE);
|
add + STRIDE);
|
||||||
@ -445,8 +448,8 @@ public final class LineTexBucket extends LineBucket {
|
|||||||
int numIndices = allIndices - i;
|
int numIndices = allIndices - i;
|
||||||
if (numIndices > MAX_INDICES)
|
if (numIndices > MAX_INDICES)
|
||||||
numIndices = MAX_INDICES;
|
numIndices = MAX_INDICES;
|
||||||
/* i / 6 * (24 shorts per block * 2 short bytes) */
|
/* i * (24 units per block / 6) * unit bytes) */
|
||||||
int add = (b.vertexOffset + i * 8) + vOffset;
|
int add = (b.vertexOffset + i * 4 * RenderBuckets.SHORT_BYTES) + vOffset;
|
||||||
|
|
||||||
gl.vertexAttribPointer(aPos0, 4, GL.SHORT, false, STRIDE,
|
gl.vertexAttribPointer(aPos0, 4, GL.SHORT, false, STRIDE,
|
||||||
add + 2 * STRIDE);
|
add + 2 * STRIDE);
|
||||||
|
@ -96,7 +96,7 @@ public abstract class RenderBucket extends Inlist<RenderBucket> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start position in ibo for this bucket
|
* Start position in ibo for this bucket (in bytes)
|
||||||
*/
|
*/
|
||||||
public int getIndiceOffset() {
|
public int getIndiceOffset() {
|
||||||
return indiceOffset;
|
return indiceOffset;
|
||||||
@ -110,9 +110,9 @@ public abstract class RenderBucket extends Inlist<RenderBucket> {
|
|||||||
this.vertexOffset = offset;
|
this.vertexOffset = offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int vertexOffset;
|
protected int vertexOffset; // in bytes
|
||||||
|
|
||||||
protected int indiceOffset;
|
protected int indiceOffset; // in bytes
|
||||||
|
|
||||||
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
||||||
compileVertexItems(vboData);
|
compileVertexItems(vboData);
|
||||||
@ -122,16 +122,16 @@ public abstract class RenderBucket extends Inlist<RenderBucket> {
|
|||||||
|
|
||||||
protected void compileVertexItems(ShortBuffer vboData) {
|
protected void compileVertexItems(ShortBuffer vboData) {
|
||||||
/* keep offset of layer data in vbo */
|
/* keep offset of layer data in vbo */
|
||||||
vertexOffset = vboData.position() * 2; // FIXME 2? - should be vertex stride / num shorts
|
vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||||
vertexItems.compile(vboData);
|
vertexItems.compile(vboData);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void compileIndicesItems(ShortBuffer iboData) {
|
protected void compileIndicesItems(ShortBuffer iboData) {
|
||||||
/* keep offset of layer data in vbo */
|
/* keep offset of layer data in ibo */
|
||||||
if (indiceItems == null || indiceItems.empty())
|
if (indiceItems == null || indiceItems.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
indiceOffset = iboData.position() * 2; // needs byte offset...
|
indiceOffset = iboData.position() * RenderBuckets.SHORT_BYTES;
|
||||||
indiceItems.compile(iboData);
|
indiceItems.compile(iboData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ public class RenderBuckets extends TileData {
|
|||||||
|
|
||||||
static final Logger log = LoggerFactory.getLogger(RenderBuckets.class);
|
static final Logger log = LoggerFactory.getLogger(RenderBuckets.class);
|
||||||
|
|
||||||
public final static int[] VERTEX_SHORT_CNT = {
|
/* Count of units needed for one vertex */
|
||||||
|
public final static int[] VERTEX_CNT = {
|
||||||
4, // LINE_VERTEX
|
4, // LINE_VERTEX
|
||||||
6, // TEXLINE_VERTEX
|
6, // TEXLINE_VERTEX
|
||||||
2, // POLY_VERTEX
|
2, // POLY_VERTEX
|
||||||
@ -58,7 +59,8 @@ public class RenderBuckets extends TileData {
|
|||||||
2, // CIRCLE
|
2, // CIRCLE
|
||||||
};
|
};
|
||||||
|
|
||||||
private final static int SHORT_BYTES = 2;
|
public final static int SHORT_BYTES = 2;
|
||||||
|
// public final static int INT_BYTES = 4;
|
||||||
|
|
||||||
private RenderBucket buckets;
|
private RenderBucket buckets;
|
||||||
|
|
||||||
@ -277,12 +279,12 @@ public class RenderBuckets extends TileData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int countVboSize() {
|
private int countVboSize() {
|
||||||
int vboShorts = 0;
|
int vboSize = 0;
|
||||||
|
|
||||||
for (RenderBucket l = buckets; l != null; l = l.next)
|
for (RenderBucket l = buckets; l != null; l = l.next)
|
||||||
vboShorts += l.numVertices * VERTEX_SHORT_CNT[l.type];
|
vboSize += l.numVertices * VERTEX_CNT[l.type];
|
||||||
|
|
||||||
return vboShorts;
|
return vboSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int countIboSize() {
|
private int countIboSize() {
|
||||||
@ -363,7 +365,7 @@ public class RenderBuckets extends TileData {
|
|||||||
ShortBuffer vboData = MapRenderer.getShortBuffer(vboSize);
|
ShortBuffer vboData = MapRenderer.getShortBuffer(vboSize);
|
||||||
|
|
||||||
if (addFill)
|
if (addFill)
|
||||||
vboData.put(fillCoords, 0, 8);
|
vboData.put(fillShortCoords, 0, 8);
|
||||||
|
|
||||||
ShortBuffer iboData = null;
|
ShortBuffer iboData = null;
|
||||||
|
|
||||||
@ -420,23 +422,25 @@ public class RenderBuckets extends TileData {
|
|||||||
if (vbo == null)
|
if (vbo == null)
|
||||||
vbo = BufferObject.get(GL.ARRAY_BUFFER, vboSize);
|
vbo = BufferObject.get(GL.ARRAY_BUFFER, vboSize);
|
||||||
|
|
||||||
vbo.loadBufferData(vboData.flip(), vboSize * 2);
|
// Set VBO data to READ mode
|
||||||
|
vbo.loadBufferData(vboData.flip(), vboSize * SHORT_BYTES);
|
||||||
|
|
||||||
if (iboSize > 0) {
|
if (iboSize > 0) {
|
||||||
if (ibo == null)
|
if (ibo == null)
|
||||||
ibo = BufferObject.get(GL.ELEMENT_ARRAY_BUFFER, iboSize);
|
ibo = BufferObject.get(GL.ELEMENT_ARRAY_BUFFER, iboSize);
|
||||||
|
|
||||||
ibo.loadBufferData(iboData.flip(), iboSize * 2);
|
// Set IBO data to READ mode
|
||||||
|
ibo.loadBufferData(iboData.flip(), iboSize * SHORT_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static short[] fillCoords;
|
private static short[] fillShortCoords;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
short s = (short) (Tile.SIZE * COORD_SCALE);
|
short s = (short) (Tile.SIZE * COORD_SCALE);
|
||||||
fillCoords = new short[]{0, s, s, s, 0, 0, s, 0};
|
fillShortCoords = new short[]{0, s, s, s, 0, 0, s, 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void initRenderer() {
|
public static void initRenderer() {
|
||||||
|
@ -74,7 +74,7 @@ public final class SymbolBucket extends TextureBucket {
|
|||||||
@Override
|
@Override
|
||||||
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
||||||
/* offset of layer data in vbo */
|
/* offset of layer data in vbo */
|
||||||
this.vertexOffset = vboData.position() * 2; //SHORT_BYTES;
|
this.vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||||
|
|
||||||
int numIndices = 0;
|
int numIndices = 0;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user