Here is the code:
private FloatBuffer outXYZ = BufferUtils.createFloatBuffer(4*4);
System.out.println( outXYZ + ":" + outXYZ.capacity() + ":" + outXYZ.position() );
GLU.gluUnProject( xyz[0], xyz[1], xyz[2],
modelView, proj, viewport,
outXYZ );
Output:
java.nio.DirectFloatBufferU[pos=0 lim=16 cap=16]:16:0
Exception in thread "AWT-EventQueue-0" java.lang.IndexOutOfBoundsException
at java.nio.Buffer.checkIndex(Unknown Source)
at java.nio.DirectFloatBufferU.get(Unknown Source)
at org.lwjgl.util.glu.Project.__gluMultMatricesf(Project.java:180)
at org.lwjgl.util.glu.Project.gluUnProject(Project.java:351)
at org.lwjgl.util.glu.GLU.gluUnProject(GLU.java:321)
at GLCharts.Camera.projectToViewPlane(GLCanvas.java:1075)
Any ideas?
This is why I detest Buffer's. When do I rewind? When do I clear?
(I realize my buffer capacity is larger than it needs to be, I was trying to rule that out.)
Any help is much appreciated.
Thanks
The modelView, proj, and viewport needed a rewind().
Not the outXYZ.
::)