Jump to content
  • Advertisement

Archived

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

angry

glVertex3i [division by zero exception]

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

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
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:

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
Guest Anonymous Poster
That is horrible.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!