-
OpenGL Color Change?
how could i change the color in an animation, in my book, so far it's only shown hot to make the object move. I tried making an array:
Code:
float clvl[3]={0.0,0.0,0.0};
and putting it in with the drawing color:
Code:
glColor3f(clvl[0],clvl[1],clvl[2]);
and then made a statement that cycles through the different variables and changes them accordingly:
Code:
int pos=rand()%3;
if(clvl[pos]==1.0)
{
clvl[pos]=0.0;
}
else
{
clvl[pos]=clvl[pos]+.1;
}
The problem is, is that I don't know where to put this statement. I'm not using system specific code, so it should look like it fits in with a console application.
-
Make a 2 dimensional array for the colors, like so:
Code:
float Color[5][3]= {
{/*1.0f,0.0f,0.0f*/},{color2},etc.
}
then just call
Code:
glColor3f(Color[?]);
and it will read the 2nd array into it.
*EDIT*
then for the cycling, make an array that every 2 frames, cycles through the colors, like so:
Code:
if (count ==2)
{
temp=Color[0];
for (x=0;x<5;x++)
{
Color[x] = Color[x+1];
}
Color[4]=temp;
count = 0;
}
count++
or something similar, I am not thinking very well right now