Original Post
Hey everybody. I've been staring at this for a couple of hours now, and I can't seem to figure it out. I'm having a problem with my lighting such that as you move the camera the lighting changes. This gives an effect where vertices will turn completly black as you pan around. It looks like
[edit: ah, I didn't know the board supported html?] The code which I use looks like In that function, for every item that need rendering, I push it's transform matrix onto the stack, and then, for every light, I call SetLight, then I render the object and pop the matrix The setLight function sets the position and color of each light I'm using. Am I missing something? Also, while I'm here, if I attempt to set the ambient color for the light, It seems to be lighting everything, despite the fact my ambient was set to a 10% gray. any ideas what causes that? Thanks for the help. [Edited by - INVERSED on January 19, 2005 5:53:24 PM]
[edit: ah, I didn't know the board supported html?] The code which I use looks like
//The Render Function
void IGraphicDevice::ExecuteRenderList(){
for( std::list<QueueableT>::iterator it = vRenderList.begin(); it != vRenderList.end(); it++ ){
PushMatrix( (*it).lMat );
CRenderable * pRenderable = (*it).pRenderable;
//setup lights
const LocalLightList & vLights = *(*it).pLights;
for( std::list<LightQueueable>::const_iterator l = vLights.begin(); l != vLights.end(); l++ ){
SetLight( (*l).pLight );
}
//render
pRenderable->Render();
//clear lights
ClearLight();
PopMatrix();
}
}
//The SetLight function
void COGLGraphicDevice::SetLight( CSceneLight * pLight ){
assert( pLight );
CVector4 vPos;
switch( pLight->GetType() ){
case CSceneLight::LightType_Directional:
vPos = pLight->GetDirection();
vPos.w = 0.0f;
break;
case CSceneLight::LightType_Point:
vPos = pLight->GetPosition();
vPos.w = 1.0f;
break;
case CSceneLight::LightType_Spot:
vPos = pLight->GetPosition();
vPos.w = 1.0f;
glLightf( GL_LIGHT0 + uCurrentLightsUsed, GL_SPOT_CUTOFF, pLight->GetCutoff() );
glLightf( GL_LIGHT0 + uCurrentLightsUsed, GL_SPOT_EXPONENT, pLight->GetExponent() );
break;
}
//set the color
glEnable( GL_LIGHT0 + uCurrentLightsUsed );
//glLightfv( GL_LIGHT0 + uCurrentLightsUsed, GL_AMBIENT, pLight->GetAmbient() );
glLightfv( GL_LIGHT0 + uCurrentLightsUsed, GL_DIFFUSE, pLight->GetDiffuse() );
glLightfv( GL_LIGHT0 + uCurrentLightsUsed, GL_SPECULAR, pLight->GetSpecular() );
glLightfv( GL_LIGHT0 + uCurrentLightsUsed, GL_POSITION, vPos );
uCurrentLightsUsed++;
}