ok I am doing little random coloring on c++/opengl…
But I got little problem when I use rand()…
so I made little program…
But after compile and running it several times I always get same numbers…
I know this is not opengl problem but this is the best coding forum…
cout << rand() <<endl;
cout << b <<endl;
cout << c <<endl;
cout << d <<endl;
cout << e <<endl;
cout << f <<endl;
You may want to look up the documentation for the function “srand”.
You may also want to look in to calling randomize() then try using random(…)
randomize will create a random seed to start everytime the program executes.
srand() is a function that will ‘seed’ the random number generator to ensure it generates different numbers each execution.
You only need to call it once in your initialisation code, most people usually use the time as a seed (then it varies indefinately, or until time ends if you believe in that).
no that they’ve fixed that problem try a faster generator thats far more random…
4x faster that rand() and its better…