X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=progs%2Fdemos%2Fisosurf.c;h=e280d8f507c553d2d4201cf9176b6ef4d8325950;hb=56cfa4de9150514af46d040c3cdb24def301b3a1;hp=85fb7f215c71d56e3cffcd79b34a06d5edd376a3;hpb=b8f9980999cb3619b3b60c089e6fa3b780a52292;p=mesa.git diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c index 85fb7f215c7..e280d8f507c 100644 --- a/progs/demos/isosurf.c +++ b/progs/demos/isosurf.c @@ -1,4 +1,3 @@ -/* $Id: isosurf.c,v 1.11 2001/05/11 15:47:02 keithw Exp $ */ /* * Display an isosurface of 3-D wind speed volume. @@ -30,40 +29,47 @@ #include #include #include -#define GL_GLEXT_LEGACY +#ifdef _WIN32 +#include +#undef CLIP_MASK +#endif +#include #include "GL/glut.h" -#include "readtex.c" /* I know, this is a hack. KW: me too. */ +#include "readtex.h" #define TEXTURE_FILE "../images/reflect.rgb" -#define LIT 0x1 -#define UNLIT 0x2 -#define REFLECT 0x10 -#define POINT_FILTER 0x40 -#define LINEAR_FILTER 0x80 -#define GLVERTEX 0x100 -#define DRAW_ELTS 0x4 -#define DRAW_ARRAYS 0x200 -#define ARRAY_ELT 0x400 -#define LOCKED 0x800 -#define UNLOCKED 0x8 -#define IMMEDIATE 0x1000 -#define DISPLAYLIST 0x2000000 -#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 GLINFO 0x4000000 -#define STIPPLE 0x8000000 -#define NO_STIPPLE 0x20 +#define LIT 0x00000001 +#define UNLIT 0x00000002 +#define REFLECT 0x00000004 +#define POINT_FILTER 0x00000008 +#define LINEAR_FILTER 0x00000010 +#define GLVERTEX 0x00000020 +#define DRAW_ELTS 0x00000040 +#define DRAW_ARRAYS 0x00000080 +#define ARRAY_ELT 0x00000100 +#define LOCKED 0x00000200 +#define UNLOCKED 0x00000400 +#define IMMEDIATE 0x00000800 +#define DISPLAYLIST 0x00001000 +#define SHADE_SMOOTH 0x00002000 +#define SHADE_FLAT 0x00004000 +#define TRIANGLES 0x00008000 +#define STRIPS 0x00010000 +#define POINTS 0x00020000 +#define USER_CLIP 0x00040000 +#define NO_USER_CLIP 0x00080000 +#define MATERIALS 0x00100000 +#define NO_MATERIALS 0x00200000 +#define FOG 0x00400000 +#define NO_FOG 0x00800000 +#define QUIT 0x01000000 +#define GLINFO 0x02000000 +#define STIPPLE 0x04000000 +#define NO_STIPPLE 0x08000000 +#define POLYGON_FILL 0x10000000 +#define POLYGON_LINE 0x20000000 +#define POLYGON_POINT 0x40000000 #define LIGHT_MASK (LIT|UNLIT|REFLECT) #define FILTER_MASK (POINT_FILTER|LINEAR_FILTER) @@ -76,9 +82,10 @@ #define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT) #define FOG_MASK (FOG|NO_FOG) #define STIPPLE_MASK (STIPPLE|NO_STIPPLE) +#define POLYGON_MASK (POLYGON_FILL|POLYGON_LINE|POLYGON_POINT) #define MAXVERTS 10000 -static GLuint maxverts = MAXVERTS; +static GLint maxverts = MAXVERTS; static float data[MAXVERTS][6]; static float compressed_data[MAXVERTS][6]; static float expanded_data[MAXVERTS*3][6]; @@ -141,7 +148,7 @@ static void read_surface( char *filename ) static void print_flags( const char *msg, GLuint flags ) { fprintf(stderr, - "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", + "%s (0x%x): %s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n", msg, flags, (flags & GLVERTEX) ? "glVertex, " : "", (flags & DRAW_ARRAYS) ? "glDrawArrays, " : "", @@ -159,7 +166,9 @@ static void print_flags( const char *msg, GLuint flags ) (flags & USER_CLIP) ? "user_clip, " : "", (flags & MATERIALS) ? "materials, " : "", (flags & FOG) ? "fog, " : "", - (flags & STIPPLE) ? "stipple, " : ""); + (flags & STIPPLE) ? "stipple, " : "", + (flags & POLYGON_LINE) ? "polygon mode line, " : "", + (flags & POLYGON_POINT) ? "polygon mode point, " : ""); } @@ -330,7 +339,7 @@ static void make_tri_indices( void ) { unsigned int *v = tri_indices; unsigned int parity = 0; - unsigned int i, j; + int i, j; for (j=2;j 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 +764,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 ); @@ -762,6 +782,20 @@ static void ModeMenu(int m) glUnlockArraysEXT(); } } +#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 } @@ -1004,7 +1038,6 @@ static GLint Args(int argc, char **argv) int main(int argc, char **argv) { GLenum type; - char *extensions; GLuint arg_mode = Args(argc, argv); @@ -1013,6 +1046,7 @@ int main(int argc, char **argv) read_surface( "isosurf.dat" ); + glutInit( &argc, argv); glutInitWindowPosition(0, 0); glutInitWindowSize(400, 400); @@ -1025,15 +1059,15 @@ int main(int argc, char **argv) exit(0); } - /* Make sure server supports the vertex array extension */ - extensions = (char *) glGetString( GL_EXTENSIONS ); + glewInit(); - if (!strstr( extensions, "GL_EXT_vertex_array" )) + /* Make sure server supports the vertex array extension */ + if (!GLEW_EXT_vertex_array) { printf("Vertex arrays not supported by this renderer\n"); allowed &= ~(LOCKED|DRAW_ARRAYS|DRAW_ELTS|ARRAY_ELT); } - else if (!strstr( extensions, "GL_EXT_compiled_vertex_array" )) + else if (!GLEW_EXT_compiled_vertex_array) { printf("Compiled vertex arrays not supported by this renderer\n"); allowed &= ~LOCKED; @@ -1058,6 +1092,10 @@ int main(int argc, char **argv) glutAddMenuEntry("Stipple", STIPPLE); glutAddMenuEntry("No Stipple", NO_STIPPLE); glutAddMenuEntry("", 0); + glutAddMenuEntry("Polygon Mode Fill", POLYGON_FILL); + glutAddMenuEntry("Polygon Mode Line", POLYGON_LINE); + glutAddMenuEntry("Polygon Mode Points", POLYGON_POINT); + glutAddMenuEntry("", 0); glutAddMenuEntry("Point Filtered", POINT_FILTER); glutAddMenuEntry("Linear Filtered", LINEAR_FILTER); glutAddMenuEntry("", 0);