View Full Version : Display object
I've got an object and i want to display only the front faces... (the faces are empty polygons)
How can i do that??
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?
04-12-2000, 02: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"?
04-12-2000, 02: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?
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.
04-12-2000, 04: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.
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...
Thanks for your answers...
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.