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

Thread: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    5

    GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    The line
    glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, 1 );
    causes a floating point division by 0 error in my program if I am drawing in wireframe mode. I am drawing a triangle mesh using GL_TRIANGLES. I am also using call lists to draw my scene.


    The error occurs when glCallList(GLuint list); is called.

    If I take out the lighting model line above the problem no longer occurs. Does anyone know what might be causing this or how to fix it?

  2. #2
    Member Regular Contributor
    Join Date
    Jul 2002
    Location
    Austria
    Posts
    280

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    Where does the division by 0 occur exactly? In which module? It might well be a driver bug. Regards.

    [This message has been edited by Asgard (edited 08-20-2002).]
    XEngine - The Platform- and API-Independent 3D Engine
    with Programmable Pipeline Support: [URL=http://xengine.sourceforge.net
    My]http://xengine.sourceforge.net

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    5

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    It happens in my call to glCallList. I couldn't step into that function for some reason.

  4. #4
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    What are the parameters for ligting you used?

    Try a basic scene with a single line and one directional lights.

    In the lighting equation, it is possible to have
    a division by zero if your not careful.

    V-man
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  5. #5
    Junior Member Regular Contributor
    Join Date
    Feb 2001
    Location
    Gothenburg, Sweden
    Posts
    124

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    It's actually quite normal for a GL implementation to divide by zero, the bigger problem is that your system is set to throw big exceptions when that happens.

    I've seen these problems mostly from users of Borland C++, which throws exceptions by default. I can't remember how you turn it of, but look for fp-control or something similiar.
    --
    /Marcus

  6. #6
    Member Regular Contributor
    Join Date
    May 2000
    Posts
    454

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    In Delphi, I think the function is Set8087CW. In C++ the function call is _control87(MCW_EM,MCW_EM);
    Ron Frazier

  7. #7
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    5

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    yes, I am using Borland and I know how I can turn off exception but unfortunately other sections of the program I am working on relies heavily on exceptions. Thanks anyway.

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    SWEDEN
    Posts
    718

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    This doesn't turn off c++ exception handling, it turns off floating point exceptions. I kind of doubt you rely heavily on floating point exceptions in the rest of your code.

  9. #9
    Junior Member Newbie
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    5

    Re: GL_LIGHT_MODEL_TWO_SIDE error with wireframe drawing

    yeah, you're right. I don't need floating point exceptions. I wasn't aware that you could just disable that type. That should fix my problem. Thanks for the help.

Posting Permissions

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