View Full Version : OpenGL crashing when clipping
10-31-2002, 03:21 AM
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?
10-31-2002, 07:49 AM
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?
10-31-2002, 09:42 AM
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);
// 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);
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);
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).]
10-31-2002, 12:23 PM
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.
10-31-2002, 12:37 PM
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'.
11-01-2002, 03:44 AM
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.
11-01-2002, 03:54 AM
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
11-01-2002, 04:07 AM
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.
11-01-2002, 05:15 AM
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.
11-01-2002, 07:20 AM
Yes, thats it. I got the FPU exceptions turned off now and it runs smoothly now.
Thank you guys!
11-01-2002, 07:28 AM
oh, by the way, the command that I used is:
with an #include <float.h>
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.