Friday, 6 September 2013

Interleaved data in JOGL

Interleaved data in JOGL

I cannot find any information on the proper way to render interleaved
vertex arrays (not VBOs) in JOGL. Specifically, the use of
glVertexAttribPointer() seems to not allow the specification of an offset
within the interleaved data (a FloatBuffer). In C, C++, or Objective-C, I
know exactly how to do this, but in Java there seems to be no clear path
to victory.
The only thing I have tried that looked like it might have worked was to
set the position of the buffer before using glVertexAttribPointer(), but
this had no effect.
For clarity, here is a sample of code in the rendering function:
gl.glEnableVertexAttribArray( POSITION_ATTRIB );
gl.glEnableVertexAttribArray( NORMAL_ATTRIB );
gl.glVertexAttribPointer( POSITION_ATTRIB, 4, GL.GL_FLOAT, false, 32,
vertexBuffer );
// vertexBuffer.position( 4 ); if I try to specify an offset
gl.glVertexAttribPointer( NORMAL_ATTRIB, 4, GL.GL_FLOAT, false, 32,
vertexBuffer );
gl.glDrawArrays( GL.GL_TRIANGLES, 0, nummy );
gl.glDisableVertexAttribArray( NORMAL_ATTRIB );
gl.glDisableVertexAttribArray( POSITION_ATTRIB );
I am using 4 floats for every attribute that I have. I chose a stride of
32 based on
4 bytes per float * 4 floats per attribute * 2 attributes per vertex.

No comments:

Post a Comment