Hi, I've come across what by now is probably a very very old Mesa-3.0 bug. Ive included example code that reproduces the bug and 2 screenshots. 1 with the bug from Mesa-3.0 and one without from 3.1. How do I workaround this bug for 3.0?. Btw I'm just learning opengl materials/lighting - what i really want this code to do is have a static light source. This one seems to move with the object. Any pointers? I'm probably doing something wrong here which is whats bringing up this "bug" Thanks for Mesa and Happy Holidays!, Colin Fowler
#include <stdlib.h> #include <stdio.h> #include <GL/glut.h> #include <math.h> static void initcamera(void); static void init(void); static void display(void); static void reshape(int x, int y); struct cam_struct { GLfloat x,y,z; float xrot,yrot,zrot; GLfloat fov; }camera; static GLfloat light0_position[] = {0.0, 0.0, 20.0, 0.0}; int q,w,e,loop; GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat mat_ambient_color[] = { 0.1, 0.1, 0.7, 1.0 }; GLfloat mat_diffuse[] = { 0.1, 0.5, 0.8, 1.0 }; GLfloat high_shininess[] = { 100.0 }; GLfloat mat_emission[] = {0.2, 0.2, 0.2, 0.0}; static void initcamera(void) { camera.x=0.0; camera.y=0.0; camera.z=15.0; camera.xrot=0.0; camera.yrot=0.0; camera.zrot=0.0; camera.fov=90; } static void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_SMOOTH); glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); initcamera(); } static void display(void) { /* clear all pixels, clear depth bit */ glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glRotatef(-camera.xrot,1,0,0); glRotatef(-camera.yrot,0,1,0); glRotatef(-camera.zrot,0,1,1); glTranslatef(-camera.x, -camera.y, -camera.z); glLightfv(GL_LIGHT0, GL_POSITION, light0_position); glRotatef(q,1,0,0); glRotatef(w,0,1,0); glRotatef(e,0,1,1); glPushMatrix(); glMaterialfv(GL_FRONT, GL_AMBIENT, mat_ambient_color); glMaterialfv(GL_FRONT, GL_DIFFUSE, mat_diffuse); glMaterialfv(GL_FRONT, GL_SPECULAR, no_mat); glMaterialfv(GL_FRONT, GL_SHININESS, high_shininess); glMaterialfv(GL_FRONT, GL_EMISSION, mat_emission); glScalef(1,1,0.1); glutSolidSphere(6,20,20); glPopMatrix(); glFlush(); glutSwapBuffers(); } static void reshape(int x, int y) { glViewport(0, 0, x, y); /* set up projection transformation */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); /* for perspective projection */ gluPerspective(camera.fov,(float)x/(float)y,0.1,1000); /* set up viewing transformation */ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); } static void idle(void) { q++; w++; e++; glutPostRedisplay(); } int main(int argc, char** argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(640,480); glutInitWindowPosition(0,0); glutCreateWindow("Foo"); glutReshapeFunc(reshape); glutIdleFunc(idle); init(); glutDisplayFunc(display); glutMainLoop(); return 0; }