I have simple studyng project representing some space star's system. I have a star and several planets with moons rotating around the star. I'm using depth buffer, but planets are always in front of the star even if planet should be shadowed by the star. What can be the issue reason?
void drawPlanet(float orbitRadius, float planetRadius, float daysInYear, float hoursInDay){
static float year = 0;
static float days = 0;
static float hours = 0;
glPushMatrix();
glRotatef(year, 0, 1, 0);
glTranslatef(orbitRadius, 0 ,0);
glRotatef(days, 1, 2, 0);
glutWireSphere(planetRadius, 20, 16);
drawLuna(0.3, 0.1, 30, 15);
glPopMatrix();
hours++;
days = hours/hoursInDay;
year=days/daysInYear;
}
void display(void){
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
gluLookAt(0,0,5, 0, 0, 0, 0 ,1, 0);
glColor3f(1.0, 0.647059, 0.00);
glutSolidSphere(0.5, 20, 16);
glColor3b(197, 96, 63);
drawPlanet(2, 0.2, 50, 12);
drawPlanet(1, 0.15, 30, 15);
glFlush();
}
int main(int argc, char** argv)
{
....
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
glEnable(GL_DEPTH_TEST);
....
}