How can I get an OpenGLPrimitive, to which user has just done a click?

A big cube consists of many small cubes (its really called a Cube of Rubic [img][/img]) I must define, to which small cube and which side of it the user has just done a click. How can I do this? Ive read already about glRenderMode(GL_SELECT) and about gl_SelectBuffer, but I could understand a little Help!

you can do it a number of ways,

  1. create a custom function to draw the scene again but using colours specified with unsigned bytes as indices. in your mouse click function, call the function to draw the scene to the back buffer, and then use glReadPixels to read in the image data at the mouse click. Use the colour found to find the required block.

  2. Use glUnProject to find a ray in 3d and any objects it intersects.

  3. Use the selection buffer which is a bit lame IMHO, but it is not too bad to use. (please dont start an argument about selection buffer - I’ve heard it all before)

the first is probably the easiest, but should only be used if you only want to select one thing at a time.