srihari1986
asked on
AMBIENT AND SPOT LIGHT IN OPENGL
Hi,
Actually i have done a program will have a a room(Where all the walls are a 10 X 10 grid).And actually implemented a ambient light.but when i runt the program i can see that only the 1 wall changes color.
And anybody tell me how should i use spot light and what are the steps i need to use.And how to bring shining to the surface.
Regards
Hari
Actually i have done a program will have a a room(Where all the walls are a 10 X 10 grid).And actually implemented a ambient light.but when i runt the program i can see that only the 1 wall changes color.
And anybody tell me how should i use spot light and what are the steps i need to use.And how to bring shining to the surface.
Regards
Hari
ASKER
Yes my walls are textured.What are the values we need to set for ambient and spot light.Below is the code o have done for the ambient light.The ambient light actually works only on the wall that has no texture.
// method to setup the lighting
void set_light ( void)
{
// controlling the ambient light
GLfloat ambientVal;
if(!nightMode)
ambientVal = 2.0;
else
ambientVal = 0.2;
GLfloat lmodel_ambient[] = {ambientVal,ambientVal,amb ientVal, 1.0 };
glClearColor(0.0,0.0,0.0,1 .0);
glShadeModel(GL_SMOOTH);
// enable ambient light
glLightModelfv(GL_LIGHT_MO DEL_AMBIEN T, lmodel_ambient);
glLightModeli ( GL_LIGHT_MODEL_LOCAL_VIEWE R, GL_TRUE );
glLightModeli ( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
// enable all the lighting
glEnable ( GL_LIGHTING ); // ambient
glEnable (GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL ); // to enable proper transparency and color after the lighting
}
Regards
Hari
// method to setup the lighting
void set_light ( void)
{
// controlling the ambient light
GLfloat ambientVal;
if(!nightMode)
ambientVal = 2.0;
else
ambientVal = 0.2;
GLfloat lmodel_ambient[] = {ambientVal,ambientVal,amb
glClearColor(0.0,0.0,0.0,1
glShadeModel(GL_SMOOTH);
// enable ambient light
glLightModelfv(GL_LIGHT_MO
glLightModeli ( GL_LIGHT_MODEL_LOCAL_VIEWE
glLightModeli ( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE );
// enable all the lighting
glEnable ( GL_LIGHTING ); // ambient
glEnable (GL_DEPTH_TEST);
glEnable(GL_COLOR_MATERIAL
}
Regards
Hari
I'd recommend keeping a browser window open to:
http://rush3d.com/reference/opengl-redbook-1.1/
Whenever you're doing OpenGL programming. The chapter on lighting (#6) is probably going to be most helpful to you. Can you post a bit more code, specifically, your draw function?
http://rush3d.com/reference/opengl-redbook-1.1/
Whenever you're doing OpenGL programming. The chapter on lighting (#6) is probably going to be most helpful to you. Can you post a bit more code, specifically, your draw function?
I've been away with work, I'll try to answer your question soon.
corey
corey
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
corey