i965: add support for ARB_half_float_vertex
[mesa.git] / progs / demos / ipers.c
index 029de000898b5722b01a9932875b1b9e2d724be9..265378b90a9b883b4c2770c165859ca5a84c8cad 100644 (file)
@@ -9,16 +9,16 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
-#include <time.h>
+#include <string.h>
 
-#ifdef WIN32
+#if defined (WIN32)|| defined(_WIN32)
 #include <windows.h>
 #include <mmsystem.h>
 #endif
 
 #include <GL/glut.h>
 
-#include "readtex.c"
+#include "readtex.h"
 
 #ifdef XMESA
 #include "GL/xmesa.h"
@@ -133,6 +133,8 @@ initdlists(void)
 
       glEndList();
    }
+
+   gluDeleteQuadric(obj);
 }
 
 static void
@@ -186,7 +188,7 @@ inittextures(void)
        (gluerr =
        gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TEX_SKY_WIDTH, TEX_SKY_HEIGHT,
                          GL_RGB, GL_UNSIGNED_BYTE, (GLvoid *) (tsky)))) {
-      fprintf(stderr, "GLULib%s\n", gluErrorString(gluerr));
+      fprintf(stderr, "GLULib%s\n", (char *) gluErrorString(gluerr));
       exit(-1);
    }
 
@@ -236,11 +238,28 @@ special(int k, int x, int y)
    }
 }
 
+static void
+cleanup(void)
+{
+   int i;
+
+   glDeleteTextures(1, &t1id);
+   glDeleteTextures(1, &t2id);
+
+   glDeleteLists(skydlist, 1);
+   for (i = 0; i < MAX_LOD; i++) {
+      glDeleteLists(LODdlist[i], 1);
+      glDeleteLists(LODnumpoly[i], 1);
+   }
+}
+
+
 static void
 key(unsigned char k, int x, int y)
 {
    switch (k) {
    case 27:
+      cleanup();
       exit(0);
       break;
 
@@ -357,7 +376,7 @@ printhelp(void)
    printstring(GLUT_BITMAP_TIMES_ROMAN_24, "p - Toggle Wire frame");
    glRasterPos2i(60, 150);
    printstring(GLUT_BITMAP_TIMES_ROMAN_24,
-              "b - Toggle GL_EXT_rescale_normal extension");
+              "n - Toggle GL_EXT_rescale_normal extension");
    glRasterPos2i(60, 120);
    printstring(GLUT_BITMAP_TIMES_ROMAN_24,
               "+/- - Increase/decrease the Object maximum LOD");
@@ -543,6 +562,12 @@ draw(void)
    static GLfloat alpha = 0.0f;
    static GLfloat beta = 0.0f;
    static float fr = 0.0;
+   static double t0 = -1.;
+   double dt, t = glutGet(GLUT_ELAPSED_TIME) / 1000.0;
+   if (t0 < 0.0)
+      t0 = t;
+   dt = t - t0;
+   t0 = t;
 
    dojoy();
 
@@ -586,8 +611,8 @@ draw(void)
    drawipers(0, FROM_NONE);
    glPopMatrix();
 
-   alpha += 0.5f;
-   beta += 0.3f;
+   alpha += 4.f * dt;
+   beta += 2.4f * dt;
 
    glDisable(GL_LIGHTING);
    glDisable(GL_LIGHT0);
@@ -657,7 +682,6 @@ main(int ac, char **av)
    fprintf(stderr,
           "IperS V1.0\nWritten by David Bucciarelli (tech.hmw@plus.it)\n");
 
-   glutInitWindowPosition(0, 0);
    glutInitWindowSize(WIDTH, HEIGHT);
    glutInit(&ac, av);
 
@@ -701,6 +725,7 @@ main(int ac, char **av)
    glutIdleFunc(draw);
 
    glutMainLoop();
+   cleanup();
 
    return 0;
 }