Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / progs / tests / manytex.c
index 06e67bdbccc196920beee79edfaca205a806d84d..83c86766571013bd0129cc278b885820e544dfbc 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id: manytex.c,v 1.2 2000/10/23 23:32:22 brianp Exp $ */
 
 /*
  * test handling of many texture maps
@@ -12,6 +11,7 @@
 #include <assert.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <math.h>
 #include <GL/glut.h>
 
@@ -28,7 +28,8 @@ static GLboolean MipMap = GL_FALSE;
 static GLboolean LinearFilter = GL_FALSE;
 static GLboolean RandomSize = GL_FALSE;
 static GLint Rows, Columns;
-static GLuint LowPriorityCount = 0;
+static GLint LowPriorityCount = 0;
+static GLint Win;
 
 
 static void Idle( void )
@@ -127,6 +128,14 @@ static int RandomInt(int min, int max)
 }
 
 
+static void DeleteTextures(void)
+{
+   glDeleteTextures(NumTextures, TextureID);
+   free(TextureID);
+   TextureID = NULL;
+}
+
+
 
 static void Init( void )
 {
@@ -230,7 +239,7 @@ static void Init( void )
          GLint level = 0;
          GLint w = TexWidth, h = TexHeight;
          while (1) {
-            glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,
+            glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w, h, 0,
                          GL_RGBA, GL_UNSIGNED_BYTE, texImage);
             if (w == 1 && h == 1)
                break;
@@ -305,9 +314,12 @@ static void Key( unsigned char key, int x, int y )
          Zrot += step;
          break;
       case ' ':
+         DeleteTextures();
          Init();
          break;
       case 27:
+         DeleteTextures();
+         glutDestroyWindow(Win);
          exit(0);
          break;
    }
@@ -323,7 +335,7 @@ int main( int argc, char *argv[] )
    glutInitWindowPosition( 0, 0 );
    glutInitWindowSize( WinWidth, WinHeight );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
-   glutCreateWindow(argv[0]);
+   Win = glutCreateWindow(argv[0]);
    glutReshapeFunc( Reshape );
    glutKeyboardFunc( Key );
    glutDisplayFunc( Display );