rename vars: vertices counts are actually indices
This commit is contained in:
parent
89edbf90f2
commit
f62ea65f25
@ -75,7 +75,7 @@ public class BitmapLayer extends TextureLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
TextureItem t = textures;
|
TextureItem t = textures;
|
||||||
t.vertices = TextureLayer.INDICES_PER_SPRITE;
|
t.indices = TextureLayer.INDICES_PER_SPRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setVertices(ShortBuffer sbuf) {
|
private void setVertices(ShortBuffer sbuf) {
|
||||||
@ -215,10 +215,10 @@ public class BitmapLayer extends TextureLayer {
|
|||||||
|
|
||||||
t.bind();
|
t.bind();
|
||||||
|
|
||||||
int maxVertices = MapRenderer.maxQuads * INDICES_PER_SPRITE;
|
int maxIndices = MapRenderer.maxQuads * INDICES_PER_SPRITE;
|
||||||
|
|
||||||
// draw up to maxVertices in each iteration
|
// draw up to maxVertices in each iteration
|
||||||
for (int i = 0; i < t.vertices; i += maxVertices) {
|
for (int i = 0; i < t.indices; i += maxIndices) {
|
||||||
// to.offset * (24(shorts) * 2(short-bytes) / 6(indices) == 8)
|
// to.offset * (24(shorts) * 2(short-bytes) / 6(indices) == 8)
|
||||||
int off = (t.offset + i) * 8 + tl.offset;
|
int off = (t.offset + i) * 8 + tl.offset;
|
||||||
|
|
||||||
@ -228,11 +228,11 @@ public class BitmapLayer extends TextureLayer {
|
|||||||
GL.glVertexAttribPointer(s.aTexCoord, 2,
|
GL.glVertexAttribPointer(s.aTexCoord, 2,
|
||||||
GL20.GL_SHORT, false, 12, off + 8);
|
GL20.GL_SHORT, false, 12, off + 8);
|
||||||
|
|
||||||
int numVertices = t.vertices - i;
|
int numIndices = t.indices - i;
|
||||||
if (numVertices > maxVertices)
|
if (numIndices > maxIndices)
|
||||||
numVertices = maxVertices;
|
numIndices = maxIndices;
|
||||||
|
|
||||||
GL.glDrawElements(GL20.GL_TRIANGLES, numVertices,
|
GL.glDrawElements(GL20.GL_TRIANGLES, numIndices,
|
||||||
GL20.GL_UNSIGNED_SHORT, 0);
|
GL20.GL_UNSIGNED_SHORT, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public final class SymbolLayer extends TextureLayer {
|
|||||||
t.upload();
|
t.upload();
|
||||||
|
|
||||||
t.offset = numIndices;
|
t.offset = numIndices;
|
||||||
t.vertices = 0;
|
t.indices = 0;
|
||||||
}
|
}
|
||||||
width = t.width;
|
width = t.width;
|
||||||
height = t.height;
|
height = t.height;
|
||||||
@ -176,9 +176,9 @@ public final class SymbolLayer extends TextureLayer {
|
|||||||
pos += TextLayer.VERTICES_PER_SPRITE * 6;
|
pos += TextLayer.VERTICES_PER_SPRITE * 6;
|
||||||
|
|
||||||
/* six elements used to draw the four vertices */
|
/* six elements used to draw the four vertices */
|
||||||
t.vertices += TextureLayer.INDICES_PER_SPRITE;
|
t.indices += TextureLayer.INDICES_PER_SPRITE;
|
||||||
}
|
}
|
||||||
numIndices += t.vertices;
|
numIndices += t.indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos > 0)
|
if (pos > 0)
|
||||||
@ -199,7 +199,7 @@ public final class SymbolLayer extends TextureLayer {
|
|||||||
textures = Inlist.appendItem(textures, t);
|
textures = Inlist.appendItem(textures, t);
|
||||||
|
|
||||||
t.offset = 0;
|
t.offset = 0;
|
||||||
t.vertices = 0;
|
t.indices = 0;
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ public final class TextLayer extends TextureLayer {
|
|||||||
|
|
||||||
if (y + height > TEXTURE_HEIGHT) {
|
if (y + height > TEXTURE_HEIGHT) {
|
||||||
t.offset = offsetIndices;
|
t.offset = offsetIndices;
|
||||||
t.vertices = (short) (numIndices - offsetIndices);
|
t.indices = (short) (numIndices - offsetIndices);
|
||||||
offsetIndices = numIndices;
|
offsetIndices = numIndices;
|
||||||
|
|
||||||
t.next = pool.get();
|
t.next = pool.get();
|
||||||
@ -167,7 +167,7 @@ public final class TextLayer extends TextureLayer {
|
|||||||
vi.used = pos;
|
vi.used = pos;
|
||||||
|
|
||||||
t.offset = offsetIndices;
|
t.offset = offsetIndices;
|
||||||
t.vertices = (short) (numIndices - offsetIndices);
|
t.indices = (short) (numIndices - offsetIndices);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class TextureItem extends Inlist<TextureItem> {
|
|||||||
|
|
||||||
/** vertex offset from which this texture is referenced */
|
/** vertex offset from which this texture is referenced */
|
||||||
public short offset;
|
public short offset;
|
||||||
public short vertices;
|
public short indices;
|
||||||
|
|
||||||
/** temporary Bitmap */
|
/** temporary Bitmap */
|
||||||
public Bitmap bitmap;
|
public Bitmap bitmap;
|
||||||
|
@ -172,10 +172,10 @@ public abstract class TextureLayer extends RenderElement {
|
|||||||
1f / (t.height * COORD_SCALE));
|
1f / (t.height * COORD_SCALE));
|
||||||
t.bind();
|
t.bind();
|
||||||
|
|
||||||
int maxVertices = MapRenderer.maxQuads * INDICES_PER_SPRITE;
|
int maxIndices = MapRenderer.maxQuads * INDICES_PER_SPRITE;
|
||||||
|
|
||||||
/* draw up to maxVertices in each iteration */
|
/* draw up to maxVertices in each iteration */
|
||||||
for (int i = 0; i < t.vertices; i += maxVertices) {
|
for (int i = 0; i < t.indices; i += maxIndices) {
|
||||||
/* to.offset * (24(shorts) * 2(short-bytes)
|
/* to.offset * (24(shorts) * 2(short-bytes)
|
||||||
* / 6(indices) == 8) */
|
* / 6(indices) == 8) */
|
||||||
int off = (t.offset + i) * 8 + tl.offset;
|
int off = (t.offset + i) * 8 + tl.offset;
|
||||||
@ -198,11 +198,11 @@ public abstract class TextureLayer extends RenderElement {
|
|||||||
2, GL20.GL_SHORT, false, 12,
|
2, GL20.GL_SHORT, false, 12,
|
||||||
layers.vertexArrayBuffer);
|
layers.vertexArrayBuffer);
|
||||||
}
|
}
|
||||||
int numVertices = t.vertices - i;
|
int numIndices = t.indices - i;
|
||||||
if (numVertices > maxVertices)
|
if (numIndices > maxIndices)
|
||||||
numVertices = maxVertices;
|
numIndices = maxIndices;
|
||||||
|
|
||||||
GL.glDrawElements(GL20.GL_TRIANGLES, numVertices,
|
GL.glDrawElements(GL20.GL_TRIANGLES, numIndices,
|
||||||
GL20.GL_UNSIGNED_SHORT, 0);
|
GL20.GL_UNSIGNED_SHORT, 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user