PDA

View Full Version : newbie light question



Mickey_dup1
04-25-2006, 05:11 PM
Hi,
I drawn my scene with a grid (white lines) and a square with a texture; I'm trying to change light position and I can see the difference only on the grid; why this? why I can't change difference light in my textured sqaure; thanks
[CODE]
const float spec[4]={.4f,.4f,.4f,1};
const float shin = 1;
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR ,spec);
glMaterialf(GL_FRONT_AND_BACK,GL_SHININESS ,shin);

GLfloat light_position[4] = {0,4,2,0};
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
glLightfv(GL_LIGHT0, GL_AMBIENT,light_ambient);
glLightfv(GL_LIGHT0, GL_AMBIENT,light_diffuse);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_NORMALIZE);glColorMaterial(GL_FRONT_AN D_BACK,GL_AMBIENT_AND_DIFFUSE);
glEnable(GL_COLOR_MATERIAL);
............................
[CODE]

juju
04-26-2006, 01:24 AM
If u want to change light position u must update your light position every frame. for example:

void Draw()
{
glClear(GL_COLOR_BUFFER_BIT |GL_DEPTH_BUFFER_BIT);
glLoadIdentity();

glLightfv(GL_LIGHT1, GL_POSITION, LightPosition);

...... // Some Draw code
}

Mickey_dup1
04-26-2006, 01:34 AM
this is ok; in fact I can see effect of light changing, but only on white grid! I don't see effect on sqaure textured.Why this?

Komat
04-26-2006, 04:49 AM
What texture function you use on the textured grid? If it is GL_REPLACE, you will need to use GL_MODULATE instead.

Mickey_dup1
04-26-2006, 02:59 PM
It's seems don't change; change luminacne of some objects drawn with glVertex() and glColor but not texture....

04-26-2006, 03:32 PM
:rolleyes:

Mickey_dup1
04-26-2006, 03:47 PM
maybe I didin't to be clear; The grid are many lines white; the textures are on a square; then there's an arrow ( drawn with gevertex,glcolor..). I can see effect of change light position on the grid, on the arrow, but not on the texture ( i can change light pos very much, but the square textures appear in the same way). Is it normal?
Thanks

Mars_999
04-26-2006, 06:31 PM
post a Screenshot

here is a site that can host
http://imageshack.us/

and BTW do you have your normals loaded?