-/* $Id: isosurf.c,v 1.8 2001/01/06 20:38:03 gareth Exp $ */
+/* $Id: isosurf.c,v 1.9 2001/04/19 13:12:40 keithw Exp $ */
/*
* Display an isosurface of 3-D wind speed volume.
#define STIPPLE_MASK (STIPPLE|NO_STIPPLE)
#define MAXVERTS 10000
+static GLuint maxverts = MAXVERTS;
static float data[MAXVERTS][6];
static float compressed_data[MAXVERTS][6];
static GLuint indices[MAXVERTS];
static GLint state, allowed = ~0;
static GLboolean doubleBuffer = GL_TRUE;
static GLdouble plane[4] = {1.0, 0.0, -1.0, 0.0};
-static GLuint surf1;
+static GLuint surf1, surf2, surf3;
static GLboolean PrintInfo = GL_FALSE;
0xAA, 0xAA, 0xAA, 0xAA, 0x55, 0x55, 0x55, 0x55};
/* forward decl */
-int BuildList( int mode );
+int BuildVertexList( int mode );
+int BuildArrayEltList( int mode );
+int BuildDrawArraysList( int mode );
static void read_surface( char *filename )
}
numverts = 0;
- while (!feof(f) && numverts<MAXVERTS) {
+ while (!feof(f) && numverts<maxverts) {
fscanf( f, "%f %f %f %f %f %f",
&data[numverts][0], &data[numverts][1], &data[numverts][2],
&data[numverts][3], &data[numverts][4], &data[numverts][5] );
break;
case (DISPLAYLIST|GLVERTEX|STRIPS):
- if (!surf1)
- surf1 = BuildList( GL_COMPILE_AND_EXECUTE );
- else
- glCallList(surf1);
+ glCallList(surf1);
+ break;
+ case (DISPLAYLIST|ARRAY_ELT|STRIPS):
+ glCallList(surf2);
+ break;
+ case (DISPLAYLIST|DRAW_ARRAYS|STRIPS):
+ glCallList(surf3);
break;
if (doubleBuffer) glutSwapBuffers();
}
-int BuildList( int mode )
+int BuildVertexList( int mode )
{
int rv = glGenLists(1);
glNewList(rv, mode );
return rv;
}
+int BuildArrayEltList( int mode )
+{
+ int rv = glGenLists(1);
+ glNewList(rv, mode );
+ draw_surface( IMMEDIATE|ARRAY_ELT|STRIPS );
+ glEndList();
+ return rv;
+}
+
+int BuildDrawArraysList( int mode )
+{
+ int rv = glGenLists(1);
+ glNewList(rv, mode );
+ draw_surface( IMMEDIATE|DRAW_ARRAYS|STRIPS );
+ glEndList();
+ return rv;
+}
+
/* KW: only do this when necessary, so CVA can re-use results.
*/
static void set_matrix( void )
compactify_arrays();
make_tri_indices();
- surf1 = BuildList( GL_COMPILE );
-
ModeMenu(SHADE_SMOOTH|
LIT|
NO_TEXTURE|
NO_STIPPLE|
GLVERTEX);
+ surf1 = BuildVertexList( GL_COMPILE );
+ surf2 = BuildArrayEltList( GL_COMPILE );
+ surf3 = BuildDrawArraysList( GL_COMPILE );
+
if (PrintInfo) {
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
else if (strcmp(argv[i], "-info") == 0) {
PrintInfo = GL_TRUE;
}
+ else if (strcmp(argv[i], "-10") == 0) {
+ maxverts = 10;
+ }
+ else if (strcmp(argv[i], "-100") == 0) {
+ maxverts = 100;
+ }
+ else if (strcmp(argv[i], "-1000") == 0) {
+ maxverts = 1000;
+ }
else {
printf("%s (Bad option).\n", argv[i]);
return QUIT;
glutAddMenuEntry("", 0);
glutAddMenuEntry("glVertex display list (STRIPS)",
DISPLAYLIST|GLVERTEX|STRIPS);
+ glutAddMenuEntry("glArrayElement display list (STRIPS)",
+ DISPLAYLIST|GLVERTEX|STRIPS);
+ glutAddMenuEntry("glDrawArrays display list (STRIPS)",
+ DISPLAYLIST|GLVERTEX|STRIPS);
glutAddMenuEntry("", 0);
if (allowed & DRAW_ARRAYS) {
glutAddMenuEntry("DrawElements (TRIANGLES)",