Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: OpenGL crashing when clipping

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Groesbeek, Holland
    Posts
    12

    OpenGL crashing when clipping

    Hi

    I have modeled a soccerfield and now I wanted to move a camera from one end of the field to the other end. Now, when the camera gradually moves on to the field the prog crashes with this error:
    'Project 'blaat.exe' raised exception class EInvalidOp with message 'Invalid Floating Point Operation'.

    It crashes at the point where my nearest polygon (the field) hits zNear. (zNear and zFar are both positive)

    what's going on?
    Signature? who needs a signature?

  2. #2
    Senior Member Regular Contributor
    Join Date
    Jul 2001
    Posts
    442

    Re: OpenGL crashing when clipping

    It is possible that your view matrix is screwy (for example, having a camera focus on its own position, leading to floating point trouble-up-mill).

    Are you using gluLookAt?

  3. #3
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Groesbeek, Holland
    Posts
    12

    Re: OpenGL crashing when clipping

    No, I don't use gluLookAt (yet). But have a look at my sourcecode, maybe you see something wrong with it:

    // Here's the projection part

    glViewport(0, 0, width, height);
    glMatrixMode(GL_PROJECTION); glLoadIdentity();
    gluPerspective(26.0, (GLfloat)width/(GLfloat)height,5000.0f,35000.0f);
    glMatrixMode(GL_MODELVIEW); glLoadIdentity();


    // Initialization settings
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearDepth(1.0f); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_TEST);


    // And here is the rendering loop (just for testing purposes only, I know its not nicely coded)
    double afstandMiddenstip = -12000;
    time_t t1 = time(0);
    for (int i = 1; i <= 6000; i++)
    {
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef (-v.Breedte()/2.0, 0.0, afstandMiddenstip);
    glRotatef (hoek, 1.0, 0.0, 0.0);
    glTranslatef (0.0, -v.Lengte()/2.0, 0.0);

    cam.tekenVeld();
    SwapBuffers(hDC);
    afstandMiddenstip += 10;
    }


    Hope you can find something. By the way, in the mean time I recalled some command for disabling FPU-exceptions, 'Set8087'. I havent figured out yet how to use this, but could that be the solution to my problem?

    [This message has been edited by Quirus (edited 10-31-2002).]
    Signature? who needs a signature?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Location
    macedon, ny
    Posts
    288

    Re: OpenGL crashing when clipping

    Well, i didnt look to hard at the code. But i did see atleast one divide by a variable. Is there any time this variable drops to 0? This would cause the crash.

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Groesbeek, Holland
    Posts
    12

    Re: OpenGL crashing when clipping

    No, the gluPerspective is called only once, before the loop. That can't be the problem, cause at the start opengl does draw some frames. It crashes when the field first crosses the zNear plane of the viewing volume (picture the field coming closer to the camera). If I set the zNear bigger the program crashes quicker. If I set zNear to something positive near 0, it crashes when you are about to 'step onto the field'.
    Signature? who needs a signature?

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Groesbeek, Holland
    Posts
    12

    Re: OpenGL crashing when clipping

    Mm, I just compiled lesson 7 from NeHes tutorials in BCB5 and run. Guess what, now I get the same error when I zoom in 'through' the box. Seems my code is correct after all. Is this some bug in BCB5 or some opengl version, I cant find anything on the web about this.
    Signature? who needs a signature?

  7. #7
    Senior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Princeton, NJ
    Posts
    380

    Re: OpenGL crashing when clipping

    what sort of hardware are you using. I seem to remember a similar problem cropping up with some older video cards which weren't programmed to ignore certain divide by zero errors

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Groesbeek, Holland
    Posts
    12

    Re: OpenGL crashing when clipping

    I got a Voodoo3, and I should have the latest driver. BTW: when I run the precompiled version of lesson 7 it works just fine. I guess that means my voodoo is not the cause. Maybe I should check out the BCB forums.
    Signature? who needs a signature?

  9. #9
    Senior Member Frequent Contributor
    Join Date
    Sep 2000
    Location
    SWEDEN
    Posts
    601

    Re: OpenGL crashing when clipping

    Borland doesn't turn off floating point exceptions by default which leads to the error you're seeing. If you search these forums for "borland floating point exception" you'll find info on how to fix it.

  10. #10
    Junior Member Newbie
    Join Date
    Oct 2002
    Location
    Groesbeek, Holland
    Posts
    12

    Re: OpenGL crashing when clipping

    Yes, thats it. I got the FPU exceptions turned off now and it runs smoothly now.
    Thank you guys!
    Signature? who needs a signature?

Page 1 of 2 12 LastLast

Similar Threads

  1. OpenGL Crashing my PC
    By pkiller162 in forum OpenGL: User Software
    Replies: 2
    Last Post: 08-14-2012, 09:08 AM
  2. OpenGL crashing
    By Cerberus2332 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 05-11-2004, 04:51 PM
  3. OpenGL Crashing HL with mod TS
    By in forum OpenGL: User Software
    Replies: 0
    Last Post: 09-03-2003, 05:18 PM
  4. Replies: 1
    Last Post: 09-02-2003, 01:45 PM
  5. OpenGL Crashing.
    By Alastair Grant in forum OpenGL: User Software
    Replies: 41
    Last Post: 12-06-2000, 11:31 AM

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