jeudi 5 février 2015

value noise random function strange output

I am trying to implement this random function that I will use for Value Noise :



float random(int x, int y){
int r;
float s;

srand(y*hgrid+x+seed);

r=rand();

s = (float)(r & 0x7fff)/(float)0x7fff;

return (s);
}


As the author of this function said it ( http://ift.tt/1zkQR7L ) :



It is important to note that some compilers have their own RNG, so this may not work for everyone. Visual C++ 2008 was especially troublesome, however GCC on Linux works perfectly.



So I tried it on windows, using mingw. The output is really strange, since it gives me growing numbers from 0.0 to 1.0.


While on linux, it works like it should, random numbers from 0.0 to 1.0.


Since I am using mingw, which should be like gcc, I was expecting something working the same way.


Why doesn't it works? Is there a way to make it works?





Aucun commentaire:

Enregistrer un commentaire