Results 1 to 8 of 8

Thread: Display object

  1. #1
    Guest

    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??

    Le Bayonnais

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Display object

    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

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Display object

    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"?

  4. #4
    Member Contributor
    Join Date
    Feb 2000
    Location
    Breda, Netherlands
    Posts
    57

    Re: Display object

    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

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Display object

    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

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Display object

    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.

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: Display object

    You're right Mike, meant a non convex object
    Didn't noticed it until you mentioned it...

  8. #8
    Guest

    Re: Display object

    Thanks for your answers...
    Le Bayonnais

Similar Threads

  1. How to Open a 2d UI to display 3d object?
    By opengllove in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-21-2017, 11:56 PM
  2. click 2d button to display object
    By gottijay in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 07-17-2011, 07:08 AM
  3. Display 3D-Object
    By Irena in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 02-05-2010, 12:25 PM
  4. display an object
    By airseb in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-30-2002, 04:00 PM
  5. Difference between 95 and NT in object display.
    By Dolphin in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-13-2000, 07:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean