Hello all,

The current CVS version does not properly restore attributes with
the glPushAttrib(GL_DEPTH_BUFFER_BIT) call. This applies only to
the Mesa Voodoo driver, software works fine.

I've included a simple test program. It draws a spinning cube, and
if given the command line argument "-pop" will do a (supposedly)
harmless glPushAttrib()/glPopAttrib() pair of calls on startup.

To see the affects of the bug, run this program with the Voodoo
driver with and without the "-pop" argument.

Cheers, and many, many thanks for all of your hard work,
-Pete Ratzlaff <[EMAIL PROTECTED]>


#include <stdio.h>
#include <GL/glut.h>

#define DOWHITE glColor3f(1.f, 1.f, 1.f);
#define DORED   glColor3f(1.f, 0.f, 0.f);
#define DOGREEN glColor3f(0.f, 1.f, 0.f);
#define DOBLUE  glColor3f(0.f, 0.f, 1.f);

#define FRONT_TOP_RIGHT     DOBLUE;  glVertex3f( w, w, -w)
#define FRONT_TOP_LEFT      DOWHITE; glVertex3f(-w, w, -w)
#define FRONT_BOTTOM_RIGHT  DOGREEN; glVertex3f( w, -w, -w)
#define FRONT_BOTTOM_LEFT   DORED;   glVertex3f(-w, -w, -w)
#define BACK_TOP_RIGHT      DOGREEN; glVertex3f( w, w, w)
#define BACK_TOP_LEFT       DOGREEN; glVertex3f(-w, w, w)
#define BACK_BOTTOM_RIGHT   DOBLUE;  glVertex3f( w, -w, w)
#define BACK_BOTTOM_LEFT    DOWHITE; glVertex3f(-w, -w, w)

void draw_cube(float w) {

  glBegin(GL_QUADS);

  /* front */
  FRONT_BOTTOM_LEFT;
  FRONT_TOP_LEFT;
  FRONT_TOP_RIGHT;
  FRONT_BOTTOM_RIGHT;

  /* left */
  BACK_BOTTOM_LEFT;
  BACK_TOP_LEFT;
  FRONT_TOP_LEFT;
  FRONT_BOTTOM_LEFT;

  /* back */
  BACK_BOTTOM_RIGHT;
  BACK_TOP_RIGHT;
  BACK_TOP_LEFT;
  BACK_BOTTOM_LEFT;

  /* right */
  FRONT_BOTTOM_RIGHT;
  FRONT_TOP_RIGHT;
  BACK_TOP_RIGHT;
  BACK_BOTTOM_RIGHT;

  /* top */
  FRONT_TOP_LEFT;
  BACK_TOP_LEFT;
  BACK_TOP_RIGHT;
  FRONT_TOP_RIGHT;

  /* bottom */
  BACK_BOTTOM_LEFT;
  FRONT_BOTTOM_LEFT;
  FRONT_BOTTOM_RIGHT;
  BACK_BOTTOM_RIGHT;

  glEnd();

}

void init(int argc, char **argv) {

  int i;

  glClearColor(0., 0., 0., 0.);
  glShadeModel(GL_SMOOTH);
  glEnable(GL_DEPTH_TEST);
  glDepthFunc(GL_LESS);

  for (i=1; i<argc; i++) {
    if (strcmp(argv[i],"-pop") == 0) {
      fprintf(stderr,"glPushAttrib(GL_DEPTH_BUFFER_BIT)/glPopAttrib()\n");

      glPushAttrib(GL_DEPTH_BUFFER_BIT);
      glDisable(GL_DEPTH_TEST);
      glPopAttrib();

    }
  }

}

void reshape(int w, int h) {
  glViewport(0,0,w,h);
}

void display() {

  static float xrot = 0.f;
  static float yrot = 0.f;
  static float zrot = 0.f;

  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();
  glRotatef(xrot,yrot,zrot,1.f);

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  draw_cube(0.2);

  glutSwapBuffers();

  xrot += 10.f;
  yrot += 10.f;
  zrot += 10.f;

  glutPostRedisplay();

}

void keyboard(unsigned char key, int x, int y) {
  switch (key) {
  case 27:
    exit(0);
    break;
  default:
    break;
  }

}

int main(int argc, char **argv) {
  glutInit(&argc, argv);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH | GLUT_RGB);
  glutCreateWindow(argv[0]);
  init(argc,argv);
  glutDisplayFunc(display);
  glutReshapeFunc(reshape);
  glutKeyboardFunc(keyboard);

  glutMainLoop();

  return 0;
}



_______________________________________________
Mesa-dev maillist  -  [EMAIL PROTECTED]
http://lists.mesa3d.org/mailman/listinfo/mesa-dev

Reply via email to