}\r
\r
public SpriteCache (int size) {\r
- this.mesh = new Mesh(true, size * 4, size * 6, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(\r
+ mesh = new Mesh(true, size * 4, size * 6, new VertexAttribute(Usage.Position, 2, "a_position"), new VertexAttribute(\r
Usage.ColorPacked, 4, "a_color"), new VertexAttribute(Usage.TextureCoordinates, 2, "a_texCoords"));\r
+ mesh.setAutoBind(false);\r
\r
short[] indices = new short[size * 6];\r
int len = size * 6;\r
gl.glLoadMatrixf(projectionMatrix.val, 0);\r
gl.glMatrixMode(GL10.GL_MODELVIEW);\r
gl.glLoadMatrixf(transformMatrix.val, 0);\r
+ \r
+ mesh.bind();\r
} else {\r
combinedMatrix.set(projectionMatrix).mul(transformMatrix);\r
\r
shader.begin();\r
shader.setUniformMatrix("u_projectionViewMatrix", combinedMatrix);\r
shader.setUniformi("u_texture", 0);\r
+\r
+ mesh.bind(shader);\r
}\r
drawing = true;\r
}\r
gl.glDisable(GL20.GL_BLEND);\r
gl.glDisable(GL20.GL_TEXTURE_2D);\r
}\r
+ mesh.unbind();\r
}\r
\r
public void draw (Cache cache) {\r
* numVertices);\r
byteBuffer.order(ByteOrder.nativeOrder());\r
buffer = byteBuffer.asFloatBuffer();\r
+ buffer.flip();\r
}\r
\r
/**\r
*/\r
@Override\r
public int getNumVertices() {\r
- return byteBuffer.limit() / attributes.vertexSize;\r
+ return buffer.limit();\r
}\r
\r
/**\r
// }\r
usage = isStatic ? GL11.GL_STATIC_DRAW : GL11.GL_DYNAMIC_DRAW;\r
buffer = byteBuffer.asFloatBuffer();\r
+ buffer.flip();\r
bufferHandle = createBufferObject();\r
}\r
\r
*/\r
@Override\r
public int getNumVertices() {\r
- return byteBuffer.limit() / attributes.vertexSize;\r
+ return buffer.limit();\r
}\r
\r
/**\r
* {@inheritDoc}\r
*/\r
public int getNumMaxVertices() {\r
- return byteBuffer.capacity() / attributes.vertexSize;\r
+ return buffer.capacity();\r
}\r
\r
/**\r