How to make a set of 4 random RGB colours? In freeglut or glut. Or opengl.
Generate 4 random float values in [0, 1] and pass them to glColor4f().
well it is not so straight forward.
I have 6 colors.
blue, green, yellow, light blue, white and red.
I want to create a set of 4 colors from them.
colours array[6] = {sblue, sgreen, slblue, syellow, sred, swhite}
;
I got this. All the members are the objects of my structure colours whose members are R, G, B.
How can I do it?
struct colours
{
int red;
int green;
int blue;
}sblue, sgreen, slblue, syellow, sred, swhite;
//--------------------------------------------------------------------------------------------------------------------
int createrandomcolors()
{
sblue.red = 0; sblue.green = 0; sblue.blue = 255;
sgreen.red = 0; sgreen.green = 100; sgreen.blue = 0;
slblue.red= 0; slblue.green = 255; slblue.blue =255;
syellow.red =265; syellow.green = 140; syellow.blue = 0;
sred.red =1; sred.green = 0; sred.blue = 0;
swhite.red=1; swhite.green = 1; swhite.blue =1;
colours array[6] = {sblue, sgreen, slblue, syellow, sred, swhite};
}
So what you want to do is to pick 4 out of those colours at random? That was completely impossible to guess from your original post.
Just generate 4 random integers, to use as indices for an array of colours?
Sorry about that. I suck at making posts.
could you please tell me in detail how to do that?
Or you can use the built-in noise function in the shader language.