Selection in Orthographic mode

I have selection working in perspective mode, using the gluPickMatrix() function to generate the pick matrix. The relevant code is:

gluPickMatrix(x, viewport[3] - y, 2,2,viewport);
float aspect = static_cast<float>(width()) / static_cast<float>(height());
gluPerspective(45.0, aspect, 1.0, 100.0);

But what is the equivilent for Orthographic projections? With what do I replace gluPickMatrix()?

Thanks for the help!

Hey i don’t now much about selection. And i’m not sure if this is exactly what you are looking for but i hear the functions glProject and glUnproject getting thrown around a lot for selection.

They can be used for selection, but OpenGL also has a specific render mode for selection where it records which primatives end up in a specific area, which is what i’m trying to use. Anyone have any other ideas? Otherwise i might have to use glProject/unProject.

Ortho is 2D. Can’t u just use the mouse position?

Orthographic projection is as much 3D as perspective projection. It just lacks perspective.

Selection with orthographic projection should not be any different from selection in perspective projection. It should be enough to replace gluPerspective with glOrtho instead. The selection mechanism in OpenGL is independent of type of projection.


Yes it is the same, gluPickMatrix can be used in glOrtho mode. I was thrown by documentation refering to it defineing a ‘frustrum’ which I figured would be specific to 3D.

The problem was elsewhere, and it now works. Thanks guys!

Originally posted by Bob:
Orthographic projection is as much 3D as perspective projection. It just lacks perspective.

3D - perspective = 2D Right?
Or are you talking about how the driver/card handels it; sending it through the same pipeline?

With an orthographic projection matrix, you can still use the depth buffer to eliminate hidden objects, objects too far away are still clipped by the far clip plane, fogging will still fog the objects based on distance from the viewpoint, and so on. All objects have a depth, apart from left/right and up/down; three dimensions are present.

Orthographic projection are usually used to do 2D drawings, but that doesn’t make orthographic projection itself 2D.