El Viernes, 13 de Febrero de 2004 16:22, Brian Paul escribió: > No, not glPushAttrib(). glPopAttrib() is where the problem probably > occurs.
Sorry, my mistake O:-) > Great. I attach a very stupid program. It draws two cubes (one big blue, and another red small). Press 'r' to rotate both. I use glPushAttrib(GL_CURRENT_BIT)/glPopAttrib() to save/restore the current color. I've successfully tested it with nvidia drivers (the big cube remains being blue). When I try on my ATI Radeon Mobility (iBook 2.2) the big cube starts blue, but once you rotate goes red (and it shouldn't). I just hope it helps.
/* glPushAttrib(), glPopAttrib() tiny test */ #include <GL/glut.h> GLfloat angle = 0.0; int win_w, win_h; void keyboard(unsigned char, int, int); void reshape(int, int); void display(void); int main(int argc, char **argv) { /* libglut stuff */ glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH); glutInitWindowSize(500, 500); glutInitWindowPosition(70, 70); glutCreateWindow("Tiny test"); glutKeyboardFunc(keyboard); glutReshapeFunc(reshape); glutDisplayFunc(display); /* Minimal Enables */ glEnable(GL_DEPTH_TEST); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); glEnable(GL_COLOR_MATERIAL); glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE); glClearColor(1.0, 1.0, 1.0, 1.0); /* Initial color is blue */ glColor3f(0.0, 0.0, 1.0); /* Set up projection matrix */ glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-5.0, 5.0, -5.0, 5.0, -5.0, 5.0); glMatrixMode(GL_MODELVIEW); glutMainLoop(); return 0; } void keyboard(unsigned char key, int x, int y) { switch (key) { case 'r': /* Rotate cubes */ angle += 3.0; if (angle > 360.0) angle -= 360.0; break; case 27: exit(0); } glutPostRedisplay(); } void reshape(int w, int h) { win_w = w; win_h = h; } void display(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); /* Set viewport for blue cube */ glViewport(0, 0, win_w, win_h); glLoadIdentity(); glRotatef(angle, 1.0, 1.0, 1.0); glutSolidCube(3.5); /* Set smaller viewport for red cube */ glViewport(0, 0, win_w/5, win_h/5); glLoadIdentity(); glRotatef(angle, -1.0, 1.0, 1.0); glPushAttrib(GL_CURRENT_BIT); /* Save blue color */ glColor3f(1.0, 0.0, 0.0); glutSolidCube(3.5); glPopAttrib(); /* Restore blue color */ glFlush(); glutSwapBuffers(); }