Creating a solar system in opengl - lighting not working as planned
c, lighting, opengl
Solution
Actually i just realised that ratchet freak was right in the comments. I called gluLookAt after i set the lights position and so it "rotated" it away. I now called it afterwards and it works now!
Problem
i'm trying to create a solar system (only sun, earth and moon) in openGL. My only light source is the sun, which should light the other planets up. I got it working so far, but the faces of the planet which face away from the sun are also lit, i want them to be dark. The objects are `glutSolidSpheres`, the Sun is at the origin and there is also my light source. Here is the code of my lighting setup: ``` GLfloat light_position[] = {0.0, 0.0, 0.0, 1.0}; GLfloat light_ambient_color[] = {0.0, 0.0, 0.0, 0.0}; GLfloat light_diffuse_color[] = {1.0, 1.0, 1.0, 1.0}; glLightfv(GL_LIGHT0, GL_POSITION, light_position); glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient_color); glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse_color); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glColorMaterial ( GL_FRONT, GL_DIFFUSE ) ; glEnable(GL_COLOR_MATERIAL); ``` What am i doing wrong? Can you guys give me a hint?