View Full Version : How can I get an OpenGLPrimitive, to which user has just done a click?
A big cube consists of many small cubes (it`s really called a Cube of Rubic http://www.opengl.org/discussion_boards/ubb/smile.gif) I must define, to which small cube and which side of it the user has just done a click. How can I do this?
I`ve read already about glRenderMode(GL_SELECT) and about gl_SelectBuffer, but I could understand a little http://www.opengl.org/discussion_boards/ubb/frown.gif Help!
Rob The Bloke
12-21-2001, 02:35 AM
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.