Picking oddness

Howdy all,

I have been having some difficulty in getting picking to work correctly.

I’m pretty sure I’m setting it all up correctly, the right number of hits is returned and so on, but the problem is that whenever the name stack has anything in it, I get an obviously wrong reading on it’s depth. For instance, I only ever push one number ( 0 ) onto the stack, but when a hit is recorded the stack depth is reported as 2^24, and also the contents of the name stack are wrong.

All of the examples I’ve found on the web use the glSelectBuffer() that takes an int array, which no longer seems to exist in jogl, and so i am stuck with using an IntBuffer.

Is there perhaps some wierdness with mapping native bytes to java ints? do I have to worry about endian stuff?

Thanks in advance

never mind, I’ve sorted it out now.

If anyone else runs into this, the solution is to make your direct ByteBuffer little-endian.

Actually you should probably be setting your ByteBuffer to the native byte order. The BufferUtils class in net.java.games.jogl.util does this automatically.