Sign in to follow this  

picking / glFeedbackBuffer

Recommended Posts

ggonca    122
hi, i have a problem.i'm working in 3D and when i click the window ( with mouse) i want to get the coordinates of that point but not window coordinates.(i know that i can get window coordinates with mousecallback) i draw a point in 0,0,10 in my enviroment.when i click on that point i should get its coordinates.( i also have camera in the my enviroment) so should i use glFeedbackBuffer function ( if yes how??) or anything else? if you can help me i 'll be very glad.thanks ggonca

Share this post

Link to post
Share on other sites
frob    44911
When you pick a point on your screen, you are actually picking a volume.

The volume is the size of the pixel and between the near/far planes.

You might interpret it as a line from some point in the pixel between the near/far planes, but you'll end up missing items if they only partially hit the pixel.

One option is to use a feedback buffer. You clip down to a very small area (one pixel) and render the scene using markers. You collect the array of markers. If the markers show up in your list, the thing is rendered inside that area.

Another option is to use a selection buffer. There is a utility function gluPickMatrix that can help convert from window coordinates to a matrix. The process is basically like the feedback buffer. Nice things about a selection buffer is that you can also see the near/far z coordinates, and you can have multiple names in each selection which is useful for debugging a matrix stack.

There are examples of both in the OpenGL Red Book (found a clicky).

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this