Archived

This topic is now archived and is closed to further replies.

glVertex3i [division by zero exception]

This topic is 5235 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Argh... my rendering code throws a division by zero exception caused by a call to glVertex3i. The code looks like this:
void render()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glTranslatef(0.0f, 0.0f, -5.0f);

glBegin(GL_TRIANGLES);
glVertex3i( 0, 1, 5);
glVertex3i(-1,-1, 5);
glVertex3i( 1,-1, 5);
glEnd();

SwapBuffers(hDC);
}

[edited by - angry on October 22, 2003 8:49:39 AM]

Share on other sites
did you set the projection matrix?

Share on other sites
I think it''s better to use float variables for vertices.

Share on other sites
Are you using Borland C++ compiler? If yes try resetting the FPU state before any gl call:

_control87(MCW_EM, MCW_EM);

this func is found in float.h

If you're not using Borland, well, ignore the above comment

Regards
-Lev

[edited by - Lev Povalahev on October 22, 2003 12:16:37 PM]

Share on other sites
Maybe it''s the Z divide. Make sure you''re the matrix mode is GL_MODELVIEW before you enter your render function, and make sure the projection matrix is set properly, using gluPerspective or whatever.

Share on other sites
quote:

Are you using Borland C++ compiler? If yes try resetting the FPU state before any gl call:

_control87(MCW_EM, MCW_EM);

this func is found in float.h

Yep im using a Borland C++ Compiler. And it worked, thanks!

Share on other sites
That is horrible.

Share on other sites
Probably this simply disables math-exception...I think that problem is not here; note that you get no exception in release version (at least in VC++...) but exceptions are useful not evil!!!

Share on other sites
quote:
Original post by benjamin bunny
Maybe it''s the Z divide. Make sure you''re the matrix mode is GL_MODELVIEW before you enter your render function, and make sure the projection matrix is set properly, using gluPerspective or whatever.

Share on other sites
quote:
Original post by blizzard999
Probably this simply disables math-exception...I think that problem is not here; note that you get no exception in release version (at least in VC++...) but exceptions are useful not evil!!!

You get no exceptions in VC because MS disables FPU exceptions by default, whereas Borland does not, so to ensure compatibility you must do this yourself.

Regards
-Lev