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: Help!!

  1. #1
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Posts
    173

    Help!!

    I have a cuboid - why does the back face block the front when you look directly at it but disappear when you zoom out and look from above - also why are some of the sides missing or transparent - I did apply
    [ccode]glCullFace (GL_BACK);
    glEnable (GL_CULL_FACE);[/ccode]

    which took away the top and back faces of all the objects rather than just the one I wanted so I removed the line and now the back face of cuboid overlap with the front face when rotating the scene

    Any ideas?

    Thanx

  2. #2
    Junior Member Regular Contributor
    Join Date
    Feb 2000
    Location
    Brisbane,QLD, Australia
    Posts
    101

    Re: Help!!

    make sure your polygon winding is the same across all faces.(The order you specify your verts) Counter-clockwise seems to be popular, if your unsure on how do do this then glDisable(GL_CULL_FACE) should stop your faces disapearing.

    check you have this consistant, and for a hack you could do the example.

    void glPolygonMode(
    GLenum face, //GL_FRONT, GL_BACK, GL_FRONT_AND_BACK
    GLenum mode //GL_FILL, GL_LINE, GL_POINT
    );

    so... (example)

    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE)
    should also help your polys to be displayed from all angles.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Posts
    173

    Re: Help!!

    I've checked the polygon winding - it's fine - I tried glDisable(GL_CULL_FACE) - it doesn't seem to make a difference
    This is my code in Onsize()
    {
    .
    .
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, aspect, 0.0,300);//60,aspect, 0.0, 300
    glMatrixMode (GL_MODELVIEW);
    glLoadIdentity ();
    //glCullFace (GL_BACK);
    //glDisable (GL_CULL_FACE);
    glEnable (GL_LIGHTING);
    glEnable (GL_DEPTH_TEST);
    .
    .
    }

    I also tried glPolygonMode(GL_FRONT, GL_LINE);

    placing it just before drawing each face - and i get a blank screen

  4. #4
    Junior Member Regular Contributor
    Join Date
    Sep 2000
    Location
    Italy
    Posts
    124

    Re: Help!!

    I encountered a similar problem some time ago... while rotating a cube I could see faces appear and disappear in a strange way, and it was a mix of these errors:
    - I didn't set up properly normals
    - I didn't ordered poly vertex counter-clockwise
    - I was applying an incorrect transformation

    Try to check these...

  5. #5
    Member Regular Contributor
    Join Date
    Oct 2000
    Location
    USA
    Posts
    303

    Re: Help!!

    Yes, you must be sure to wind your polys in the right direction. Also make sure you've got depth testing turned on. I believe by default, if you looked at one side of the poly and from that perspective you saw it wound in a counter-clockwise direction, that side is considered the "front" of the poly and the other side is the backface. You can change this default behaviour with an OpenGL call the name of which escapes me at the moment. Anyway, make sure you wind your polys in the right direction. I've heard people say it doesn't matter which way you wind as long as it is consistent and from what I know, if you're using backface culling, this is dead wrong. It does matter which way if you aren't specifying to OpenGL which way you're winding because the way you wind it determines which side is the front and which is the back.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Posts
    173

    Re: Help!!

    I've re-examined the polygon windings and made a few changes but get the same result

    When added the back-face culling - in onpaint I added the line below

    glDepthFunc(GL_LEQUAL);

    - I think this may be the problem - removing it gives a blank screen I'm not sure why because I already have glEnable(GL_LIGHTING); glEnable(GL_DEPTH_TEST); and glEnable(GL_LIGHT0);

    any ideas

    I can submit some code if that helps
    Thanx


    [This message has been edited by fox (edited 10-11-2000).]

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

    Re: Help!!

    The problem only happens when you zoom out?
    If so, then I'd tend to think you have a problem with your farplane:nearplane ratio.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Aug 2000
    Posts
    173

    Re: Help!!

    Hey it works it works - yes it work ha ha ha ha ha ha ha ha ha ha ha ha

Posting Permissions

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