I am working on a project and randomly glDrawArrays with cause the JVM to crash. It is not reproducable as far as I know and I don’t know how to fix it. Here is the JVM dump: http://pastebin.java-gaming.org/ced0e509c251c, and here is the offending code:
// in Graphics.java
public void draw(VertexArrayObject object) {
GL11.glEnable(GL11.GL_TEXTURE_2D);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
GL20.glUseProgram(program);
GL20.glUniformMatrix4fv(projectionLocation, false, toFloatBuffer(orthographic.val, 0, 1 << 4));
object.bind();
GL11.glAlphaFunc(GL11.GL_GREATER, 0.1f);
GL11.glEnable(GL11.GL_ALPHA_TEST);
GL13.glActiveTexture(GL13.GL_TEXTURE0);
GL11.glBindTexture(GL11.GL_TEXTURE_2D, object.getTexture());
@@ object.draw();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
object.unbind();
GL20.glUseProgram(0);
}
// in VertexArrayObject.java
public void draw() {
if (bufferObjects != null) {
for (VertexBufferObject object : bufferObjects) {
if (object == null) {
continue;
}
boolean hasCrop = object.getCropX() >= 0 && object.getCropY() >= 0 && object.getCropWidth() >= 0 && object.getCropHeight() >= 0;
if (hasCrop) {
GL11.glEnable(GL11.GL_SCISSOR_TEST);
GL11.glScissor(object.getCropX(), object.getCropY(), object.getCropWidth(), object.getCropHeight());
}
bind();
object.bind();
GL11.glBindTexture(GL11.GL_TEXTURE_2D, object.getTexture());
GL20.glVertexAttribPointer(0, 2, GL11.GL_FLOAT, false, 8 << 2, 0);
GL20.glVertexAttribPointer(1, 4, GL11.GL_FLOAT, false, 8 << 2, 2 << 2);
GL20.glVertexAttribPointer(2, 2, GL11.GL_FLOAT, false, 8 << 2, 6 << 2);
@@ GL11.glDrawArrays(object.getShape(), 0, object.getVertices());
object.unbind();
unbind();
if (hasCrop) {
GL11.glDisable(GL11.GL_SCISSOR_TEST);
}
}
} else {
if (vertices > 0) {
@@ GL11.glDrawArrays(shape, 0, vertices);
}
}
}
Am I doing something wrong? It renders perfectly fine and works fine 99% of the time, it’s just the occasional JVM crash that confuses me.