progs/tests: compile with SCons and glew
[mesa.git] / progs / tests / mipmap_view.c
index d821f432f0b6a926ca20690b191574b303ff69de..16f3584f703b7455cf1735221f309976e337f58d 100644 (file)
@@ -10,6 +10,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <math.h>
+#include <GL/glew.h>
 #include <GL/glut.h>
 #include <GL/glext.h>
 
@@ -21,6 +22,8 @@ static int TexWidth = 256, TexHeight = 256;
 static int WinWidth = 1044, WinHeight = 900;
 static GLfloat Bias = 0.0;
 static GLboolean ScaleQuads = GL_FALSE;
+static GLint Win = 0;
+
 
 
 static void
@@ -55,17 +58,10 @@ Display(void)
 
    for (bias = -1; bias < 11; bias++) {
 
-      glRasterPos2f(x, y + TexHeight + 5);
-      sprintf(str, "Texture LOD Bias = %d", bias);
-      PrintString(str);
-
-      glPushMatrix();
-      glTranslatef(x, y, 0);
-
-      glEnable(GL_TEXTURE_2D);
-
       if (ScaleQuads) {
          if (bias > 0) {
+            if (texWidth == 1 && texHeight == 1)
+               break;
             texWidth = TexWidth >> bias;
             texHeight = TexHeight >> bias;
             if (texWidth < 1)
@@ -79,6 +75,20 @@ Display(void)
          glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, bias);
       }
 
+      glRasterPos2f(x, y + TexHeight + 5);
+      if (ScaleQuads)
+         sprintf(str, "Texture Level %d: %d x %d",
+                 (bias < 0 ? 0 : bias),
+                 texWidth, texHeight);
+      else
+         sprintf(str, "Texture LOD Bias = %d", bias);
+      PrintString(str);
+
+      glPushMatrix();
+      glTranslatef(x, y, 0);
+
+      glEnable(GL_TEXTURE_2D);
+
       glBegin(GL_POLYGON);
       glTexCoord2f(0, 0);  glVertex2f(0, 0);
       glTexCoord2f(1, 0);  glVertex2f(texWidth, 0);
@@ -138,6 +148,7 @@ Key(unsigned char key, int x, int y)
          ScaleQuads = !ScaleQuads;
          break;
       case 27:
+         glutDestroyWindow(Win);
          exit(0);
          break;
    }
@@ -231,7 +242,8 @@ main(int argc, char *argv[])
    glutInitWindowPosition(0, 0);
    glutInitWindowSize(WinWidth, WinHeight);
    glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
-   glutCreateWindow(argv[0]);
+   Win = glutCreateWindow(argv[0]);
+   glewInit();
    glutReshapeFunc(Reshape);
    glutKeyboardFunc(Key);
    glutDisplayFunc(Display);