Hey all,
One problem I’ve found (and not really sure it’s a problem) is with net.java.games.jogl.util.BufferUtils FloatBuffer. It’s truncating my double values into floats. I could use java.nio.DoubleBuffer, but I don’t see that BufferUtils has a newDoubleBuffer() which means I must use newFloatBuffer() so my values will get truncated.
original double values … x: 0.0, y: -0.01999999955, z: -0.09652002156
float values truncated … x: 0.0, y: -0.02, z: -0.09652002
Any help much appreciated.
— code snip —
FloatBuffer vertexBuffer = BufferUtils.newFloatBuffer(3 * 3);
…
// loop 3 nodes and get x, y, z points
vertexBuffer.put(idx++, (float) node.getX());
vertexBuffer.put(idx++, (float) node.getY());
vertexBuffer.put(idx++, (float) node.getZ());
…
gl.glPolygonMode(GL.GL_FRONT_AND_BACK, GL.GL_LINE);
gl.glColor3f(1.0f, 1.0f, 1.0f);
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glVertexPointer(3, GL.GL_FLOAT, 0, vertexBuffer);
gl.glDrawArrays(GL.GL_TRIANGLES, 0, 8);
gl.glDisableClientState(GL.GL_VERTEX_ARRAY);