I made a square and a triangle and set the color to red two days ago. I used the same method to try to make it blue and no matter what color I try or how many times I try to clear the buffers or reset the color it will not do it.
void glutDisplay(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glShadeModel(GL_SMOOTH);
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glutSetColor(1,0.0f,1.0f,0.0f);
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glutSetColor(2,0.0f,1.0f,0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glutSetColor(3,0.0f,1.0f,0.0f);
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd();
glTranslatef(3.0f,0.0f,0.0f);
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glColor3f(0.0,1.0f,0.0f);
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
glColor3f(0.0,0.0f,1.0f);
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glColor3f(0.0,0.5f,0.0f);
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd();
glFlush();
glutSwapBuffers();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_INDEX | GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(600,500);
glutInitWindowPosition(200,200);
glutCreateWindow(“Shapes”);
glutReshapeFunc(glutResize);
glutDisplayFunc(glutDisplay);
glutMainLoop();
return 0;
}
that’s what I did. How do I chang colors???