JRGlide
12-05-2007, 09:12 AM
This question is actually something I've already figured out, but I think I probably did it the hard way. So maybe there is an easier way.
I have a program that allows the user to rotate, pan, and zoom a model in GL. I need to be able to find the extents of the Open GL window. For example, for a given view I need to know that min/max x ranges from -5 to +10 and min/max y goes from -4.4 to +10.5.
What I did was to start at each edge (top, bottom, left, right) and use glReadPixels to read the RGB values a column or row at a time. Since the background is black, I just keep reading until I found a value that isn't black. Then I read the depth buffer and do a gluUnProject to get the 3D value at each edge. The left side gives me minx, the right side gives me maxx, etc.
This works but did I do it the hard way? Is there some simple command that does the same thing?
Thank you.
I have a program that allows the user to rotate, pan, and zoom a model in GL. I need to be able to find the extents of the Open GL window. For example, for a given view I need to know that min/max x ranges from -5 to +10 and min/max y goes from -4.4 to +10.5.
What I did was to start at each edge (top, bottom, left, right) and use glReadPixels to read the RGB values a column or row at a time. Since the background is black, I just keep reading until I found a value that isn't black. Then I read the depth buffer and do a gluUnProject to get the 3D value at each edge. The left side gives me minx, the right side gives me maxx, etc.
This works but did I do it the hard way? Is there some simple command that does the same thing?
Thank you.