1 /* $Id: isosurf.c,v 1.4 1999/10/21 16:39:06 brianp Exp $ */
4 * Display an isosurface of 3-D wind speed volume.
6 * Command line options:
7 * -info print GL implementation information
9 * Brian Paul This file in public domain.
16 * - Arrow keys to rotate
17 * - 's' toggles smooth shading
18 * - 'l' toggles lighting
20 * - 'I' and 'i' zoom in and out
21 * - 'c' toggles a user clip plane
22 * - 'm' toggles colorful materials in GL_TRIANGLES modes.
23 * - '+' and '-' move the user clip plane
25 * Other options are available via the popup menu.
30 * Revision 1.4 1999/10/21 16:39:06 brianp
31 * added -info command line option
33 * Revision 1.3 1999/09/08 22:14:31 brianp
34 * minor changes. always call compactify_arrays()
36 * Revision 1.2 1999/09/03 14:56:40 keithw
37 * Fog, displaylist and zoom operations
39 * Revision 3.4 1999/04/24 01:10:47 keithw
40 * clip planes, materials
42 * Revision 3.3 1999/03/31 19:42:14 keithw
45 * Revision 3.1 1998/11/01 20:30:20 brianp
46 * added benchmark feature (b key)
48 * Revision 3.0 1998/02/14 18:42:29 brianp
62 #include "../util/readtex.c" /* I know, this is a hack. KW: me too. */
63 #define TEXTURE_FILE "../images/reflect.rgb"
68 #define NO_TEXTURE 0x8
70 #define NO_REFLECT 0x20
71 #define POINT_FILTER 0x40
72 #define LINEAR_FILTER 0x80
73 #define GLVERTEX 0x100
74 #define DRAW_ARRAYS 0x200 /* or draw_elts, if compiled */
75 #define ARRAY_ELT 0x400
76 #define COMPILED 0x800
77 #define IMMEDIATE 0x1000
78 #define SHADE_SMOOTH 0x2000
79 #define SHADE_FLAT 0x4000
80 #define TRIANGLES 0x8000
81 #define STRIPS 0x10000
82 #define USER_CLIP 0x20000
83 #define NO_USER_CLIP 0x40000
84 #define MATERIALS 0x80000
85 #define NO_MATERIALS 0x100000
87 #define NO_FOG 0x400000
89 #define DISPLAYLIST 0x1000000
91 #define LIGHT_MASK (LIT|UNLIT)
92 #define TEXTURE_MASK (TEXTURE|NO_TEXTURE)
93 #define REFLECT_MASK (REFLECT|NO_REFLECT)
94 #define FILTER_MASK (POINT_FILTER|LINEAR_FILTER)
95 #define RENDER_STYLE_MASK (GLVERTEX|DRAW_ARRAYS|ARRAY_ELT)
96 #define COMPILED_MASK (COMPILED|IMMEDIATE|DISPLAYLIST)
97 #define MATERIAL_MASK (MATERIALS|NO_MATERIALS)
98 #define PRIMITIVE_MASK (TRIANGLES|STRIPS)
99 #define CLIP_MASK (USER_CLIP|NO_USER_CLIP)
100 #define SHADE_MASK (SHADE_SMOOTH|SHADE_FLAT)
101 #define FOG_MASK (FOG|NO_FOG)
103 #define MAXVERTS 10000
104 static float data
[MAXVERTS
][6];
105 static float compressed_data
[MAXVERTS
][6];
106 static GLuint indices
[MAXVERTS
];
107 static GLuint tri_indices
[MAXVERTS
*3];
108 static GLfloat col
[100][4];
109 static GLint numverts
, num_tri_verts
, numuniq
;
113 static GLfloat dist
= -6;
114 static GLint state
, allowed
= ~0;
115 static GLboolean doubleBuffer
= GL_TRUE
;
116 static GLdouble plane
[4] = {1.0, 0.0, -1.0, 0.0};
119 static GLboolean PrintInfo
= GL_FALSE
;
122 int BuildList( int mode
);
125 static void read_surface( char *filename
)
129 f
= fopen(filename
,"r");
131 printf("couldn't read %s\n", filename
);
136 while (!feof(f
) && numverts
<MAXVERTS
) {
137 fscanf( f
, "%f %f %f %f %f %f",
138 &data
[numverts
][0], &data
[numverts
][1], &data
[numverts
][2],
139 &data
[numverts
][3], &data
[numverts
][4], &data
[numverts
][5] );
144 printf("%d vertices, %d triangles\n", numverts
, numverts
-2);
158 #define COMPARE_FUNC( AXIS ) \
159 static int compare_axis_##AXIS( const void *a, const void *b ) \
161 float t = ( (*(struct data_idx *)a).data[AXIS] - \
162 (*(struct data_idx *)b).data[AXIS] ); \
164 if (t < 0) return -1; \
165 if (t > 0) return 1; \
177 int (*(compare
[7]))( const void *a
, const void *b
) =
189 #define VEC_ELT(f, s, i) (float *)(((char *)f) + s * i)
191 static int sort_axis( int axis
,
194 struct data_idx
*indices
,
203 if (finish
-start
> 2)
205 qsort( indices
+start
, finish
-start
, sizeof(*indices
), compare
[axis
] );
207 else if (indices
[start
].data
[axis
] > indices
[start
+1].data
[axis
])
209 struct data_idx tmp
= indices
[start
];
210 indices
[start
] = indices
[start
+1];
211 indices
[start
+1] = tmp
;
214 if (axis
== vec_size
-1) {
215 for (i
= start
; i
< finish
; ) {
216 float max
= indices
[i
].data
[axis
] + fudge
;
217 float *dest
= VEC_ELT(out
, vec_stride
, uniq
);
220 for (j
= 0 ; j
< vec_size
; j
++)
221 dest
[j
] = indices
[i
].data
[j
];
223 for ( ; i
< finish
&& max
>= indices
[i
].data
[axis
]; i
++)
224 indices
[i
].uniq_idx
= uniq
;
229 for (i
= start
; i
< finish
; ) {
231 float max
= indices
[i
].data
[axis
] + fudge
;
232 while (j
< finish
&& max
>= indices
[j
].data
[axis
]) j
++;
234 float *dest
= VEC_ELT(out
, vec_stride
, uniq
);
237 indices
[i
].uniq_idx
= uniq
;
239 for (k
= 0 ; k
< vec_size
; k
++)
240 dest
[k
] = indices
[i
].data
[k
];
244 uniq
= sort_axis( axis
+1, vec_size
, vec_stride
,
245 indices
, i
, j
, out
, uniq
, fudge
);
255 static void extract_indices1( const struct data_idx
*in
, unsigned int *out
,
259 for ( i
= 0 ; i
< n
; i
++ ) {
260 out
[in
[i
].idx
] = in
[i
].uniq_idx
;
265 static void compactify_arrays(void)
268 struct data_idx
*ind
;
270 ind
= (struct data_idx
*) malloc( sizeof(struct data_idx
) * numverts
);
272 for (i
= 0 ; i
< numverts
; i
++) {
274 ind
[i
].data
= data
[i
];
277 numuniq
= sort_axis(0,
278 sizeof(compressed_data
[0])/sizeof(float),
279 sizeof(compressed_data
[0]),
283 (float *)compressed_data
,
287 printf("Nr unique vertex/normal pairs: %d\n", numuniq
);
289 extract_indices1( ind
, indices
, numverts
);
293 static float myrand( float max
)
295 return max
*rand()/(RAND_MAX
+1.0);
299 static void make_tri_indices( void )
301 unsigned int *v
= tri_indices
;
302 unsigned int parity
= 0;
305 for (j
=2;j
<numverts
;j
++,parity
^=1) {
317 num_tri_verts
= v
- tri_indices
;
318 printf("num_tri_verts: %d\n", num_tri_verts
);
320 for (i
= j
= 0 ; i
< num_tri_verts
; i
+= 600, j
++) {
322 col
[j
][2] = myrand(1);
323 col
[j
][1] = myrand(1);
324 col
[j
][0] = myrand(1);
328 #define MIN(x,y) (x < y) ? x : y
330 static void draw_surface( int with_state
)
334 switch (with_state
& (COMPILED_MASK
|RENDER_STYLE_MASK
|PRIMITIVE_MASK
)) {
335 #ifdef GL_EXT_vertex_array
337 case (COMPILED
|DRAW_ARRAYS
|STRIPS
):
338 glDrawElements( GL_TRIANGLE_STRIP
, numverts
, GL_UNSIGNED_INT
, indices
);
342 case (COMPILED
|ARRAY_ELT
|STRIPS
):
343 glBegin( GL_TRIANGLE_STRIP
);
344 for (i
= 0 ; i
< numverts
; i
++)
345 glArrayElement( indices
[i
] );
349 case (COMPILED
|DRAW_ARRAYS
|TRIANGLES
):
350 case (IMMEDIATE
|DRAW_ARRAYS
|TRIANGLES
):
351 if (with_state
& MATERIALS
) {
352 for (j
= i
= 0 ; i
< num_tri_verts
; i
+= 600, j
++) {
353 GLuint nr
= MIN(num_tri_verts
-i
, 600);
354 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, col
[j
]);
355 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, col
[j
]);
356 glDrawElements( GL_TRIANGLES
, nr
, GL_UNSIGNED_INT
, tri_indices
+i
);
359 glDrawElements( GL_TRIANGLES
, num_tri_verts
, GL_UNSIGNED_INT
,
365 /* Uses the original arrays (including duplicate elements):
367 case (IMMEDIATE
|DRAW_ARRAYS
|STRIPS
):
368 glDrawArraysEXT( GL_TRIANGLE_STRIP
, 0, numverts
);
371 /* Uses the original arrays (including duplicate elements):
373 case (IMMEDIATE
|ARRAY_ELT
|STRIPS
):
374 glBegin( GL_TRIANGLE_STRIP
);
375 for (i
= 0 ; i
< numverts
; i
++)
380 case (IMMEDIATE
|ARRAY_ELT
|TRIANGLES
):
381 case (COMPILED
|ARRAY_ELT
|TRIANGLES
):
382 if (with_state
& MATERIALS
) {
383 for (j
= i
= 0 ; i
< num_tri_verts
; i
+= 600, j
++) {
384 GLuint nr
= MIN(num_tri_verts
-i
, 600);
386 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, col
[j
]);
387 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, col
[j
]);
388 glBegin( GL_TRIANGLES
);
389 for (k
= 0 ; k
< nr
; k
++)
390 glArrayElement( tri_indices
[i
+k
] );
394 glBegin( GL_TRIANGLES
);
395 for (i
= 0 ; i
< num_tri_verts
; i
++)
396 glArrayElement( tri_indices
[i
] );
402 case (IMMEDIATE
|GLVERTEX
|TRIANGLES
):
403 if (with_state
& MATERIALS
) {
404 for (j
= i
= 0 ; i
< num_tri_verts
; i
+= 600, j
++) {
405 GLuint nr
= MIN(num_tri_verts
-i
, 600);
407 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, col
[j
]);
408 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, col
[j
]);
409 glBegin( GL_TRIANGLES
);
410 for (k
= 0 ; k
< nr
; k
++) {
411 glNormal3fv( &compressed_data
[tri_indices
[i
+k
]][3] );
412 glVertex3fv( &compressed_data
[tri_indices
[i
+k
]][0] );
417 glBegin( GL_TRIANGLES
);
418 for (i
= 0 ; i
< num_tri_verts
; i
++) {
419 glNormal3fv( &compressed_data
[tri_indices
[i
]][3] );
420 glVertex3fv( &compressed_data
[tri_indices
[i
]][0] );
426 case (DISPLAYLIST
|GLVERTEX
|STRIPS
):
428 surf1
= BuildList( GL_COMPILE_AND_EXECUTE
);
435 /* Uses the original arrays (including duplicate elements):
438 glBegin( GL_TRIANGLE_STRIP
);
439 for (i
=0;i
<numverts
;i
++) {
440 glNormal3fv( &data
[i
][3] );
441 glVertex3fv( &data
[i
][0] );
449 static void Display(void)
451 glClear( GL_COLOR_BUFFER_BIT
| GL_DEPTH_BUFFER_BIT
);
452 draw_surface( state
);
454 if (doubleBuffer
) glutSwapBuffers();
457 int BuildList( int mode
)
459 int rv
= glGenLists(1);
460 glNewList(rv
, mode
);
461 draw_surface( IMMEDIATE
|GLVERTEX
|STRIPS
);
466 /* KW: only do this when necessary, so CVA can re-use results.
468 static void set_matrix( void )
470 glMatrixMode(GL_MODELVIEW
);
472 glTranslatef( 0.0, 0.0, dist
);
473 glRotatef( yrot
, 0.0, 1.0, 0.0 );
474 glRotatef( xrot
, 1.0, 0.0, 0.0 );
477 static void Benchmark( float xdiff
, float ydiff
)
479 int startTime
, endTime
;
481 double seconds
, fps
, triPerSecond
;
483 printf("Benchmarking...\n");
486 startTime
= glutGet(GLUT_ELAPSED_TIME
);
494 endTime
= glutGet(GLUT_ELAPSED_TIME
);
495 } while (endTime
- startTime
< 5000); /* 5 seconds */
498 seconds
= (double) (endTime
- startTime
) / 1000.0;
499 triPerSecond
= (numverts
- 2) * draws
/ seconds
;
500 fps
= draws
/ seconds
;
501 printf("Result: triangles/sec: %g fps: %g\n", triPerSecond
, fps
);
505 static void InitMaterials(void)
507 static float ambient
[] = {0.1, 0.1, 0.1, 1.0};
508 static float diffuse
[] = {0.5, 1.0, 1.0, 1.0};
509 static float position0
[] = {0.0, 0.0, 20.0, 0.0};
510 static float position1
[] = {0.0, 0.0, -20.0, 0.0};
511 static float front_mat_shininess
[] = {60.0};
512 static float front_mat_specular
[] = {0.2, 0.2, 0.2, 1.0};
513 static float front_mat_diffuse
[] = {0.5, 0.28, 0.38, 1.0};
515 static float back_mat_shininess[] = {60.0};
516 static float back_mat_specular[] = {0.5, 0.5, 0.2, 1.0};
517 static float back_mat_diffuse[] = {1.0, 1.0, 0.2, 1.0};
519 static float lmodel_ambient
[] = {1.0, 1.0, 1.0, 1.0};
520 static float lmodel_twoside
[] = {GL_FALSE
};
522 glLightfv(GL_LIGHT0
, GL_AMBIENT
, ambient
);
523 glLightfv(GL_LIGHT0
, GL_DIFFUSE
, diffuse
);
524 glLightfv(GL_LIGHT0
, GL_POSITION
, position0
);
527 glLightfv(GL_LIGHT1
, GL_AMBIENT
, ambient
);
528 glLightfv(GL_LIGHT1
, GL_DIFFUSE
, diffuse
);
529 glLightfv(GL_LIGHT1
, GL_POSITION
, position1
);
532 glLightModelfv(GL_LIGHT_MODEL_AMBIENT
, lmodel_ambient
);
533 glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE
, lmodel_twoside
);
535 glMaterialfv(GL_FRONT_AND_BACK
, GL_SHININESS
, front_mat_shininess
);
536 glMaterialfv(GL_FRONT_AND_BACK
, GL_SPECULAR
, front_mat_specular
);
537 glMaterialfv(GL_FRONT_AND_BACK
, GL_DIFFUSE
, front_mat_diffuse
);
542 #define UPDATE(o,n,mask) (o&=~mask, o|=n&mask)
543 #define CHANGED(o,n,mask) ((n&mask) && \
544 (n&mask) != (o&mask) ? UPDATE(o,n,mask) : 0)
546 static void ModeMenu(int m
)
555 if (CHANGED(state
, m
, FILTER_MASK
)) {
556 if (m
& LINEAR_FILTER
) {
557 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_LINEAR
);
558 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_LINEAR
);
560 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MIN_FILTER
, GL_NEAREST
);
561 glTexParameteri(GL_TEXTURE_2D
, GL_TEXTURE_MAG_FILTER
, GL_NEAREST
);
565 if (CHANGED(state
, m
, LIGHT_MASK
)) {
567 glEnable(GL_LIGHTING
);
569 glDisable(GL_LIGHTING
);
572 if (CHANGED(state
, m
, SHADE_MASK
)) {
573 if (m
& SHADE_SMOOTH
)
574 glShadeModel(GL_SMOOTH
);
576 glShadeModel(GL_FLAT
);
580 if (CHANGED(state
, m
, TEXTURE_MASK
)) {
582 glEnable(GL_TEXTURE_2D
);
584 glDisable(GL_TEXTURE_2D
);
587 if (CHANGED(state
, m
, REFLECT_MASK
)) {
589 glEnable(GL_TEXTURE_GEN_S
);
590 glEnable(GL_TEXTURE_GEN_T
);
592 glDisable(GL_TEXTURE_GEN_S
);
593 glDisable(GL_TEXTURE_GEN_T
);
597 if (CHANGED(state
, m
, CLIP_MASK
)) {
599 glEnable(GL_CLIP_PLANE0
);
601 glDisable(GL_CLIP_PLANE0
);
605 if (CHANGED(state
, m
, FOG_MASK
)) {
609 printf("FOG enable\n");
614 printf("FOG disable\n");
618 #ifdef GL_EXT_vertex_array
619 if (CHANGED(state
, m
, (COMPILED_MASK
|RENDER_STYLE_MASK
|PRIMITIVE_MASK
)))
621 if ((m
& (COMPILED_MASK
|PRIMITIVE_MASK
)) == (IMMEDIATE
|STRIPS
))
623 glVertexPointerEXT( 3, GL_FLOAT
, sizeof(data
[0]), numverts
, data
);
624 glNormalPointerEXT( GL_FLOAT
, sizeof(data
[0]), numverts
, &data
[0][3]);
628 glVertexPointerEXT( 3, GL_FLOAT
, sizeof(data
[0]), numuniq
,
630 glNormalPointerEXT( GL_FLOAT
, sizeof(data
[0]), numuniq
,
631 &compressed_data
[0][3]);
633 #ifdef GL_EXT_compiled_vertex_array
635 glLockArraysEXT( 0, numuniq
);
643 if (m
& (RENDER_STYLE_MASK
|PRIMITIVE_MASK
)) {
644 UPDATE(state
, m
, (RENDER_STYLE_MASK
|PRIMITIVE_MASK
));
647 if (m
& MATERIAL_MASK
) {
648 UPDATE(state
, m
, MATERIAL_MASK
);
656 static void Init(int argc
, char *argv
[])
658 GLfloat fogColor
[4] = {0.5,1.0,0.5,1.0};
660 glClearColor(0.0, 0.0, 0.0, 0.0);
661 glEnable( GL_DEPTH_TEST
);
662 glEnable( GL_VERTEX_ARRAY_EXT
);
663 glEnable( GL_NORMAL_ARRAY_EXT
);
667 glMatrixMode(GL_PROJECTION
);
669 glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 );
671 glMatrixMode(GL_MODELVIEW
);
673 glClipPlane(GL_CLIP_PLANE0
, plane
);
677 glTexEnvi(GL_TEXTURE_ENV
, GL_TEXTURE_ENV_MODE
, GL_DECAL
);
678 glHint(GL_PERSPECTIVE_CORRECTION_HINT
, GL_FASTEST
);
680 glTexGeni(GL_S
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
681 glTexGeni(GL_T
, GL_TEXTURE_GEN_MODE
, GL_SPHERE_MAP
);
683 if (!LoadRGBMipmaps(TEXTURE_FILE
, GL_RGB
)) {
684 printf("Error: couldn't load texture image\n");
688 /* Green fog is easy to see */
689 glFogi(GL_FOG_MODE
,GL_EXP2
);
690 glFogfv(GL_FOG_COLOR
,fogColor
);
691 glFogf(GL_FOG_DENSITY
,0.15);
692 glHint(GL_FOG_HINT
,GL_DONT_CARE
);
698 surf1
= BuildList( GL_COMPILE
);
700 ModeMenu(SHADE_SMOOTH
|
712 printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER
));
713 printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION
));
714 printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR
));
715 printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS
));
721 static void Reshape(int width
, int height
)
723 glViewport(0, 0, (GLint
)width
, (GLint
)height
);
728 static void Key( unsigned char key
, int x
, int y
)
736 ModeMenu((state
^ FOG_MASK
) & FOG_MASK
);
739 ModeMenu((state
^ SHADE_MASK
) & SHADE_MASK
);
742 ModeMenu((state
^ LIGHT_MASK
) & LIGHT_MASK
);
745 ModeMenu((state
^ MATERIAL_MASK
) & MATERIAL_MASK
);
748 ModeMenu((state
^ CLIP_MASK
) & CLIP_MASK
);
769 glMatrixMode(GL_MODELVIEW
);
771 glClipPlane(GL_CLIP_PLANE0
, plane
);
778 glMatrixMode(GL_MODELVIEW
);
780 glClipPlane(GL_CLIP_PLANE0
, plane
);
789 static void SpecialKey( int key
, int x
, int y
)
815 static GLint
Args(int argc
, char **argv
)
820 for (i
= 1; i
< argc
; i
++) {
821 if (strcmp(argv
[i
], "-sb") == 0) {
822 doubleBuffer
= GL_FALSE
;
824 else if (strcmp(argv
[i
], "-db") == 0) {
825 doubleBuffer
= GL_TRUE
;
827 else if (strcmp(argv
[i
], "-info") == 0) {
831 printf("%s (Bad option).\n", argv
[i
]);
839 int main(int argc
, char **argv
)
844 GLuint arg_mode
= Args(argc
, argv
);
849 read_surface( "isosurf.dat" );
851 glutInitWindowPosition(0, 0);
852 glutInitWindowSize(400, 400);
856 type
|= (doubleBuffer
) ? GLUT_DOUBLE
: GLUT_SINGLE
;
857 glutInitDisplayMode(type
);
859 if (glutCreateWindow("Isosurface") <= 0) {
863 /* Make sure server supports the vertex array extension */
864 extensions
= (char *) glGetString( GL_EXTENSIONS
);
866 if (!strstr( extensions
, "GL_EXT_vertex_array" ))
868 printf("Vertex arrays not supported by this renderer\n");
869 allowed
&= ~(COMPILED
|DRAW_ARRAYS
|ARRAY_ELT
);
871 else if (!strstr( extensions
, "GL_EXT_compiled_vertex_array" ))
873 printf("Compiled vertex arrays not supported by this renderer\n");
874 allowed
&= ~COMPILED
;
880 glutCreateMenu(ModeMenu
);
881 glutAddMenuEntry("Lit", LIT
|NO_TEXTURE
|NO_REFLECT
);
882 glutAddMenuEntry("Unlit", UNLIT
|NO_TEXTURE
|NO_REFLECT
);
883 /* glutAddMenuEntry("Textured", TEXTURE); */
884 glutAddMenuEntry("Reflect", TEXTURE
|REFLECT
);
885 glutAddMenuEntry("", 0);
886 glutAddMenuEntry("Smooth", SHADE_SMOOTH
);
887 glutAddMenuEntry("Flat", SHADE_FLAT
);
888 glutAddMenuEntry("", 0);
889 glutAddMenuEntry("Fog", FOG
);
890 glutAddMenuEntry("No Fog", NO_FOG
);
891 glutAddMenuEntry("", 0);
892 glutAddMenuEntry("Point Filtered", POINT_FILTER
);
893 glutAddMenuEntry("Linear Filtered", LINEAR_FILTER
);
894 glutAddMenuEntry("", 0);
895 glutAddMenuEntry("glVertex (STRIPS)", IMMEDIATE
|GLVERTEX
|STRIPS
);
896 glutAddMenuEntry("glVertex (TRIANGLES)", IMMEDIATE
|GLVERTEX
|TRIANGLES
);
897 glutAddMenuEntry("", 0);
898 glutAddMenuEntry("glVertex display list (STRIPS)",
899 DISPLAYLIST
|GLVERTEX
|STRIPS
);
900 glutAddMenuEntry("", 0);
901 if (allowed
& DRAW_ARRAYS
) {
902 glutAddMenuEntry("DrawArrays (STRIPS)",
903 IMMEDIATE
|DRAW_ARRAYS
|STRIPS
);
904 glutAddMenuEntry("ArrayElement (STRIPS)",
905 IMMEDIATE
|ARRAY_ELT
|STRIPS
);
906 glutAddMenuEntry("DrawElements (TRIANGLES)",
907 IMMEDIATE
|DRAW_ARRAYS
|TRIANGLES
);
908 glutAddMenuEntry("ArrayElement (TRIANGLES)",
909 IMMEDIATE
|ARRAY_ELT
|TRIANGLES
);
910 glutAddMenuEntry("", 0);
913 if (allowed
& COMPILED
) {
914 glutAddMenuEntry("Compiled DrawElements (TRIANGLES)",
915 COMPILED
|DRAW_ARRAYS
|TRIANGLES
);
916 glutAddMenuEntry("Compiled DrawElements (STRIPS)",
917 COMPILED
|DRAW_ARRAYS
|STRIPS
);
918 glutAddMenuEntry("Compiled ArrayElement (TRIANGLES)",
919 COMPILED
|ARRAY_ELT
|TRIANGLES
);
920 glutAddMenuEntry("Compiled ArrayElement (STRIPS)",
921 COMPILED
|ARRAY_ELT
|STRIPS
);
922 glutAddMenuEntry("", 0);
924 glutAddMenuEntry("Quit", QUIT
);
925 glutAttachMenu(GLUT_RIGHT_BUTTON
);
927 glutReshapeFunc(Reshape
);
928 glutKeyboardFunc(Key
);
929 glutSpecialFunc(SpecialKey
);
930 glutDisplayFunc(Display
);