From c85164605031cd64afbc57ca5ab1331377af887b Mon Sep 17 00:00:00 2001 From: Gareth Hughes Date: Sat, 6 Jan 2001 20:38:03 +0000 Subject: Add GL_POINTS as a primitive, including with CVA DrawElements. Useful for testing non-triangle primitives on hardware driver fastpaths. --- progs/demos/isosurf.c | 323 +++++++++++++++++++++++++++----------------------- 1 file changed, 177 insertions(+), 146 deletions(-) diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c index d5b0ceb500..9c78a47490 100644 --- a/progs/demos/isosurf.c +++ b/progs/demos/isosurf.c @@ -1,7 +1,7 @@ -/* $Id: isosurf.c,v 1.7 2000/12/24 22:53:54 pesco Exp $ */ +/* $Id: isosurf.c,v 1.8 2001/01/06 20:38:03 gareth Exp $ */ /* - * Display an isosurface of 3-D wind speed volume. + * Display an isosurface of 3-D wind speed volume. * * Command line options: * -info print GL implementation information @@ -36,47 +36,48 @@ #include "readtex.c" /* I know, this is a hack. KW: me too. */ #define TEXTURE_FILE "../images/reflect.rgb" -#define LIT 0x1 -#define UNLIT 0x2 -#define TEXTURE 0x4 -#define NO_TEXTURE 0x8 -#define REFLECT 0x10 -#define NO_REFLECT 0x20 -#define POINT_FILTER 0x40 -#define LINEAR_FILTER 0x80 -#define GLVERTEX 0x100 -#define DRAW_ARRAYS 0x200 /* or draw_elts, if compiled */ -#define ARRAY_ELT 0x400 -#define COMPILED 0x800 -#define IMMEDIATE 0x1000 -#define SHADE_SMOOTH 0x2000 -#define SHADE_FLAT 0x4000 -#define TRIANGLES 0x8000 -#define STRIPS 0x10000 -#define USER_CLIP 0x20000 -#define NO_USER_CLIP 0x40000 -#define MATERIALS 0x80000 -#define NO_MATERIALS 0x100000 -#define FOG 0x200000 -#define NO_FOG 0x400000 -#define QUIT 0x800000 -#define DISPLAYLIST 0x1000000 -#define GLINFO 0x2000000 -#define STIPPLE 0x4000000 -#define NO_STIPPLE 0x8000000 - -#define LIGHT_MASK (LIT|UNLIT) -#define TEXTURE_MASK (TEXTURE|NO_TEXTURE) -#define REFLECT_MASK (REFLECT|NO_REFLECT) -#define FILTER_MASK (POINT_FILTER|LINEAR_FILTER) -#define RENDER_STYLE_MASK (GLVERTEX|DRAW_ARRAYS|ARRAY_ELT) -#define COMPILED_MASK (COMPILED|IMMEDIATE|DISPLAYLIST) -#define MATERIAL_MASK (MATERIALS|NO_MATERIALS) -#define PRIMITIVE_MASK (TRIANGLES|STRIPS) -#define CLIP_MASK (USER_CLIP|NO_USER_CLIP) -#define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT) -#define FOG_MASK (FOG|NO_FOG) -#define STIPPLE_MASK (STIPPLE|NO_STIPPLE) +#define LIT 0x1 +#define UNLIT 0x2 +#define TEXTURE 0x4 +#define NO_TEXTURE 0x8 +#define REFLECT 0x10 +#define NO_REFLECT 0x20 +#define POINT_FILTER 0x40 +#define LINEAR_FILTER 0x80 +#define GLVERTEX 0x100 +#define DRAW_ARRAYS 0x200 /* or draw_elts, if compiled */ +#define ARRAY_ELT 0x400 +#define COMPILED 0x800 +#define IMMEDIATE 0x1000 +#define SHADE_SMOOTH 0x2000 +#define SHADE_FLAT 0x4000 +#define TRIANGLES 0x8000 +#define STRIPS 0x10000 +#define POINTS 0x20000 +#define USER_CLIP 0x40000 +#define NO_USER_CLIP 0x80000 +#define MATERIALS 0x100000 +#define NO_MATERIALS 0x200000 +#define FOG 0x400000 +#define NO_FOG 0x800000 +#define QUIT 0x1000000 +#define DISPLAYLIST 0x2000000 +#define GLINFO 0x4000000 +#define STIPPLE 0x8000000 +#define NO_STIPPLE 0x10000000 + +#define LIGHT_MASK (LIT|UNLIT) +#define TEXTURE_MASK (TEXTURE|NO_TEXTURE) +#define REFLECT_MASK (REFLECT|NO_REFLECT) +#define FILTER_MASK (POINT_FILTER|LINEAR_FILTER) +#define RENDER_STYLE_MASK (GLVERTEX|DRAW_ARRAYS|ARRAY_ELT) +#define COMPILED_MASK (COMPILED|IMMEDIATE|DISPLAYLIST) +#define MATERIAL_MASK (MATERIALS|NO_MATERIALS) +#define PRIMITIVE_MASK (TRIANGLES|STRIPS|POINTS) +#define CLIP_MASK (USER_CLIP|NO_USER_CLIP) +#define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT) +#define FOG_MASK (FOG|NO_FOG) +#define STIPPLE_MASK (STIPPLE|NO_STIPPLE) #define MAXVERTS 10000 static float data[MAXVERTS][6]; @@ -180,7 +181,7 @@ int (*(compare[7]))( const void *a, const void *b ) = #define VEC_ELT(f, s, i) (float *)(((char *)f) + s * i) -static int sort_axis( int axis, +static int sort_axis( int axis, int vec_size, int vec_stride, struct data_idx *indices, @@ -192,27 +193,27 @@ static int sort_axis( int axis, { int i; - if (finish-start > 2) + if (finish-start > 2) { qsort( indices+start, finish-start, sizeof(*indices), compare[axis] ); - } - else if (indices[start].data[axis] > indices[start+1].data[axis]) + } + else if (indices[start].data[axis] > indices[start+1].data[axis]) { struct data_idx tmp = indices[start]; indices[start] = indices[start+1]; indices[start+1] = tmp; } - + if (axis == vec_size-1) { for (i = start ; i < finish ; ) { float max = indices[i].data[axis] + fudge; float *dest = VEC_ELT(out, vec_stride, uniq); int j; - + for (j = 0 ; j < vec_size ; j++) dest[j] = indices[i].data[j]; - for ( ; i < finish && max >= indices[i].data[axis]; i++) + for ( ; i < finish && max >= indices[i].data[axis]; i++) indices[i].uniq_idx = uniq; uniq++; @@ -227,7 +228,7 @@ static int sort_axis( int axis, int k; indices[i].uniq_idx = uniq; - + for (k = 0 ; k < vec_size ; k++) dest[k] = indices[i].data[k]; @@ -244,7 +245,7 @@ static int sort_axis( int axis, } -static void extract_indices1( const struct data_idx *in, unsigned int *out, +static void extract_indices1( const struct data_idx *in, unsigned int *out, int n ) { int i; @@ -266,13 +267,13 @@ static void compactify_arrays(void) ind[i].data = data[i]; } - numuniq = sort_axis(0, - sizeof(compressed_data[0])/sizeof(float), + numuniq = sort_axis(0, + sizeof(compressed_data[0])/sizeof(float), sizeof(compressed_data[0]), - ind, - 0, - numverts, - (float *)compressed_data, + ind, + 0, + numverts, + (float *)compressed_data, 0, 1e-6); @@ -297,7 +298,7 @@ static void make_tri_indices( void ) for (j=2;j