Polygon culling on vertex arrays

I am wondering how I can cull polygons from my game models.

Now, let me explain exactly what I am asking because I know a lot of you are thinking, “Well, use face culling of course”. =)

That is not what I am asking. In my engine, I am using Poser models. They are indexed, meaning I draw them with a glDrawElements call. The vertices, face colors, texture coordinates, etc are all indexed.

I am implementing object removel, so if the object is behind you, I just don’t draw it. When the model is full in front of you, of course the OGL backface culling takes care of not drawing the polygons on the far side of the figure.

Now, here’s the real question. Let’s say the model is halfway in my view. Id there a way to have glDrawElements ONLY draw the polygons that are in my sight? If only 1 polygon from the figure is in my view, is there a way to have glDrawElements only parse that polygon?

Another example: In my world, I have an object with 5000 tris in it surroundg the play area (hollowed out mountain from Bryce).

The game is crawling right now because when glDrawElements gets called, it seems to draw the whole thing even though a huge percentage of it is never going to be in your view.

Do I need to forget about array element drawing, unravel the arrays, and do my own polygon checking? I hope not. <Shiver> That would likely grind the engine to a halt pretty quickly.

OpenGL only does backface and frustum culling. If you want a coarser degree of culling, you’ll have to implement it. For example, use several bounding boxes around the parts of your model and check to see if those are at least partially visible, if not, then just ignore (i.e. don’t draw or process) all the triangles in that part. You can of course use smaller bounding boxes within larger bounding boxes to quickly weed out most of the triangles that need not be drawn.

How is frustrum culling set up? My engine is at the same frame rate when an object is in front of me as when it is behind me, so I need to set this frustrum culling mode up I think.

OpenGL’s frustum culling is at the triangle level and is implemented by default. But since it works at the triangle level, it doesn’t help much since all the triangles still have to be processed to determine if it is in or out of the frustum. At which point it could then be culled or clipped. There is a hint you can use to request that it be disabled but it generally isn’t worth the effort. To get some speed back you have to make OpenGL not process those out of sight triangles to begin with by using a coarser representation of your model like I descibed above.

[This message has been edited by DFrey (edited 06-28-2001).]