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;
|
||||
|
||||
this.vertexOffset = vboData.position() * 2;
|
||||
this.vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||
vboData.put(buf);
|
||||
}
|
||||
|
||||
|
@ -606,7 +606,7 @@ public class ExtrusionBucket extends RenderBucket {
|
||||
iOffset += idx[i];
|
||||
}
|
||||
}
|
||||
vertexOffset = vboData.position() * 2;
|
||||
vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||
vertexItems.compile(vboData);
|
||||
|
||||
clear();
|
||||
|
@ -35,8 +35,8 @@ import static org.oscim.renderer.MapRenderer.COORD_SCALE;
|
||||
|
||||
/**
|
||||
* Note:
|
||||
* Coordinates must be in range +/- (Short.MAX_VALUE / COORD_SCALE) and the maximum
|
||||
* resolution for coordinates is 0.25 as points will be converted
|
||||
* Coordinates must be in range +/- (Short.MAX_VALUE / COORD_SCALE) if using GL.SHORT.
|
||||
* The maximum resolution for coordinates is 0.25 as points will be converted
|
||||
* to fixed point values.
|
||||
*/
|
||||
public class LineBucket extends RenderBucket {
|
||||
@ -360,7 +360,7 @@ public class LineBucket extends RenderBucket {
|
||||
vNextX = nextX - curX;
|
||||
vNextY = nextY - curY;
|
||||
a = Math.sqrt(vNextX * vNextX + vNextY * vNextY);
|
||||
/* skip too short segmets */
|
||||
/* skip two vertex segments */
|
||||
if (a < mMinDist) {
|
||||
numVertices -= 2;
|
||||
continue;
|
||||
|
@ -68,11 +68,11 @@ import static org.oscim.renderer.MapRenderer.bindQuadIndicesVBO;
|
||||
* flip 0 1 0 1 0 1 0 1
|
||||
* </pre>
|
||||
* <p/>
|
||||
* Vertex layout:
|
||||
* [2 short] position,
|
||||
* [2 short] extrusion,
|
||||
* [1 short] line length
|
||||
* [1 short] unused
|
||||
* Vertex layout (here: 1 unit == 1 short):
|
||||
* [2 unit] position,
|
||||
* [2 unit] extrusion,
|
||||
* [1 unit] line length
|
||||
* [1 unit] unused
|
||||
* <p/>
|
||||
* indices, for two blocks:
|
||||
* 0, 1, 2,
|
||||
@ -341,8 +341,11 @@ public final class LineTexBucket extends LineBucket {
|
||||
GL.REPEAT, GL.REPEAT);
|
||||
}
|
||||
|
||||
private final static int STRIDE = 12;
|
||||
private final static int LEN_OFFSET = 8;
|
||||
/* posX, posY, extrX, extrY, length, unused */
|
||||
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,
|
||||
float div, RenderBuckets buckets) {
|
||||
@ -420,8 +423,8 @@ public final class LineTexBucket extends LineBucket {
|
||||
if (numIndices > MAX_INDICES)
|
||||
numIndices = MAX_INDICES;
|
||||
|
||||
/* i / 6 * (24 shorts per block * 2 short bytes) */
|
||||
int add = (b.vertexOffset + i * 8) + vOffset;
|
||||
/* i * (24 units per block / 6) * unit bytes) */
|
||||
int add = (b.vertexOffset + i * 4 * RenderBuckets.SHORT_BYTES) + vOffset;
|
||||
|
||||
gl.vertexAttribPointer(aPos0, 4, GL.SHORT, false, STRIDE,
|
||||
add + STRIDE);
|
||||
@ -445,8 +448,8 @@ public final class LineTexBucket extends LineBucket {
|
||||
int numIndices = allIndices - i;
|
||||
if (numIndices > MAX_INDICES)
|
||||
numIndices = MAX_INDICES;
|
||||
/* i / 6 * (24 shorts per block * 2 short bytes) */
|
||||
int add = (b.vertexOffset + i * 8) + vOffset;
|
||||
/* i * (24 units per block / 6) * unit bytes) */
|
||||
int add = (b.vertexOffset + i * 4 * RenderBuckets.SHORT_BYTES) + vOffset;
|
||||
|
||||
gl.vertexAttribPointer(aPos0, 4, GL.SHORT, false, 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() {
|
||||
return indiceOffset;
|
||||
@ -110,9 +110,9 @@ public abstract class RenderBucket extends Inlist<RenderBucket> {
|
||||
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) {
|
||||
compileVertexItems(vboData);
|
||||
@ -122,16 +122,16 @@ public abstract class RenderBucket extends Inlist<RenderBucket> {
|
||||
|
||||
protected void compileVertexItems(ShortBuffer vboData) {
|
||||
/* 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);
|
||||
}
|
||||
|
||||
protected void compileIndicesItems(ShortBuffer iboData) {
|
||||
/* keep offset of layer data in vbo */
|
||||
/* keep offset of layer data in ibo */
|
||||
if (indiceItems == null || indiceItems.empty())
|
||||
return;
|
||||
|
||||
indiceOffset = iboData.position() * 2; // needs byte offset...
|
||||
indiceOffset = iboData.position() * RenderBuckets.SHORT_BYTES;
|
||||
indiceItems.compile(iboData);
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,8 @@ public class RenderBuckets extends TileData {
|
||||
|
||||
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
|
||||
6, // TEXLINE_VERTEX
|
||||
2, // POLY_VERTEX
|
||||
@ -58,7 +59,8 @@ public class RenderBuckets extends TileData {
|
||||
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;
|
||||
|
||||
@ -277,12 +279,12 @@ public class RenderBuckets extends TileData {
|
||||
}
|
||||
|
||||
private int countVboSize() {
|
||||
int vboShorts = 0;
|
||||
int vboSize = 0;
|
||||
|
||||
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() {
|
||||
@ -363,7 +365,7 @@ public class RenderBuckets extends TileData {
|
||||
ShortBuffer vboData = MapRenderer.getShortBuffer(vboSize);
|
||||
|
||||
if (addFill)
|
||||
vboData.put(fillCoords, 0, 8);
|
||||
vboData.put(fillShortCoords, 0, 8);
|
||||
|
||||
ShortBuffer iboData = null;
|
||||
|
||||
@ -420,23 +422,25 @@ public class RenderBuckets extends TileData {
|
||||
if (vbo == null)
|
||||
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 (ibo == null)
|
||||
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;
|
||||
}
|
||||
|
||||
private static short[] fillCoords;
|
||||
private static short[] fillShortCoords;
|
||||
|
||||
static {
|
||||
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() {
|
||||
|
@ -74,7 +74,7 @@ public final class SymbolBucket extends TextureBucket {
|
||||
@Override
|
||||
protected void compile(ShortBuffer vboData, ShortBuffer iboData) {
|
||||
/* offset of layer data in vbo */
|
||||
this.vertexOffset = vboData.position() * 2; //SHORT_BYTES;
|
||||
this.vertexOffset = vboData.position() * RenderBuckets.SHORT_BYTES;
|
||||
|
||||
int numIndices = 0;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user