QUAD disappearing when animate glutSolidSphere

Hello, this is my first post to this forum so please bear with me. When I run the following code, the first “frame” is exactly what I want, but as the ‘animation’ proceeds the quad does not maintain it’s proper color. Instead it becomes black. Any insight into my problem would be much appreciated.
For completeness, the entire program is listed (I hope).
---------------BEGIN CODE-------------------
#include <GL/glut.h>
#include <stdlib.h>

GLfloat x = 0.0, y = 0.0, z = 0.0;
GLint flag = 0;

void init(void) {
//set light values.
GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat mat_shininess[] = { 50.0 };
GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
GLfloat white_light[] = { 1.0, 1.0, 1.0, 1.0 };
GLfloat lmodel_ambient[] = { 0.1, 0.1, 0.1, 1.0 };
//set bg/clear color.
glClearColor(0.8, 0.4, 0.2, 0.0);
glShadeModel(GL_SMOOTH);

//set light values.
glMaterialfv(GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);

glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//done setting light.

glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
//initial viewing values.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
gluLookAt(-0.5, 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
glutFullScreen();

}

void SphereAnimate(void) {
if(x < 100.0 && !flag) {
x+= 1.05;
y+= 1.05;
}
if(x >= 100.0) {
x-=1.05;
y-=1.05;
flag = 1;
}
if(x <= 100.0 && flag) {
x-=1.05;
y-=1.05;
}
if(x <= 0.0 && flag) {
flag = 0;
}
//glutPostRedisplay();
}

void display(void) {
//clear pixels.
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glPushMatrix();
glColor3f(0.5, 0.5, 1.0);
glTranslatef(0.0, 0.0, 0.0);
//glRotatef(x, 1.0, 0.0, 0.0);
//glRotatef(0.0, 0.0, 1.0, 0.0);
glBegin(GL_QUADS);
	glVertex3f(0.0, 0.0, 0.0);
		glColor3f(0.5, 0.5, 1.0);
	glVertex3f(1.0, 1.0, 0.0);
		glColor3f(0.5, 0.5, 1.0);
	glVertex3f(0.0, 0.5, 0.0);
		glColor3f(0.5, 0.5, 1.0);
	glVertex3f(0.0, 0.0, 0.0);
glEnd();
	glLoadIdentity();
	glTranslatef(0.5, 0.5, 0.0);
	glRotatef(x, 1.0, 0.0, 0.0);
	glRotatef(y, 1.0, 0.0, 0.0);
	glutSolidSphere(0.1, 26, 23); //Solid Sphere.
glPopMatrix();
SphereAnimate();
glutSwapBuffers(); //swap.

} //end of display()

void reshape(GLint width, GLint height) {

glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);

}

void keyboard(unsigned char key, int x, int y) {
switch(key) {
case 27: exit(0); //exit on ESC.
}
}

int main(int argc, char** argv) {

glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(640, 480);
glutInitWindowPosition(100, 100);
glutCreateWindow("_my_test_");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(keyboard);
//glutIdleFunc(SphereAnimate);
glutIdleFunc(display);
glutMainLoop();
return 0;

}

---------END CODE------------

Thank you for your time!

Hi !

The code looks ok to me at least after just a quick look, the only thing that comes to mind is that you only set the colors for the frontfacing polygons, could it be that you have the quad rotated so that you see the back facing side of it ?

Mikael