I need to find the 2D screen bounding rectangle/extent of a group of triangles drawn in OpenGL. Previously, when I’ve written software renderers, I maintained both the 3D world coordinates AND the projected 2D screen coordinates for each vertex and from this I could calculate the bounding rect.
But OpenGL doesn’t give me that information. How can I (easily) find the projected 2D coordinates of a vertex?
Well, I guess what you could do is retrieve the transformation matrices back from OpenGL.
I believe there is a glGet… function for it - but I’m not sure if it’s in the 1.0 spec, so you may not find it in the redbook/bluebook as they can be found on the site.
Oh I forgot to mention: I’m constructing all my own matrices, including the camera and projection matrices, along with their inversed versions for the ray-picking system I’m using if that helps any.
I suppose I could calculate the projected coordinates for each point seperately, but that seems OTT…