lighting problem


I have a rotating cylinder.
The problem is that when I apply lightings on it, the cylinder gets darker and darker as it rotates, and eventually it becomes black.


How do you place your light source position?hah

how should i place the light source?

Probably a different way than what you do now…

Things to think about when placing lights that might help you figure out your problem.

  1. glLightfv(…, GL_POSITION/GL_SPOT_POSITION, …) calls are affected by the current MODELVIEW matrix.
  2. glLightfv(…, GL_POSITION/GL_SPOT_POSITION, …) calls are NOT affected by the PROJECTION matrix, so if you are putting things there that you shouldn’t be, like glRotate/glTranslate/glScale, your lighting calculations won’t work like they should.

If things change over time, the problem is mostlikley that you dont use ‘glLoadIdentity’ or that your are messing with the matrixmode.

Both are common beginners mistakes.