Bart

01-15-2003, 01:08 AM

Hello,

i have the following Problem. Through the function below i can create squares. Now i would like to give each square a different color. Is this possible? If not would it be possible to color each row in a different way?

Would be very glad if anyone could help me.

Here is my source code:

void QuadratColor(float length,int quant)

{

GLuint DlQuadrat=1;

int i,j;

glNewList (DlQuadrat,GL_COMPILE);

glBegin(GL_LINE_LOOP);

glVertex2f(length, length);

glVertex2f(0, length);

glVertex2f(0, 0);

glVertex2f(length, 0);

glEnd();

glEndList();

for (i=0;i<quant;i++)

{

glPushMatrix();

for (j=0;j<quant;j++){

glPushMatrix();

glCallList(DlQuadrat);

glPopMatrix();

glTranslatef(length,0,0);

}

glPopMatrix();

glTranslatef(0,length,0);

}}

i have the following Problem. Through the function below i can create squares. Now i would like to give each square a different color. Is this possible? If not would it be possible to color each row in a different way?

Would be very glad if anyone could help me.

Here is my source code:

void QuadratColor(float length,int quant)

{

GLuint DlQuadrat=1;

int i,j;

glNewList (DlQuadrat,GL_COMPILE);

glBegin(GL_LINE_LOOP);

glVertex2f(length, length);

glVertex2f(0, length);

glVertex2f(0, 0);

glVertex2f(length, 0);

glEnd();

glEndList();

for (i=0;i<quant;i++)

{

glPushMatrix();

for (j=0;j<quant;j++){

glPushMatrix();

glCallList(DlQuadrat);

glPopMatrix();

glTranslatef(length,0,0);

}

glPopMatrix();

glTranslatef(0,length,0);

}}