NV_evaluators and divide by zero error

Hi,

I have got a small problem with the NV_evaluators, if I try:

float CPTS[4][4][4] = {{{-6.0f, 6.0f, 0.0f, 1.0f}, {-2.0f, 6.0f, 0.0f, 1.0f}, {2.0f, 6.0f, 0.0f, 1.0f}, {6.0f, 6.0f, 0.0f, 1.0f}},
{{-6.0f, 2.0f, 0.0f, 1.0f}, {-2.0f, 2.0f, 0.0f, 1.0f}, {2.0f, 2.0f, 0.0f, 1.0f}, {6.0f, 2.0f, 0.0f, 1.0f}},
{{-6.0f, -2.0f, 0.0f, 1.0f}, {-2.0f, -2.0f, 0.0f, 1.0f}, {2.0f, -2.0f, 0.0f, 1.0f}, {6.0f, -2.0f, 0.0f, 1.0f}},
{{-6.0f, -6.0f, 0.0f, 1.0f}, {-2.0f, -6.0f, 0.0f, 1.0f}, {2.0f, -6.0f, 0.0f, 1.0f}, {6.0f, -6.0f, 0.0f, 1.0f}}};

float CPTS_tex[4][4][4] = {{{0.0f, 1.0f, 0.0f, 1.0f}, {0.33f, 1.0f, 0.0f, 1.0f}, {0.66f, 1.0f, 0.0f, 1.0f}, {1.0f, 1.0f, 0.0f, 1.0f}},
{{0.0f, 0.66f, 0.0f, 1.0f}, {0.33f, 0.66f, 0.0f, 1.0f}, {0.66f, 0.66f, 0.0f, 1.0f}, {1.0f, 0.66f, 0.0f, 1.0f}},
{{0.0f, 0.33f, 0.0f, 1.0f}, {0.33f, 0.33f, 0.0f, 1.0f}, {0.66f, 0.33f, 0.0f, 1.0f}, {1.0f, 0.33f, 0.0f, 1.0f}},
{{0.0f, 0.0f, 0.0f, 1.0f}, {0.33f, 0.0f, 0.0f, 1.0f}, {0.66f, 0.0f, 0.0f, 1.0f}, {1.0f, 0.0f, 0.0f, 1.0f}}};

float TESS[4] = {16.0f, 16.0f, 16.0f, 16.0f};

glEnable(GL_EVAL_VERTEX_ATTRIB0_NV);

glEnable(GL_EVAL_FRACTIONAL_TESSELLATION_NV);

MainLoop
{
// other stuff …

glMapControlPointsNV(GL_EVAL_2D_NV, 0, GL_FLOAT, (4 * sizeof(GLfloat)), (4 * 4 * sizeof(GLfloat)), 4, 4, GL_FALSE, CPTS);
glMapControlPointsNV(GL_EVAL_2D_NV, 8, GL_FLOAT, (4 * sizeof(GLfloat)), (4 * 4 * sizeof(GLfloat)), 4, 4, GL_FALSE, CPTS_tex);
glMapParameterfvNV(GL_EVAL_2D_NV, GL_MAP_TESSELLATION_NV, TESS);

glEvalMapsNV(GL_EVAL_2D_NV, GL_FILL);

// … other stuff
}

I get an divide by zero error, if the glEvalMapsNV(GL_EVAL_2D_NV, GL_FILL); is executed.
If I leave out the glEnable(GL_EVAL_FRACTIONAL_TESSELLATION_NV); call, there is no error.

I had checked for GL errors, but the function for that returned none!

Any ideas for this one?

Diapolo

What compiler are you using?

I´m using Borland C++ Builder 5.0 (Build 12.34) Update Pack 1.

Im not sure but i think a lot of stuff in the opengl on win32 can give you that error if you dont set the FPU flags correctly

Set8087CW($133F);

That´s the first divide by zero error I saw, during my hobby OGL coding sessions .

But I don´t have a clue, how to use the command you specified for my Borland Compiler .

Diapolo

Originally posted by Diapolo:
I´m using Borland C++ Builder 5.0 (Build 12.34) Update Pack 1.

Exactly what I was thinking

There was another topic about this a few months ago, altough I can’t find it right now, so I’ll give you the solution again:

#ifdef BORLANDC
#include
_control87(MCW_EM,MCW_EM);
#endif

Add this to the beginning of your program (before calling any GL function)

I tried the code you posted, but I don´t think my compiler likes it g.

I get 5 error messages:

  • incompatible filename in include command
  • typename expected
  • redeclaration of _control87 with other type
  • wrong initialization
  • ) expected

I translated them from german, perhaps the meaning is sligthly different.
And ideas for this?

Diapolo

Heh… sorry, stupid HTML

You should replace

#include

with

#include <float.h>

Thank you very much, now the code works .

But I´m asking myself, why the floating point errors have to be ignored or why this function need to divide something by zero?

Diapolo

I can only tell you that the MSVC compiler disables these divide errors by default and the Borland C/C++ compiler doesn’t.

But IIRC D3D has the same problem so it’s probably not OGL throwing these errors.

[This message has been edited by richardve (edited 02-18-2002).]