glVertex3i [division by zero exception]

Started by
8 comments, last by angry 20 years, 6 months ago
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]
Advertisement
did you set the projection matrix?

our new version has many new and good features. sadly, the good ones are not new and the new ones are not good
I think it''s better to use float variables for vertices.
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]
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.

____________________________________________________________www.elf-stone.com | Automated GL Extension Loading: GLee 5.00 for Win32 and Linux

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!
That is horrible.
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!!!
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.


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

This topic is closed to new replies.

Advertisement