PDA

View Full Version : Display object



04-11-2000, 07:56 AM
I've got an object and i want to display only the front faces... (the faces are empty polygons)
How can i do that??

Le Bayonnais

Bob
04-11-2000, 08:26 AM
If you mean you don't want to draw the faces not facing your direction, you can use glCullFace(). You pass either GL_FRONT or GL_BACK, depending on how you draw your polygons (cw or ccw).

You enable culling with glEnable(GL_CULL_FACE)

Is this what you meant?

Bob

MikeC
04-12-2000, 01:49 AM
Bob's right, although if your object isn't a convex hull and you want to do hidden-surface removal it gets a bit trickier.

What exactly did you mean by "front faces"?

Sjonny
04-12-2000, 01:58 AM
Is "do it yourself" hidden surface removal much more faster than letting OpenGL decide with culling? I mean, you still have to send all ther vertices and normals, so it will be slower. Or is it allmost unnoticable?

John

Bob
04-12-2000, 02:21 AM
I think OpenGL is using a formula to calculate the area of the polygon projected on the screen. If the area is positive, it's facing the viewer. I don't remember the actual furmula, but as far as i know, it wasn't too complex. So I would say you won't gain that much speed by doing the culling yourself.

If you need to render a convex object (like what Mike was saying), you need to do occlusion culling (or?), and that can be a bit timeconsuming (compared to simple frontface culling). It might even be slower than just draw the polygons as they are. However, if you are using software rendering and want speed, then this might be an option.
The only reason i see why you should do this kind of culling on ordinary objects, is when displaying them in wireframe.

Bob

MikeC
04-12-2000, 03:19 AM
I assume Bob meant "If you need to render a NON-convex object"...

Occlusion culling is a fairly heavy area, and like backface culling it works at the level of whole triangles or above. Hidden-surface or hidden-line removal is different, since you'll often need to draw some parts of a triangle but not the whole thing.

I'd strongly advise against trying to do your own hidden-line removal in application code. Chances are that your algorithm for determining what's visible won't be EXACTLY the same as the OpenGL's, so you can expect to see one-pixel glitches cropping up here and there where the two don't agree.

So: if you want hidden-surface removal for filled polygons, use the Z buffer. That's what it's there for.

If you want hidden-line removal for a wireframe object, your best bet is probably a two-pass algorithm; draw the object as filled polygons, updating the Z-buffer as you do so, then draw it again in wireframe mode. You'll have to do some tricky work with stencilling or polygon offset to get this working properly, but it's doable.

Bob
04-12-2000, 03:55 AM
You're right Mike, meant a non convex object http://www.opengl.org/discussion_boards/ubb/biggrin.gif
Didn't noticed it until you mentioned it...

04-13-2000, 03:40 AM
Thanks for your answers...
Le Bayonnais