Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: Rendering of Complex Shapes

  1. #1
    Guest

    Rendering of Complex Shapes

    I got a new user question that I can't seem to find answers to. I created a complex shape using the following code:

    glBegin(GL_POLYGON); // Drawing Using Triangles
    glColor3f(1.0f,0.0f,0.0f);
    glVertex3f( -2.0f,-2.0f, 0.0f); //
    glVertex3f( 2.0f,-2.0f, 0.0f); //
    glVertex3f( 2.0f,2.0f, 0.0f); //
    glVertex3f( 1.0f,3.0f, 0.0f); //
    glVertex3f( -1.0f,3.0f, 0.0f); //
    glVertex3f( -2.0f,2.0f, 0.0f); //
    glEnd();

    Then I used many other Polygons and quads to make this into a 3D object. My question is, how do I make it so the sides of this object that are not in the field of view of the camera don't show up? Right now, it is a very complex picture, that is hard to understand what is going on, because the backside of the 3D object show up just like the front. But when I use the glutSolidCube(3.0f) command, it looks like it should, but the cube is not the shape that I need. Is there some sort of trick with lighting that I can use? Thanks for any help, Newbie

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: Rendering of Complex Shapes

    If your model is convex, enabling culling should do the trick:

    glEnable( GL_CULL_FACE );
    glCullFace( GL_BACK );

    If it isn't convex, you'll need to enable depth buffering.

  3. #3
    Guest

    Re: Rendering of Complex Shapes

    I am not sure what you mean by if my model is convex. I inserted the lines that you listed above and nothing changed. Does convex pertain to which direction I drew my vertexes? Either clockwise or counterclockwise? For I drew everything in a counterclockwise direction. Thanks for the help. Newbie

  4. #4
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,505

    Re: Rendering of Complex Shapes

    Sounds like you have not enabled depth testing.

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Hannover, Germany
    Posts
    1,074

    Re: Rendering of Complex Shapes

    Did you define all polys counter clockwise?
    Depth-test shouldn't have anything to do with backface culling I think.

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

    Re: Rendering of Complex Shapes

    Depth-test IS relevant if the model isn't convex, i.e. if some front-facing polys should appear behind other front-facing polys. Culling on its own isn't enough here.

  7. #7
    Guest

    Re: Rendering of Complex Shapes

    In my program I enable depth testing by the following code:

    glEnable (GL_DEPTH_TEST);

    And when I do this, the screen stays totally black. But when I comment it out, my complex shape and my cylinder both appear. Do I need to do something else besides the enable to make this work? I also have Lighting, Lighto and Cull_Face enabled.

    May I ask what a convex shape is though? Does it have to do with the counterclockwise means of defining my shapes? And what is the difference between Cull_Face and Depth_Test?

    Thanks,
    Newbie

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: Rendering of Complex Shapes

    Can you e-mail your code ?

    My e-mail address is available when clicking on the question mark near the "posted 12-5-2000...".

    It seems really strange that we cannot find the solution to this (usually) simple problem.

    Regards.

    Eric

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •