PDA

View Full Version : debug lighting vs release lighting



haust
10-29-2003, 06:17 AM
i have a very weird problem, with the following code which render a simple landscape
[CODE] glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
land.Render(frustumhelper, draw_debug);
{
GLfloat light_ambient[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat light_diffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f };
GLfloat light_specular[] = { 1.0f, 1.0f, 1.0f, 1.0f };
//GLfloat light_position[] = { 1.0f, 1.0f, 1.0f, 0.0f };
GLfloat light_position[] = { 0.0f, 0.0f, 1.0f, 0.0f };

glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
}
glDisable(GL_LIGHTING);

[CODE]
in release mode, lighting is correct however in debug mode the landscape doesn't lit at all : full dark !!

any hint about this behaviour ??
thanks for the help.

fuxifuxi
10-29-2003, 12:21 PM
Do you have any ASSERTs, cause if you do, they may be the problem...

mikael_aronsson
10-29-2003, 10:29 PM
Yes, check all TRACE and ASSERT lines, one typical problem is if you have:

if( .... )
TRACE( ...);

This will break in release mode, you must use:

if( ... )
{
TRACE( ... );
}

Mikael

Relic
10-30-2003, 05:09 AM
Then sit down and debug what's the difference in OpenGL calls for both paths. http://www.opengl.org/discussion_boards/ubb/wink.gif
You're setting the lighting parameters _after_ you have rendered the frustum helper(?).
If the frustum helper has modified the modelview matrix, the light position is transformed by the current modelview matrix.

haust
10-30-2003, 09:43 AM
Then sit down and debug what's the difference in OpenGL calls for both paths
there is _no_ difference between the debug and release _code_ :)


You're setting the lighting parameters _after_ you have rendered the frustum helper(?).
If the frustum helper has modified the modelview matrix, the light position is transformed by the current modelview matrix.

actually the frustumhelper modify nothing, it just compute the 6 planes (normal and distance values) so the light is till tied to the modelview matrix before frustum operation.

however the debug version works great now. it seems it's another compile problem :( but i'm sure sure i did many rebuild all (using vc 6)....
weirdo.

thanks for your replis guyz ;)