Vertex colors dont seem to have an affect on my lighting. All my polygons just look grey (or whatever color I make my light) even though I assign specific colors to them. I must have something I need disabled, but I couldnt find any answers in the man pages.
#include <GLUT/glut.h>
double aspect;
double anglex, angley, manglex, mangley;
GLfloat light_position[] = {4, 0, 0, 0};
GLfloat light_specularity[] = {1, 1, 1, 1};
GLfloat mat_ambient[] = {.2, .2, .2, 1};
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
/*
glBegin(GL_TRIANGLES);
glColor3f(1, 0, 0);
glVertex2f(0, 1);
glColor3f(0, 1, 0);
glVertex2f(1, -1);
glColor3f(0, 0, 1);
glVertex2f(-1, -1);
glEnd();
*/
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
glPushMatrix();
glRotated(manglex, 0, 1, 0);
glRotated(mangley, 0, 0, -1);
glColor3f(1, 0, 0);
glutSolidTeapot(1);
glPopMatrix();
glRotated(anglex, 0, 1, 0);
glRotated(angley, 0, 0, -1);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if (aspect > 1) {
glFrustum(-aspect, aspect, -1, 1, 1, 20);
} else {
glFrustum(-1, 1, -1/aspect, 1/aspect, 1, 20);
}
glTranslated(0, 0, -4);
glFlush();
glutSwapBuffers();
}
void reshape(int x, int y)
{
glViewport(0, 0, x, y);
aspect = (double)x / (double)y;
}
void init(void)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specularity);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
}
void idle(void)
{
display();
}
void motion(int x, int y)
{
anglex = x / 2;
angley = y / 2;
display();
}
void activemotion(int x, int y)
{
manglex = x / 2;
mangley = y / 2;
display();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
glutInitWindowSize(800, 600);
glutInitWindowPosition(100, 100);
glutCreateWindow("dick");
init();
glutPassiveMotionFunc(motion);
glutMotionFunc(activemotion);
glutIdleFunc(idle);
glutReshapeFunc(reshape);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}