LWJGL Forum

Programming => OpenGL => Topic started by: NateS on November 24, 2012, 23:21:12

Title: glVertexAttribPointer w/ ByteBuffer containing floats
Post by: NateS on November 24, 2012, 23:21:12
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?
Title: Re: glVertexAttribPointer w/ ByteBuffer containing floats
Post by: spasi on November 25, 2012, 00:54:58
Added an alternative VertexAttribPointer with ByteBuffer data and explicit type parameter. Check the next nightly.
Title: Re: glVertexAttribPointer w/ ByteBuffer containing floats
Post by: NateS on November 25, 2012, 01:02:22
Cool! 8) The following methods are also affected (though I only checked what libgdx uses):

glDrawElements
glColorPointer
glNormalPointer
glTexCoordPointer
glVertexPointer
glColorPointer
Title: Re: glVertexAttribPointer w/ ByteBuffer containing floats
Post by: spasi on November 25, 2012, 01:38:31
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.
Title: Re: glVertexAttribPointer w/ ByteBuffer containing floats
Post by: NateS on November 25, 2012, 01:42:12
Sounds good, thanks!