Hello, I am forgetting something, or doing something I shouldn't but I can't see it because it is late. I am calling this function:
void Light::SetAmbient(ObjVector3 amb)
{
UseAmbient = true;
if(Ambient == NULL)
Ambient = new ObjVector3(amb);
else if(Ambient != NULL)
{
delete Ambient;
Ambient = new ObjVector3(amb);
}
}
That controls the ambient light, but when I go to enable the light, it acts like the ambient has been magically deleted. Here is where I call for the ambient components:
void Light::EnableLight()
{
if(!glIsEnabled(GL_LIGHTING))
glEnable(GL_LIGHTING);
switch(*LightNumber)
{
case 0:
if(!glIsEnabled(GL_LIGHT0))
glEnable(GL_LIGHT0);
if(UseAmbient)
{
float amb[] = {Ambient->x, Ambient->y, Ambient->z, 1.0}; //HERE: Debugger shows these up as being 5.blahblahblah * 10^-39
glLightfv(GL_LIGHT0, GL_AMBIENT, amb);
}
if(UseDiffuse)
{
float dif[] = {Diffuse->x, Diffuse->y, Diffuse->z, 1.0};
glLightfv(GL_LIGHT0, GL_DIFFUSE, dif);
}
if(UseSpecular)
{
float spc[] = {Specular->x, Specular->y, Specular->z, 1.0};
glLightfv(GL_LIGHT0, GL_SPECULAR, spc);
}
if(UsePosition)
{
float pos[] = {Position->x, Position->y, Position->z, 1.0};
glLightfv(GL_LIGHT0, GL_POSITION, pos);
}
break;
...
Where I call these two functions is here if this helps:
Eng->GetLight(0).SetPosition(ObjVector3(0.0, 2.0, 0.0));
Eng->GetLight(0).SetAmbient(ObjVector3(0.2, 0.2, 0.2));
Eng->GetLight(0).SetDiffuse(ObjVector3(0.8, 0.8, 0.8));
Eng->GetLight(0).SetSpecular(ObjVector3(1.0, 1.0, 1.0));
Eng->GetLight(0).EnableLight();
Anybody see the problem?
Thanks