There is bug in the file TrainingCourse/06_IntroducingPOD/OGLES/OGLESIntroducingPOD.cpp in the Khronos OpenGL ES 1.1 SDKs (OGLES_WINDOWS_X86EMULATION_2.08.28.0634, the download file is OGLES_WINDOWS_X86EMULATION_2.08.28.0634.msi):
(from line 432 to line 444): == BEIGN == m_Scene.GetLight(vPos, *(PVRTVec3*)&vLightDirection, 0); ... // Specify the light direction in world space glLightfv(GL_LIGHT0, GL_POSITION, (float*)&vLightDirection);
We can get light attribute about the position, direction from POD file with class CPVRTModelPOD, how about others like type(point, spot, direct), angle & exponent for spot? Thanks.
I think I got the answer about the second point(how about the attributes of light) – we can get the attributes from the class SPODLight, normally we access the lights from POD from the array pLight in class CPVRTModelPOD.
The issue which you describe isn’t actually a bug. To specify a directional light in OpenGL you pass in a directional vector with the w component set to 0 to glLightfv with the enum GL_POSITION. As per OpenGL documentation:
"If the w component of the position is 0, the light is treated as a directional source. Diffuse and specular lighting calculations take the light’s direction, but not its actual position, into account, and attenuation is disabled."
If you take a look at the code again you’ll see the line …
I see now – the codes in SDK are for the directional light(w = 0.0). If we want to setup attributes for other types such as point light or spot light, we have to put the variable “vPos” as the parameter(w = 1.0 to point out that is position vector) for GL_POSITION.
That it exactly right, yes. Point lights need only GL_POSITION to be set (with w component = 1.0) and spot lights require GL_POSITION (with the previous requirements) and GL_SPOT_DIRECTION with a directional vector. Of course spot lights have more parameters too (such as exponent and cutoff) but these are the enums associated with position and direction.