getting xyz from a bytebuffer

i have a bytebuffer this way
x, y, z <- 3 float
r, g, b<- 3 byte
x,y,z, <- 3 float
r, g, b <- 3 byte

this are just 2 vertices i can give it directly to opengl( gldrawElements) with some stride between in
but are there methods in java to extract just the vertices.ByteBuffer.asFloatBuffer doeesn’t work because
i dont store my vertices consectutive…

Chera

Paul

Create several FloatBuffers which wrap the existing buffer, offset by the appropriate number of bytes. But you really don’t want to be extracting data if you can help it, just write it.

Cas :slight_smile:

you’d make your life a heck of a lot easier if you’d add a padding byte to the RGB (A), then all your floats are 32bit aligned, and a single FloatBuffer+ByteBuffer combo would do.