glVertexAttribPointer w/ ByteBuffer containing floats

Started by NateS, November 24, 2012, 23:21:12

Previous topic - Next topic

NateS

libgdx has this code for LWJGL:

https://github.com/libgdx/libgdx/blob/master/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglGL20.java#L695

This is not ideal since asFloatBuffer() allocates. Is there a way to call glVertexAttribPointer without allocating when I have a ByteBuffer that contains float data?

spasi

Added an alternative VertexAttribPointer with ByteBuffer data and explicit type parameter. Check the next nightly.

NateS

Cool! 8) The following methods are also affected (though I only checked what libgdx uses):

glDrawElements
glColorPointer
glNormalPointer
glTexCoordPointer
glVertexPointer
glColorPointer

spasi

I added alternatives for the *Pointer functions, but not for DrawElements. With an explicit type, the count argument would have to be exposed too. I don't think it's worth it, you shouldn't be using anything but short indices anyway.