Archived

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

angry

glVertex3i [division by zero exception]

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);
  glLoadIdentity();

  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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites