🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.graphics.api.opengl
1 messages
1 total messages Started by mark Sun, 03 Sep 2000 19:18
Division by Zero errors?
#24
Author: mark
Date: Sun, 03 Sep 2000 19:18
59 lines
3336 bytes
Hello, I'm fairly new to OpenGL programming and am using Borland C++
Builder Pro 4. I have been getting the error "Project main.exe raised
exception class EZeroDivide with message 'Floating point division by
zero'." at various positions/orientations. The error occurs at the
command glEnd().

The only thing I can see in common is when the viewpoint is 'over' a
polygon (ie, a large polygon extending both in front of and behind the
viewpoint). If I disable lighting, everything works fine. Also, if I
disable hardware acceleration (from the Windows Control Panel) it works
fine (albeit very slowly!)

Is OpenGL supposed to cope with such polygons, or am I supposed to do
the clipping myself? Alternatively is it possibly something to do with
my card/driver? (I have a Voodoo 2 Banshee; my CPU is a K6-2). Games
such as Quake 3 run fine.

I have managed to reduce my code down to a simple example which causes
the error (width and height is normally 640x480, but changing it makes
no difference):

glEnable(GL_LIGHTING);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);    
glClearDepth(1.0f);    
glEnable(GL_DEPTH_TEST);    
glDepthFunc(GL_LEQUAL);        
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);

glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);    
glLoadIdentity();            
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW);

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
GLfloat light[4] = {1.0f,1.0f,1.0f,1.0f};
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,light);
glLoadIdentity();

glTranslatef(-3.0f,-1.8f,-3.0f);
glNormal3f(0.0f,1.0f,0.0f);
glColor3f(1.0f,1.0f,1.0f);
glBegin(GL_POLYGON);
glVertex3f(0,0,0);
glVertex3f(0,0,16);
glVertex3f(16,0,16);
glVertex3f(16,0,0);
glEnd(); // causes error here

SwapBuffers( *hDC );

Another odd thing- if I replace glBegin(GL_POLYGON) and glEnd() with
glBegin(GL_QUADS) this example works, but if I add in a
glRotate3f(180.0f,0.0f,1.0f,0.0f); the error returns! (And if I have the
rotation with GL_POLYGON, it works also). Can anyone help?

Thanks in advance,

Mark
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads