Hi all
I’m trying to do picking in a 3D environment using
lwjgl, can’t seem to find any examples on the matter
if some one could point me in the right direction, that
would be great. Thanks !!
Hi all
I’m trying to do picking in a 3D environment using
lwjgl, can’t seem to find any examples on the matter
if some one could point me in the right direction, that
would be great. Thanks !!
You need a direct int buffer, use the handy-dandy methods in BufferUtils.createIntBuffer() etc.
I don’t really understand the difference between a
direct int buffer and other int buffers.
Hmm, when I tried to call viewport.array() when
the viewport is created by BufferUtils.createIntBuffer()
it throws me a java.lang.UnsupportedOperationException
How else can I call
GLU.gluPickMatrix()
to pass in an int[] for viewport if array() is not
implemented?
Thanks for the reply !!
Direct buffers are just like regular buffers, except that they actually map to a linear piece of memory, much like a regular C array. Which means its much faster when you want to hand it off to a native lib like OpenGL. For consistancy LWJGL requires direct buffers whenever data needs sending to any native method.
Converting it to an int[] is simple, you just make an int[] as big as needed and fill it with data from your buffer. Buffers provide a whole heap of relative and absolute get methods you can use.
Just be careful with buffers position and limits. LWJGL methods use these when reading or writing data. Generally that means remembering to rewind or flip the buffer before handing it to LWJGL.
LWJGL will check glGetError automatically for you every frame (in the Window.update if I remember right) which is handy as it traps when you make a mistake.
‘Somewhere’ you’ll have made an invalid OpenGL call. First find out which one it is (mass commenting usually does the trick) then look it up in the OpenGL docs and find what it means.
I’m not sure by what you mean, mass commenting usually does the trick.
when i comment part of the open gl code I think is causing problems, I get “An unexpected exception has been detected in native code outside the VM.” rather than the openGlException
I’m having trouble identifying where the error is.
Does the error code in
org.lwjgl.opengl.OpenGLException: Invalid operation (1282)
mean anything?
EDIT:
I figured out how to locate the line with the error.
org.lwjgl.opengl.Util.checkGLError();
will throw an error when something is wrong,
not wait till Window.update();
The line with the error is apparently…
GL11.glRenderMode(GL11.GL_SELECT);
Now I’m more confused then ever.
did you set up a buffer (glSelectBuffer) BEFORE setting the render mode to GL_SELECT ?
This whole thread brings back some memories - someone else had the exact same problems - just can’t seem to find the thread…
EDIT
here we go, on the LWJGL boards:
http://puppygames.net/forums/viewtopic.php?t=427&highlight=picking
I’m blind and stupid.
The answer was already given to me, and I
just didn’t think about it.
I allocated the glSelectBuffer with a
IntBuffer created by IntBuffer.allocate();
I made the change for the viewport buffer.
but didn’t think about making the change for
the selectBuffer, probably cause there
was no direct message complaining about it.
Conclusion of the night,
I’m blind and stupid.
Thanks for your help guys !!