Add glGetBoundingBox() function

Hi All,

I suggest to add function which returns axis aligned bounding box of a drawing, i.e. calculates extremes of data to be drawn. This function would be very useful to set correct projection parameters.

The straightforward way to calc vertex extremes separate from OpenGL is not elegant and easy. Some primitives are drawn with some glTranslate and glRotate is applied to them so that to calc the bounding box I have to do the same transformation calculations which OpenGL already has done. Why to do the same work twice??

For example, in Win32 API there is the function GetRgnBox() which returns bounding box of defined region.

Thanks,
Vlad.

OpenGL is a low-level API. Information in OpenGL best travels in one direction: from your application to the implementation. Also, OpenGL does not, and should not, have any knowledge of “data to be drawn.” It is only aware of the data you are currently telling it to draw right now.

In order for an implementation to retrieve your bounding box, it would have to actually store a set of camera-space post-T&L’d data somewhere. What if you’re using EXT_vertex_shader or NV_vertex_program and you don’t have a notion of camera-space transforms for your data (or, at least, your modelview matrix is folded into your projection matrix)?

Instead of transforming the actual object, why not transform the model-space bounding boxes into world space? They won’t be axis-aligned anymore, but you can convert those un-aligned boxes into slightly larger aligned one easily enough.