Merge pull request #603 from Gustl22/short_constant

Renderer: replace with SHORT_BYTES constant for better readability
This commit is contained in:
Emux 2018-12-03 11:36:25 +02:00 committed by GitHub
commit e773d868f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 8 deletions

View File

@ -23,6 +23,7 @@ import org.oscim.backend.GL;
import org.oscim.core.Tile;
import org.oscim.renderer.bucket.ExtrusionBucket;
import org.oscim.renderer.bucket.ExtrusionBuckets;
import org.oscim.renderer.bucket.RenderBuckets;
import org.oscim.utils.FastMath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -82,7 +83,7 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
for (ExtrusionBucket eb = ebs.buckets(); eb != null; eb = eb.next()) {
gl.vertexAttribPointer(vertexPointer, 3,
GL.SHORT, false, 8,
GL.SHORT, false, RenderBuckets.SHORT_BYTES * 4,
eb.getVertexOffset());
int sumIndices = eb.idx[0] + eb.idx[1] + eb.idx[2];
@ -188,10 +189,10 @@ public abstract class ExtrusionRenderer extends LayerRenderer {
}
gl.vertexAttribPointer(s.aPos, 3, GL.SHORT,
false, 8, eb.getVertexOffset());
false, RenderBuckets.SHORT_BYTES * 4, eb.getVertexOffset());
gl.vertexAttribPointer(s.aLight, 2, GL.UNSIGNED_BYTE,
false, 8, eb.getVertexOffset() + 6);
false, RenderBuckets.SHORT_BYTES * 4, eb.getVertexOffset() + RenderBuckets.SHORT_BYTES * 3);
/* draw extruded outlines (mMesh == false) */
if (eb.idx[0] > 0) {

View File

@ -219,10 +219,10 @@ public class BitmapBucket extends TextureBucket {
int off = (t.offset + i) * 8 + tb.vertexOffset;
gl.vertexAttribPointer(s.aPos, 2,
GL.SHORT, false, 12, off);
GL.SHORT, false, RenderBuckets.SHORT_BYTES * 6, off);
gl.vertexAttribPointer(s.aTexCoord, 2,
GL.SHORT, false, 12, off + 8);
GL.SHORT, false, RenderBuckets.SHORT_BYTES * 6, off + RenderBuckets.SHORT_BYTES * 4);
int numIndices = t.indices - i;
if (numIndices > MAX_INDICES)

View File

@ -145,7 +145,7 @@ public class TextureBucket extends RenderBucket {
for (int i = 0; i < t.indices; i += MAX_INDICES) {
/* to.offset * (24(shorts) * 2(short-bytes)
* / 6(indices) == 8) */
int off = (t.offset + i) * 8 + tb.vertexOffset;
int off = (t.offset + i) * RenderBuckets.SHORT_BYTES * 4 + tb.vertexOffset;
int numIndices = t.indices - i;
if (numIndices > MAX_INDICES)
@ -165,10 +165,10 @@ public class TextureBucket extends RenderBucket {
public void render(int offset, int numIndices) {
gl.vertexAttribPointer(shader.aPos, 4, GL.SHORT,
false, 12, offset);
false, RenderBuckets.SHORT_BYTES * 6, offset);
gl.vertexAttribPointer(shader.aTexCoord, 2, GL.SHORT,
false, 12, offset + 8);
false, RenderBuckets.SHORT_BYTES * 6, offset + RenderBuckets.SHORT_BYTES * 4);
gl.drawElements(GL.TRIANGLES, numIndices,
GL.UNSIGNED_SHORT, 0);