progs/tests: compile with SCons and glew
[mesa.git] / progs / tests / antialias.c
index 3a83c34b8d085f89b083eb84c03b74a70722789e..656bf2471fe3df76cfbd46b5a2b658968a1f7b18 100644 (file)
@@ -9,12 +9,14 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <math.h>
+#include <GL/glew.h>
 #include <GL/glut.h>
 
 
 static GLfloat Zrot = 0;
 static GLboolean Anim = GL_TRUE;
 static GLboolean HaveMultisample = GL_TRUE;
+static GLboolean DoMultisample = GL_TRUE;
 
 
 static void
@@ -28,7 +30,7 @@ PrintString(const char *s)
 
 
 static void
-Polygon( GLint verts, GLfloat radius, GLfloat z )
+doPolygon( GLint verts, GLfloat radius, GLfloat z )
 {
    int i;
    for (i = 0; i < verts; i++) {
@@ -46,33 +48,33 @@ DrawObject( void )
    glLineWidth(3.0);
    glColor3f(1, 1, 1);
    glBegin(GL_LINE_LOOP);
-   Polygon(12, 1.2, 0);
+   doPolygon(12, 1.2, 0);
    glEnd();
 
    glLineWidth(1.0);
    glColor3f(1, 1, 1);
    glBegin(GL_LINE_LOOP);
-   Polygon(12, 1.1, 0);
+   doPolygon(12, 1.1, 0);
    glEnd();
 
    glColor3f(1, 0, 0);
    glBegin(GL_POLYGON);
-   Polygon(12, 0.4, 0.3);
+   doPolygon(12, 0.4, 0.3);
    glEnd();
 
    glColor3f(0, 1, 0);
    glBegin(GL_POLYGON);
-   Polygon(12, 0.6, 0.2);
+   doPolygon(12, 0.6, 0.2);
    glEnd();
 
    glColor3f(0, 0, 1);
    glBegin(GL_POLYGON);
-   Polygon(12, 0.8, 0.1);
+   doPolygon(12, 0.8, 0.1);
    glEnd();
 
    glColor3f(1, 1, 1);
    glBegin(GL_POLYGON);
-   Polygon(12, 1.0, 0);
+   doPolygon(12, 1.0, 0);
    glEnd();
 }
 
@@ -85,7 +87,10 @@ Display( void )
    glColor3f(1, 1, 1);
    if (HaveMultisample) {
       glRasterPos2f(-3.1, -1.6);
-      PrintString("MULTISAMPLE");
+      if (DoMultisample)
+         PrintString("MULTISAMPLE");
+      else
+         PrintString("MULTISAMPLE (off)");
    }
    glRasterPos2f(-0.8, -1.6);
    PrintString("No antialiasing");
@@ -95,7 +100,8 @@ Display( void )
    /* multisample */
    if (HaveMultisample) {
       glEnable(GL_DEPTH_TEST);
-      glEnable(GL_MULTISAMPLE_ARB);
+      if (DoMultisample)
+         glEnable(GL_MULTISAMPLE_ARB);
       glPushMatrix();
       glTranslatef(-2.5, 0, 0);
       glPushMatrix();
@@ -172,6 +178,9 @@ Key( unsigned char key, int x, int y )
          else
             glutIdleFunc(NULL);
          break;
+      case 'm':
+         DoMultisample = !DoMultisample;
+         break;
       case 'z':
          Zrot = (int) (Zrot - step);
          break;
@@ -217,6 +226,7 @@ main( int argc, char *argv[] )
    glutInitDisplayMode( GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE |
                         GLUT_DEPTH | GLUT_MULTISAMPLE );
    glutCreateWindow(argv[0]);
+   glewInit();
    glutReshapeFunc( Reshape );
    glutKeyboardFunc( Key );
    glutDisplayFunc( Display );