How to change the light position?????
Hi,
I want to change the light position but I don't know how to do that? I know that you have to use GL_POSITION or something
like that but I don't know how to change it properly. Also do you know how to change the color of
the light to make it with red,blue, or green shades.
Re: How to change the light position?????
This is how I'm doing it
// Set up the values (these variables may be global)
GLfloat global_ambient[4]= {0.2, 0.2, 0.2, 1.0};
GLfloat light0pos[4] = {0.0, 0.0, 0.0, 1.0};
GLfloat light0ambient[4] = {0.25, 0.25, 0.25, 1.0};
GLfloat light0diffuse[4] = {0.55, 0.55, 0.55, 1.0};
GLfloat light0specular[4]= {0.15, 0.15, 0.15, 1.0};
// Call this in OnCreate()of your window/view or any intitalization fn.
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, global_ambient);
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE , 0);
glLightfv(GL_LIGHT0, GL_AMBIENT, light0ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light0diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light0specular);
glLightfv(GL_LIGHT0, GL_POSITION, light0pos);
There are other ways of doing this, but this way seems to be convenient
Re: How to change the light position?????
Thanks alot man. This helped me out alot.