Problem using glDrawArrays

Ok, I’m new to JOGL. I’ve created a file containing x,y coordinates of type float. I’m reading the file into a ByteBuffer then using


gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, GL.GL_FLOAT, 0, buffer.asFloatBuffer() );
gl.glDrawArrays(GL.GL_LINES, 0, 100000);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);

to set the pointer and draw the buffer. I’ve set the byte order to native. Is there something I’m missing or not doing? When I run this I get lines going off in every direction.

Hi, I also had problems with drawing buffers.
Try to allocate your buffer like that:
BufferUtils BU = new BufferUtils();
FloatBuffer buffer = BU.newFloatBuffer(size);

And after filling the buffer with data:
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(2, GL.GL_FLOAT, 0, buffer );
gl.glDrawArrays(GL.GL_LINES, 0, 100000);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);

I hope this helps.