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 4 of 4

Thread: Not understanding Culling ????

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2004
    Posts
    2

    Not understanding Culling ????

    Im new to openGL and I do have the redbook as my reference but I feel like Im missing something in regards to rendering polygons.

    I created a model of a cube from which I boolean diff'd a sphere which had a slightly larger diameter than the width of the cube. This left me with a nice interior volume to the cube and nifty hole on each face of the cube. I saved this as a raw triangle file and used this to load vertices into my openGL tutorial program.

    My problem is that this model does not render solid and I have toyed with every permutation of Culling and not-culling I can imagine...

    Here are a few images from my app

    Cube in line mode with front or back face culling enabled (both give the same result)
    http://digitalhound.biz/cube1.JPG

    Now 2 views with Culling disabled...
    http://digitalhound.biz/cube2.JPG
    http://digitalhound.biz/cube3.JPG

    What is going on here???
    Is this some artifact of how Im exporting the model???

    Basic code:
    Gl.glMatrixMode(Gl.GL_PROJECTION);
    Gl.glPolygonMode(Gl.GL_FRONT,Gl.GL_FLAT);
    Gl.glPolygonMode(Gl.GL_BACK,Gl.GL_FLAT);
    //Gl.glCullFace(Gl.GL_FRONT);
    //Gl.glEnable(Gl.GL_CULL_FACE);
    Gl.glLoadIdentity();
    Gl.glTranslatef(0,0,0);
    Gl.glOrtho(Xmin*2,Xmax*2,Ymin*2,Ymax*2,Zmax*2,Zmin *2);

    Thanks for any pointers you can give...

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: Not understanding Culling ????

    Edit:
    You need to draw solid with back face culling on.

    An optical illusion makes the results appear the same but they are not. You also may have some issues with zbuffering, it looks like you don't have zbuffering on, or that it lacks precision.

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    Feb 2004
    Location
    Long Island, New York
    Posts
    586

    Re: Not understanding Culling ????

    you can also mess around with glCullFace(GL_FRONT)
    or glCullFace(GL_BACK)

    there is also you're 'winding' which describes if the vertices to your polygon are defined in a clockwise or counter clockwise fashion (set this using: glFrontFace(GL_CCW or GL_CW)). OpenGL uses this information to determine whether your polygon is front facing or back facing by calculating a determinant.

    anyway, enough about culling.
    your problem seems to be depth testing.

    try this:
    in your initialization:
    glDepthMask(GL_TRUE);
    glEnable(GL_DEPTH_TEST);

    then in your render 'OR' in GL_DEPTH_BUFFER_BIT
    into your glClear() call (glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | ...)

    cheers.

    edit: looks like dorbie got to you as I was writting this

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2004
    Posts
    2

    Re: Not understanding Culling ????

    Aeluned your solution worked like a champ!!!
    Your help has been much appreciated!

    Thanks
    mccainz

Posting Permissions

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