PDA

View Full Version : LIghting problem



iris_raj
10-16-2003, 09:34 PM
Dear All,

I am renderng a move around a scene(using camera movement techniques). I have defined both ambient and position of the light in the scene.I want tthe light to be lit whereever we are moving in the scene. But I am not getting the desired effect. As I move around the scene,some parts are recieving the light and other parts are looking very dark.Moreover a polygon which have drawn(having blue color)
is rendered with a black color. I am giving the necessary code given below.

/* Light Declaration */
static GLfloat lightpos[] =
{1.0f,1.0f,1.0f,1.0f};
GLfloat ambient[] = { 1.0, 1.0, 1.0, 1.0 };

/* Light Definition */

void renderscene( )
{
glLoadIdentity();
gluLookAt(x, y, z,
x + lx,y + ly,z + lz,
0.0f,1.0f,0.0f);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0,GL_AMBIENT,ambient);
glLightfv(GL_LIGHT0,GL_POSITION,lightpos);
/* Here I am 100 x 100 Floor */
/* Rest the code for code for other scenes */
for( i = -10; i < 10; i++)
for(int j = -10; j < 10; j++)
{
glPushMatrix();
glTranslatef(5+i*10.0,0,5+j * 10.0);
draw_house()
}
}

kindly tell me how to create the light.

Thanks

10-17-2003, 05:13 PM
Have you checked the normals?

10-17-2003, 05:39 PM
Either you're not defining normals, or the lighting is overriding something.

gvm
10-18-2003, 02:31 AM
when you use lighting you cannot use glColor3f by default. to define colors - use glMaterial...
but you can make it work if you call glEnable(GL_COLOR_MATERIAL);