help drawing Triangle using glVertexPointer()

Hey all,

I’m trying to draw a Triangle using glVertexPointer(). I have 3 nodes each w/ X, Y, and Z points, so my vertexBuffer is size 9. The following compiles and I see my points on my screen, but I’m not seeing the three sides that make up a triangle. So I know the problem is not the camera or view as I can see the points that make up the triangle, but I don’t see the lines.

Any help/advice/comments are greatly appreciated.

— snip —

int idx = 0;
FloatBuffer vertexBuffer = BufferUtils.newFloatBuffer(3 * 3);

for (int i = 0; i < 3; i++) {
Node node = (Node) nodes.get(new Integer(nodeID[i]));

  vertexBuffer.put(idx++, (int) node.getX());
  vertexBuffer.put(idx++, (int) node.getY());
  vertexBuffer.put(idx++, (int) node.getZ());

}

gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL.GL_DOUBLE, 0, vertexBuffer);
gl.glBegin(GL.GL_TRIANGLES);
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glDrawArrays(GL.GL_TRIANGLES, 0, 2);
gl.glFlush();
gl.glEnd();
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);

[quote]gl.glVertexPointer(3, GL.GL_DOUBLE, 0, vertexBuffer);
[/quote]
Since your vertexBuffer contains floats, you need to use GL.GL_FLOAT instead.

From the man pages for glVertexPointer:

[quote]Execution of glVertexPointer is not allowed between the execution of glBegin and the corresponding execution of glEnd, but an error may or may not be generated. If no error is generated, the operation is undefined.
[/quote]
So loose the glBegin() and glEnd() lines.