Dynamic light opengl driver bug??

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
babyfox
Posts: 4
Joined: Sat Aug 19, 2006 4:20 pm
Location: England, UK

Dynamic light opengl driver bug??

Post by babyfox »

Hi:

I don't know if this is actually a bug. I am trying to add a few dynamic lights to my scene, however only the first two lights are rendered, the rest are ignored. I had a look at the addDynamicLight function in the OpenGL driver class. It appears to me that the following fragment of code might cause the problem I encounter.

void COpenGLDriver::addDynamicLight(const SLight& light)
{
++LastSetLight;
if (!(LastSetLight < GL_MAX_LIGHTS)
return;
...
}

If the code intends to query the maximum number of light supported byt the hardware, should we use glGetIntegerv function with the token GL_MAX_LIGHTS rather than the GL_MAX_LIGHTS token itself?

I came up with a slight modification which still needs to be tested.
void COpenGLDriver::addDynamicLight(const SLight& light)
{
++LastSetLight;
int nMaxLights;
//ask opengl how many lights are supported
glGetIntegerv(GL_MAX_LIGHTS, &nMaxLights);
if (!(LastSetLight < nMaxLights)
return;
...
}
babyfox
Posts: 4
Joined: Sat Aug 19, 2006 4:20 pm
Location: England, UK

Post by babyfox »

With the modification, the opengl driver now returns the correct amount of dynamic light supported by the driver, 8 in my case. However it still has solved the lighting problem i have.

Any advice will be appreciated.

Many thanks
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Max lights value is fixed in SVN now, thanks for reporting. I think I never tried scenes with mre than two lights visible at once, so I cannot help with your initial problem :(
omaremad
Competition winner
Posts: 1027
Joined: Fri Jul 15, 2005 11:30 pm
Location: Cairo,Egypt

Post by omaremad »

are you using the built in shaders? they only calculate the fist 2 lights added
babyfox
Posts: 4
Joined: Sat Aug 19, 2006 4:20 pm
Location: England, UK

Post by babyfox »

omaremad wrote:are you using the built in shaders? they only calculate the fist 2 lights added
thanks Omaremad. This is exactly where my problem was.


:D
Post Reply