1

I am having trouble understanding what to use as the "indices" parameter when calling glDrawElementsInstanced() in JOGL.

From looking over some C++ tutorials, it seems that you can just pass in 0 for indices as long as you want to start rendering your vertices from the beginning of the index buffer. JOGL requires that the indices parameter be a Buffer object. I tried creating an IntBuffer with one element, 0, inside it but that didn't work.

When I use this to draw my vertices, I see things drawn on the screen:

gl.glDrawElements(GL.GL_TRIANGLES, 10, GL.GL_UNSIGNED_BYTE, 0)

But when I use this instead, the screen is black:

gl.glDrawElementsInstanced(
    GL.GL_TRIANGLES, 10, GL.GL_UNSIGNED_BYTE, IntBuffer.wrap(Array(0)), 1
)

When I use this, I get a type mismatch error:

gl.glDrawElementsInstanced(
    GL.GL_TRIANGLES, 10, GL.GL_UNSIGNED_BYTE, 0, 1
)

I am using OpenGL 4 and Scala. I have also set my program to use DebugGL4 and am not getting any error messages.

2

In LWJGL which works pretty same way, when I need to pass zero in indices slot I did it this way : (IntBuffer)null. Just casting null to be of the buffer type.

|improve this answer|||||
  • Thank you! It worked to just pass in null without casting, too. – bwroga Jan 19 '13 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.