I’ve been following some tutorials about setting a simple source of light, but I still can’t make it :S let’s say I have a simple surface in 3D
const short a = 11; // width
const short b = 20; // length
glBegin( GL_QUADS );
glNormal3f(0,1,0);
glVertex3f(-b/2,0,-a/2);
glVertex3f(b/2,0,-a/2);
glVertex3f(b/2,0,a/2);
glVertex3f(-b/2,0,a/2);
glEnd(); //surface
And then following the tutorial I have to enable a source of light, then color it, position it etc, so I have this:
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
GLfloat light_color[] = {1.0,0.0,0.0,1.0}; //red for example
GLfloat light_diff[] = {1.0,0.0,0.0,0.0};
glLightfv(GL_LIGHT0, GL_AMBIENT, light_color );
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diff );
glLightfv(GL_LIGHT0, GL_SPECULAR, light_color );
GLfloat light_pos[] = {0.0,3.0,0.0,1.0};
GLfloat light_dir[] = {0.0,0.0,0.0};
glLightfv(GL_LIGHT0, GL_POSITION, light_pos);
glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, light_dir );
glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 60);
glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 128);
//glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 20); // not sure if I need it...
So I have this surface, I position the cone light above it (Y axis) and I want this cone of light to shine on the surface`s center. I normalized the vector, doublechecked everything, but all I got so far is that the said surface is dimmed, no source of light in sight…
I’ve been looking for a simple source code containing a simple light source, but I found none.