wgl: Fix debug_printf format specifiers.
[mesa.git] / progs / demos / reflect.c
index 9cd71d1c3db5f9e89b7b8bf2744aa61d6470f885..b72af12885d24c13643f0d3da30dc9b5431a0f7e 100644 (file)
@@ -42,6 +42,9 @@
 #define INIT_WIDTH 400
 #define INIT_HEIGHT 300
 
+#ifdef _WIN32
+#undef CreateWindowA
+#endif
 
 struct window {
    int id;               /* returned by glutCreateWindow() */
@@ -181,6 +184,8 @@ MakeObjects(GLuint *objects_list)
    glMaterialfv( GL_FRONT, GL_EMISSION, black );
    gluCylinder( q, 1.5, 0.0,  2.5, 15, 1 );
    glEndList();
+
+   gluDeleteQuadric(q);
 }
 
 
@@ -297,11 +302,21 @@ DrawWindow(void)
    GLfloat dist = 20.0;
    GLfloat eyex, eyey, eyez;
 
-   glDrawBuffer(w->drawBuffer);
-   glReadBuffer(w->drawBuffer);
+   if (w->drawBuffer == GL_NONE) {
+      glDrawBuffer(GL_BACK);
+      glReadBuffer(GL_BACK);
+   }
+   else {
+      glDrawBuffer(w->drawBuffer);
+      glReadBuffer(w->drawBuffer);
+   }
 
    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
 
+   if (w->drawBuffer == GL_NONE) {
+      glDrawBuffer(GL_NONE);
+   }
+
    eyex = dist  *  cos(w->yrot * DEG2RAD)  *  cos(w->xrot * DEG2RAD);
    eyez = dist  *  sin(w->yrot * DEG2RAD)  *  cos(w->xrot * DEG2RAD);
    eyey = dist  *  sin(w->xrot * DEG2RAD);
@@ -371,10 +386,10 @@ DrawWindow(void)
       ShowAlphaBuffer(w->width, w->height);
    }
 
-   if (w->drawBuffer == GL_BACK)
-      glutSwapBuffers();
-   else
+   if (w->drawBuffer == GL_FRONT)
       glFinish();
+   else
+      glutSwapBuffers();
 
    /* calc/show frame rate */
    {
@@ -386,6 +401,7 @@ DrawWindow(void)
          GLfloat seconds = (t - t0) / 1000.0;
          GLfloat fps = frames / seconds;
          printf("%d frames in %g seconds = %g FPS\n", frames, seconds, fps);
+         fflush(stdout);
          t0 = t;
          frames = 0;
       }
@@ -455,6 +471,10 @@ Key(unsigned char key, int x, int y)
          w->drawBuffer = GL_FRONT;
       glutPostRedisplay();
       break;
+   case '0':
+      w->drawBuffer = GL_NONE;
+      glutPostRedisplay();
+      break;
    case ' ':
       w->anim = !w->anim;
       w->t0 = -1;