Permalink
Browse files

lights fixed

  • Loading branch information...
cy137 committed Dec 5, 2011
1 parent 2c84fa3 commit 97a88ca05467cff14cd9ef8b146bcd073fcf5f64
Showing with 9 additions and 7 deletions.
  1. +2 −2 game.cpp
  2. +1 −1 init.h
  3. +6 −4 lights.cpp
View
@@ -22,7 +22,7 @@ using namespace std;
// This function inits things like the globals
void init() {
- GLfloat b[] = { .4, .4, .4, 1 };
+ GLfloat b[] = { .10, .10, .10, 1 };
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, b);
glEnable(GL_COLOR_MATERIAL);
glEnable(GL_DEPTH_TEST); //enable the depth testing
@@ -93,7 +93,7 @@ int main(int argc, char **argv) {
glutCreateWindow("Game"); // Title displayed in window title bar.
- //glutFullScreen();
+ glutFullScreen();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
View
2 init.h
@@ -61,7 +61,7 @@ void processfile(){
{
level_file >> x >> y;
//world.addBox( box(x,y) );
- world.addLight( light(i,x,y,1) );
+ world.addLight( light(i,x,y,3.9) );
}
level_file.close();
}
View
@@ -15,10 +15,10 @@ light::light(int n, GLfloat x, GLfloat y, GLfloat z)
diffuse[3] = 0.7;
c=randomColor();
- ambient[0] = 0.7;
- ambient[1] = 0.7;
- ambient[2] = 0.7;
- ambient[3] = 0.7;
+ ambient[0] = 0.0;
+ ambient[1] = 0.0;
+ ambient[2] = 0.0;
+ ambient[3] = 0.0;
c=randomColor();
specular[0] = 0.7;
@@ -31,7 +31,9 @@ light::light(int n, GLfloat x, GLfloat y, GLfloat z)
void light::draw()
{
+ float LightDir[3] = {0.0f, -1.0f, 0.0f}; // towards the viewer
glPushMatrix();
+ glLightfv(getLightEnum(lightNum), GL_SPOT_DIRECTION, LightDir);
glLightfv(getLightEnum(lightNum), GL_POSITION, position);
glLightfv(getLightEnum(lightNum), GL_DIFFUSE, diffuse);
glLightfv(getLightEnum(lightNum), GL_AMBIENT, ambient);

0 comments on commit 97a88ca

Please sign in to comment.