The computer represents a float number only approximately, and operations on float numbers will accumulate numeric error.
When we try to find whether two float numbers are equal, this is the wrong way to do
if(a == b) { ... }
You should write a function like,
bool approx_eq(float a, float b) { return fabs(a-b) < 1.0E-8; }
And you you should change the comparison code into,
if( approx_eq(a,b) ) { ... }
glEnabel(GL_NORMALIZE);
#include <cstdio> #include <algorithm> using namespace std; const char* tostring(int var) { static char buf[100]; fill(buf, buf+100, 0); sprintf(buf, "%d", var); return buf; }
// if you want different rand number series, you should use srand(some_seed). // rand() and srand() are defined in stdlib.h. float normalized_rand() { return float( rand() ) / RAND_MAX; }
1.3.6