Hello,
I think the class SpriteBatcher used in the OpenGl ES 2D framework is not so
strong because if you call SpriteBatcher.endBatch() method without introducing
any sprite (numSprite=0) will receive an IllegalArgumentException.
To avoid this you can check if numSprites == 0 into endBatch() method or simply
catch the exception.
The code would look like this:
public void endBatch(){
try{
vertices.setVertices(verticesBuffer, 0, bufferIndices);
vertices.bind();
vertices.draw(GL10.GL_TRIANGLES, 0, numSprites*6);
vertices.unbind();
}
catch(Exception e){
//nothing to do
}
}
Or like this:
public void endBatch(){
if(numSprites > 0){
vertices.setVertices(verticesBuffer, 0, bufferIndices);
vertices.bind();
vertices.draw(GL10.GL_TRIANGLES, 0, numSprites*6);
vertices.unbind();
}
}
I'm not an expert so I can be wrong with the solution...
What steps will reproduce the problem?
1. Create a new SpriteBatcher.
2. Call method beginBatch(Texture)
3. Call method endBatch() without calling drawSprite before.
Miquel Vidal.
Original issue reported on code.google.com by kelovi...@gmail.com on 10 Jan 2012 at 5:01
Original issue reported on code.google.com by
kelovi...@gmail.com
on 10 Jan 2012 at 5:01