diff options
author | Keith Whitwell <[email protected]> | 2001-06-04 15:34:31 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-06-04 15:34:31 +0000 |
commit | abd5134965665ad9f7154a08b13edfed15f00135 (patch) | |
tree | 8f0ec0bb9e167410d3ef28a42f2af85e8d4d385f | |
parent | bd58a63fe891f6e42c71e8a8f2c8a7990b59eae8 (diff) |
fixed some GL_POINTS probs
-rw-r--r-- | progs/demos/isosurf.c | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c index 85fb7f215c7..2706ad9faef 100644 --- a/progs/demos/isosurf.c +++ b/progs/demos/isosurf.c @@ -1,4 +1,4 @@ -/* $Id: isosurf.c,v 1.11 2001/05/11 15:47:02 keithw Exp $ */ +/* $Id: isosurf.c,v 1.12 2001/06/04 15:34:31 keithw Exp $ */ /* * Display an isosurface of 3-D wind speed volume. @@ -449,15 +449,20 @@ static void draw_surface( int with_state ) break; case (DRAW_ARRAYS|POINTS): - glDrawArraysEXT( GL_POINTS, 0, numverts ); + glDrawArraysEXT( GL_POINTS, 0, numuniq ); break; case (DRAW_ELTS|POINTS): - glDrawElements( GL_POINTS, numverts, GL_UNSIGNED_INT, indices ); + /* can use numuniq with strip_indices as strip_indices[i] == i. + */ + glDrawElements( GL_POINTS, numuniq, + GL_UNSIGNED_INT, strip_indices ); break; case (ARRAY_ELT|POINTS): + /* just emit each unique element once: + */ glBegin( GL_POINTS ); - for (i = 0 ; i < numverts ; i++) - glArrayElement( indices[i] ); + for (i = 0 ; i < numuniq ; i++) + glArrayElement( i ); glEnd(); break; #endif @@ -487,10 +492,14 @@ static void draw_surface( int with_state ) break; case (GLVERTEX|POINTS): + /* Renders all points, but not in strip order... Shouldn't be a + * problem, but people may be confused as to why points are so + * much faster in this demo... And why cva doesn't help them... + */ glBegin( GL_POINTS ); - for ( i = 0 ; i < numverts ; i++ ) { - glNormal3fv( &data[i][3] ); - glVertex3fv( &data[i][0] ); + for ( i = 0 ; i < numuniq ; i++ ) { + glNormal3fv( &compressed_data[i][3] ); + glVertex3fv( &compressed_data[i][0] ); } glEnd(); break; @@ -713,24 +722,16 @@ static void ModeMenu(int m) print_flags("primitive", state & PRIMITIVE_MASK); print_flags("render style", state & RENDER_STYLE_MASK); - if ((state & PRIMITIVE_MASK) != TRIANGLES) - { - fprintf(stderr, "enabling normal arrays\n"); - glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numverts, data ); - glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numverts, &data[0][3]); -#ifdef GL_EXT_compiled_vertex_array - if (allowed & LOCKED) { - if (state & LOCKED) { - glLockArraysEXT( 0, numverts ); - } else { - glUnlockArraysEXT(); - } - } -#endif - } - else if ((state & RENDER_STYLE_MASK) != DRAW_ARRAYS) + if ((state & PRIMITIVE_MASK) != STRIPS && + ((state & RENDER_STYLE_MASK) == DRAW_ELTS || + (state & RENDER_STYLE_MASK) == ARRAY_ELT || + (state & PRIMITIVE_MASK) == POINTS)) { fprintf(stderr, "enabling small arrays\n"); + /* Rendering any primitive with draw-element/array-element + * --> Can't do strips here as ordering has been lost in + * compaction process... + */ glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numuniq, compressed_data ); glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numuniq, @@ -745,9 +746,10 @@ static void ModeMenu(int m) } #endif } - else { + else if ((state & PRIMITIVE_MASK) == TRIANGLES && + (state & RENDER_STYLE_MASK) == DRAW_ARRAYS) { fprintf(stderr, "enabling big arrays\n"); - /* Only get here for DRAW_ARRAYS + TRIANGLES + /* Only get here for TRIANGLES and drawarrays */ glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), (numverts-2) * 3, expanded_data ); @@ -764,6 +766,20 @@ static void ModeMenu(int m) } #endif } + else { + fprintf(stderr, "enabling normal arrays\n"); + glVertexPointerEXT( 3, GL_FLOAT, sizeof(data[0]), numverts, data ); + glNormalPointerEXT( GL_FLOAT, sizeof(data[0]), numverts, &data[0][3]); +#ifdef GL_EXT_compiled_vertex_array + if (allowed & LOCKED) { + if (state & LOCKED) { + glLockArraysEXT( 0, numverts ); + } else { + glUnlockArraysEXT(); + } + } +#endif + } } #endif |