basic lighting


i´ve played around a bit with a light source in OpenGL and am a bit confused by its behavior. I position the source with

litepos = { 0.0, -1.0, 0.0, 0.0 }; // directional source
glLightfv(GL_LIGHT0, GL_POSITION, litepos);

the light is also transformed by the modelview mmtrix each frame.
if i´m not mistaken, this should create a light beaming straight down onto my scenery.
however, it doesn´ t, the objects are illuminated from below instead. i´ve checked the normal vectors but they are absolutely correct. okay, so maybe swapping the sign of the light vector solves the problem, but i don´t want to hack around here. could it be that GL_POSITION is somehow multiplied with the inverse modelview matrix, like glSpotlight?


I haven’t used gl’s lighting much yet but your code:

litepos = { 0.0, -1.0, 0.0, 0.0 }; // directional source

the parameters for it are (x, Y, z, and something which escapes me)

You have set the light position below the origin which is why it why you object is lit from below, you told it too.

The vector for a directional light indicates the direction it is coming from, not the direction it is shining in.