About glDrawElements

Did anyone succeed in using GL.glDrawElements()?

I use almost the same codes both in Java and C++
but I got nothing in Java!!

What I did is drawing a line strip using GL_LINE_STRIP.

And for GL.glVertexPointer(), I used ByteBuffer for the
forth parameter.

I used only DrawElements in my development so far, indexed and vertex buffer indexed, so it is working fine.
It does take some set up in terms of getting the right data ready.
If you still have trouble, I’ll post a quick snippet here, but there are many, many out “there”.
Good luck!

The byte ordering for your e.g. FloatBuffer is probably wrong. See net.java.games.jogl.util.BufferUtils, which provides convenience methods for allocating FloatBuffers and other buffer types with the correct endianness.

Solved it !! Thanks !! :slight_smile:

I had problems with the glDrawElements() function.

My problem was that I was calling :
gl.glDrawElements(primitiveType, 3 * nbTriangles, GL.GL_INT, polygonVertexIndexBuffer);

The solution was to change GL_INT into GL_UNSIGNED_INT

This is not obvious since the int of java are signed :’(

I hope this post will help the other users who have the same problem.