PDA

View Full Version : light position problem



lerwen
07-23-2006, 12:20 AM
it looks like my y and z coordinate for the light position are mixed up. before I position my light, it comes from +y (instead of +z) and to 'fix' it i have to set its position to {0, 1, 0, 0}. I want to know if I messed up someware or does the light appear to be coming from the top on other peoples computers also?


#include <GLUT/glut.h>

void init(void)
{
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_DEPTH_TEST);
glClearColor(0, 0, 0, 0);
}

void display(void)
{
GLdouble matrix[16];

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glutSolidTeapot(1);
glFlush();
}

void reshape(int width, int height)
{
glViewport(0, 0, width, height);
glutPostRedisplay();
}

int main(int argc, char *argv[])
{
int i;
glutInit(&amp;argc, argv);
glutInitDisplayMode(GLUT_DEPTH);
glutCreateWindow("Shit");
init();
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutMainLoop();
return 0;
}

lerwen
07-23-2006, 12:45 AM
i tried changing it to draw a triangle instead of the teapot, and it was lit correctly with my normals. now I think the normals for the teapot are incorectly defined. IS THIS **** CRAZY OR WHAT?

memfr0b
07-23-2006, 12:47 AM
glutSolidTeapot seems to fiddle with the current matrix. You have to switch to GL_MODELVIEW for it to work correctly.