Ive wrote a small app using glVertexPointer with a FloatBuffer.
This app runs well on windows but on linux an exception is thrown…
Details :
// Buffer creation :
this.vertices = com.sun.opengl.util.BufferUtil.newFloatBuffer(4 * 2);
this.vertices.put(-1.0f);
this.vertices.put(-1.0f);
this.vertices.put(1.0f);
this.vertices.put(1.0f);
this.vertices.put(-1.0f);
this.vertices.put(1.0f);
this.vertices.put(1.0f);
this.vertices.put(-1.0f);
...
// Usage with jogl :
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, GL.GL_FLOAT, 0, vertices);
gl.glDrawArrays(GL.GL_LINES, 0, vertices.capacity() / 4);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);
During the execution an Exception is thrown :
Exception in thread "main" java.lang.IndexOutOfBoundsException: Required 1 remaining elements in buffer, only had 0
at com.sun.gluegen.runtime.BufferFactory.rangeCheck(BufferFactory.java:247)
at com.sun.opengl.impl.GLImpl.glVertexPointer(GLImpl.java:25296)
at fr.gjini.morpion.view.BoxRenderer.render(BoxRenderer.java:69)
at fr.gjini.morpion.view.MorpionRenderer.render(MorpionRenderer.java:62)
at fr.gjini.morpion.view.Morpion3DView.render(Morpion3DView.java:152)
at fr.gjini.morpion.view.Morpion3DView.update(Morpion3DView.java:91)
at fr.gjini.game.util.GameController.run(GameController.java:53)
at fr.gjini.morpion.Main.main(Main.java:23)
If I increase the capacity of the buffer of 1, the program is running without exception but nothing is displayed
(maybe it is another problem).
Is it a known bug or is it normal?
I’ve didn’t found any information on this.
Augustin.