Sign in to follow this  
mjs1

glUnproject and wireframes

Recommended Posts

mjs1    122
Hello all! This is my first post to gamedev.net. My question was regarding glUnproject and small, hard-to-pick objects like wireframes or points. If you are reading the depth with glReadPixels(), you will only get a hit that isn't the far clipping plane if you pick a pixel with an object in it. When drawing a wireframe this can be hard to do. So my question is: 1. If you use glReadPixels(), what's the best way to get around this problem? The kludgy way I thought of was to do multiple tests of glUnproject in a box pattern around the input x, y value and take the result with the nearest z value. 2. Or is there something better than glReadPixels()? Something like gluPickMatrix() where you can specify a search window as opposed to sampling a single point? Thanks for any help!

Share this post


Link to post
Share on other sites
mikeman    2942
You can increase the width of lines with glLineWidth(), so it would be easier to "hit" wireframe objects.

If you don't want thick lines to actually appear in the screen, you can just render 2 passes:

1)First, render the wireframe with thin lines.
2)Turn off color-writing, and render with "fat" lines only in the z-buffer.

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