diff options
Diffstat (limited to 'progs/demos')
-rw-r--r-- | progs/demos/arbfplight.c | 1 | ||||
-rw-r--r-- | progs/demos/arbfslight.c | 1 | ||||
-rw-r--r-- | progs/demos/cubemap.c | 95 | ||||
-rw-r--r-- | progs/demos/engine.c | 27 | ||||
-rw-r--r-- | progs/demos/fslight.c | 1 | ||||
-rw-r--r-- | progs/demos/gearbox.c | 1 | ||||
-rw-r--r-- | progs/demos/gears.c | 1 | ||||
-rw-r--r-- | progs/demos/geartrain.c | 1 | ||||
-rw-r--r-- | progs/demos/gloss.c | 1 | ||||
-rw-r--r-- | progs/demos/glslnoise.c | 1 | ||||
-rw-r--r-- | progs/demos/isosurf.c | 14 | ||||
-rw-r--r-- | progs/demos/reflect.c | 1 | ||||
-rw-r--r-- | progs/demos/streaming_rect.c | 4 | ||||
-rw-r--r-- | progs/demos/texcyl.c | 1 |
14 files changed, 130 insertions, 20 deletions
diff --git a/progs/demos/arbfplight.c b/progs/demos/arbfplight.c index 401bfb49684..7b7a12bf88d 100644 --- a/progs/demos/arbfplight.c +++ b/progs/demos/arbfplight.c @@ -92,6 +92,7 @@ static void Redisplay( void ) GLfloat seconds = (t - T0) / 1000.0; GLfloat fps = Frames / seconds; printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); T0 = t; Frames = 0; } diff --git a/progs/demos/arbfslight.c b/progs/demos/arbfslight.c index a84491d34fe..275c85105ed 100644 --- a/progs/demos/arbfslight.c +++ b/progs/demos/arbfslight.c @@ -105,6 +105,7 @@ static void Redisplay (void) GLfloat seconds = (GLfloat) (t - t0) / 1000.0f; GLfloat fps = frames / seconds; printf ("%d frames in %6.3f seconds = %6.3f FPS\n", frames, seconds, fps); + fflush(stdout); t0 = t; frames = 0; } diff --git a/progs/demos/cubemap.c b/progs/demos/cubemap.c index b3bdd64f68d..26db42aed5e 100644 --- a/progs/demos/cubemap.c +++ b/progs/demos/cubemap.c @@ -39,6 +39,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <GL/glew.h> #include "GL/glut.h" #include "readtex.h" @@ -49,6 +50,45 @@ static GLboolean use_vertex_arrays = GL_FALSE; static GLboolean anim = GL_TRUE; static GLboolean NoClear = GL_FALSE; static GLint FrameParity = 0; +static GLenum FilterIndex = 0; +static GLint ClampIndex = 0; + + +static struct { + GLenum mode; + const char *name; +} ClampModes[] = { + { GL_CLAMP_TO_EDGE, "GL_CLAMP_TO_EDGE" }, + { GL_CLAMP_TO_BORDER, "GL_CLAMP_TO_BORDER" }, + { GL_CLAMP, "GL_CLAMP" }, + { GL_REPEAT, "GL_REPEAT" } +}; + +#define NUM_CLAMP_MODES (sizeof(ClampModes) / sizeof(ClampModes[0])) + + +static struct { + GLenum mag_mode, min_mode; + const char *name; +} FilterModes[] = { + { GL_NEAREST, GL_NEAREST, "GL_NEAREST, GL_NEAREST" }, + { GL_NEAREST, GL_LINEAR, "GL_NEAREST, GL_LINEAR" }, + { GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST, "GL_NEAREST, GL_NEAREST_MIPMAP_NEAREST" }, + { GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR, "GL_NEAREST, GL_NEAREST_MIPMAP_LINEAR" }, + { GL_NEAREST, GL_LINEAR_MIPMAP_NEAREST, "GL_NEAREST, GL_LINEAR_MIPMAP_NEAREST" }, + { GL_NEAREST, GL_LINEAR_MIPMAP_LINEAR, "GL_NEAREST, GL_LINEAR_MIPMAP_LINEAR" }, + + { GL_LINEAR, GL_NEAREST, "GL_LINEAR, GL_NEAREST" }, + { GL_LINEAR, GL_LINEAR, "GL_LINEAR, GL_LINEAR" }, + { GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST, "GL_LINEAR, GL_NEAREST_MIPMAP_NEAREST" }, + { GL_LINEAR, GL_NEAREST_MIPMAP_LINEAR, "GL_LINEAR, GL_NEAREST_MIPMAP_LINEAR" }, + { GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST, "GL_LINEAR, GL_LINEAR_MIPMAP_NEAREST" }, + { GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR, "GL_LINEAR, GL_LINEAR_MIPMAP_LINEAR" } +}; + +#define NUM_FILTER_MODES (sizeof(FilterModes) / sizeof(FilterModes[0])) + + #define eps1 0.99 #define br 20.0 /* box radius */ @@ -158,6 +198,8 @@ static void draw_skybox( void ) static void draw( void ) { + GLenum wrap; + if (NoClear) { /* This demonstrates how we can avoid calling glClear. * This method only works if every pixel in the window is painted for @@ -183,6 +225,16 @@ static void draw( void ) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); } + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, + FilterModes[FilterIndex].min_mode); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, + FilterModes[FilterIndex].mag_mode); + + wrap = ClampModes[ClampIndex].mode; + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, wrap); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, wrap); + glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, wrap); + glPushMatrix(); /*MODELVIEW*/ glTranslatef( 0.0, 0.0, -EyeDist ); @@ -256,6 +308,14 @@ static void key(unsigned char k, int x, int y) else glutIdleFunc(NULL); break; + case 'f': + FilterIndex = (FilterIndex + 1) % NUM_FILTER_MODES; + printf("Tex filter: %s\n", FilterModes[FilterIndex].name); + break; + case 'c': + ClampIndex = (ClampIndex + 1) % NUM_CLAMP_MODES; + printf("Tex wrap mode: %s\n", ClampModes[ClampIndex].name); + break; case 'm': mode = !mode; set_mode(mode); @@ -321,7 +381,7 @@ static void reshape(int width, int height) static void init_checkers( void ) { #define CUBE_TEX_SIZE 64 - GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][3]; + GLubyte image[CUBE_TEX_SIZE][CUBE_TEX_SIZE][4]; static const GLubyte colors[6][3] = { { 255, 0, 0 }, /* face 0 - red */ { 0, 255, 255 }, /* face 1 - cyan */ @@ -348,21 +408,25 @@ static void init_checkers( void ) for (i = 0; i < CUBE_TEX_SIZE; i++) { for (j = 0; j < CUBE_TEX_SIZE; j++) { if ((i/4 + j/4) & 1) { - image[i][j][0] = colors[f][0]; + image[i][j][0] = colors[f][2]; image[i][j][1] = colors[f][1]; - image[i][j][2] = colors[f][2]; + image[i][j][2] = colors[f][0]; + image[i][j][3] = 255; } else { image[i][j][0] = 255; image[i][j][1] = 255; image[i][j][2] = 255; + image[i][j][3] = 255; } } } - glTexImage2D(targets[f], 0, GL_RGB, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0, - GL_RGB, GL_UNSIGNED_BYTE, image); + glTexImage2D(targets[f], 0, GL_RGBA8, CUBE_TEX_SIZE, CUBE_TEX_SIZE, 0, + GL_BGRA, GL_UNSIGNED_BYTE, image); } + + glGenerateMipmapEXT(GL_TEXTURE_CUBE_MAP_ARB); } @@ -431,32 +495,30 @@ static void load_envmaps(void) static void init( GLboolean useImageFiles ) { - GLenum filter; - - /* check for extension */ + /* check for extensions */ { char *exten = (char *) glGetString(GL_EXTENSIONS); if (!strstr(exten, "GL_ARB_texture_cube_map")) { printf("Sorry, this demo requires GL_ARB_texture_cube_map\n"); exit(0); } + + /* Needed for glGenerateMipmapEXT + */ + if (!strstr(exten, "GL_EXT_framebuffer_object")) { + printf("Sorry, this demo requires GL_EXT_framebuffer_object\n"); + exit(0); + } } printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER)); if (useImageFiles) { load_envmaps(); - filter = GL_LINEAR; } else { init_checkers(); - filter = GL_NEAREST; } - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, filter); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, filter); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glEnable(GL_TEXTURE_CUBE_MAP_ARB); glEnable(GL_DEPTH_TEST); @@ -472,6 +534,8 @@ static void usage(void) printf("keys:\n"); printf(" SPACE - toggle animation\n"); printf(" CURSOR KEYS - rotation\n"); + printf(" c - toggle texture clamp/wrap mode\n"); + printf(" f - toggle texture filter mode\n"); printf(" m - toggle texgen reflection mode\n"); printf(" z/Z - change viewing distance\n"); } @@ -502,6 +566,7 @@ int main( int argc, char *argv[] ) glutInitWindowSize(600, 500); glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); glutCreateWindow("Texture Cube Mapping"); + glewInit(); glutReshapeFunc( reshape ); glutKeyboardFunc( key ); glutSpecialFunc( specialkey ); diff --git a/progs/demos/engine.c b/progs/demos/engine.c index 14fd1e68629..3cf311e7782 100644 --- a/progs/demos/engine.c +++ b/progs/demos/engine.c @@ -386,7 +386,10 @@ DrawPositionedPiston(const Engine *eng, float crankAngle) glPushMatrix(); glRotatef(-90, 1, 0, 0); glTranslatef(0, 0, pos); - DrawPiston(eng); + if (eng->PistonList) + glCallList(eng->PistonList); + else + DrawPiston(eng); glPopMatrix(); } @@ -961,6 +964,28 @@ Draw(void) glEnable(GL_TEXTURE_2D); } + /* also print out a periodic fps to stdout. useful for trying to + * figure out the performance impact of rendering the string above + * with glBitmap. + */ + { + static GLint T0 = 0; + static GLint Frames = 0; + GLint t = glutGet(GLUT_ELAPSED_TIME); + + Frames++; + + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); + T0 = t; + Frames = 0; + } + } + + glutSwapBuffers(); } diff --git a/progs/demos/fslight.c b/progs/demos/fslight.c index e79b5cc1970..41a13cc9f46 100644 --- a/progs/demos/fslight.c +++ b/progs/demos/fslight.c @@ -105,6 +105,7 @@ Redisplay(void) GLfloat fps = frames / seconds; printf("%d frames in %6.3f seconds = %6.3f FPS\n", frames, seconds, fps); + fflush(stdout); t0 = t; frames = 0; } diff --git a/progs/demos/gearbox.c b/progs/demos/gearbox.c index 35bde04417b..2dcf32f92ff 100644 --- a/progs/demos/gearbox.c +++ b/progs/demos/gearbox.c @@ -314,6 +314,7 @@ draw(void) GLfloat seconds = (t - T0) / 1000.0; GLfloat fps = Frames / seconds; printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); T0 = t; Frames = 0; } diff --git a/progs/demos/gears.c b/progs/demos/gears.c index 2a9fefefb53..6016162d6f7 100644 --- a/progs/demos/gears.c +++ b/progs/demos/gears.c @@ -219,6 +219,7 @@ draw(void) GLfloat seconds = (t - T0) / 1000.0; GLfloat fps = Frames / seconds; printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); T0 = t; Frames = 0; if ((t >= 999.0 * autoexit) && (autoexit)) { diff --git a/progs/demos/geartrain.c b/progs/demos/geartrain.c index 8363f2abc6d..8fe405e8076 100644 --- a/progs/demos/geartrain.c +++ b/progs/demos/geartrain.c @@ -905,6 +905,7 @@ draw (void) GLfloat seconds = (t - T0) / 1000.0; GLfloat fps = Frames / seconds; printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + fflush(stdout); T0 = t; Frames = 0; } diff --git a/progs/demos/gloss.c b/progs/demos/gloss.c index b2126e32678..69694b23a09 100644 --- a/progs/demos/gloss.c +++ b/progs/demos/gloss.c @@ -132,6 +132,7 @@ static void Display( void ) GLfloat seconds = (t - T0) / 1000.0; GLfloat fps = Frames / seconds; printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + fflush(stdout); T0 = t; Frames = 0; } diff --git a/progs/demos/glslnoise.c b/progs/demos/glslnoise.c index 4ee12928164..e972b62673f 100644 --- a/progs/demos/glslnoise.c +++ b/progs/demos/glslnoise.c @@ -65,6 +65,7 @@ static void Redisplay (void) GLfloat seconds = (GLfloat) (t - t0) / 1000.0f; GLfloat fps = frames / seconds; printf ("%d frames in %6.3f seconds = %6.3f FPS\n", frames, seconds, fps); + fflush(stdout); t0 = t; frames = 0; } diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c index 393741cc9d6..e280d8f507c 100644 --- a/progs/demos/isosurf.c +++ b/progs/demos/isosurf.c @@ -69,6 +69,7 @@ #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) @@ -81,7 +82,7 @@ #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) +#define POLYGON_MASK (POLYGON_FILL|POLYGON_LINE|POLYGON_POINT) #define MAXVERTS 10000 static GLint maxverts = MAXVERTS; @@ -147,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%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, " : "", @@ -166,7 +167,8 @@ static void print_flags( const char *msg, GLuint flags ) (flags & MATERIALS) ? "materials, " : "", (flags & FOG) ? "fog, " : "", (flags & STIPPLE) ? "stipple, " : "", - (flags & POLYGON_LINE) ? "polygon mode line, " : ""); + (flags & POLYGON_LINE) ? "polygon mode line, " : "", + (flags & POLYGON_POINT) ? "polygon mode point, " : ""); } @@ -711,9 +713,12 @@ static void ModeMenu(int m) if (m & POLYGON_FILL) { glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); } - else { + else if (m & POLYGON_LINE) { glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); } + else { + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + } } #ifdef GL_EXT_vertex_array @@ -1089,6 +1094,7 @@ int main(int argc, char **argv) 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); diff --git a/progs/demos/reflect.c b/progs/demos/reflect.c index 0bec0663bc2..b72af12885d 100644 --- a/progs/demos/reflect.c +++ b/progs/demos/reflect.c @@ -401,6 +401,7 @@ DrawWindow(void) GLfloat seconds = (t - t0) / 1000.0; GLfloat fps = frames / seconds; printf("%d frames in %g seconds = %g FPS\n", frames, seconds, fps); + fflush(stdout); t0 = t; frames = 0; } diff --git a/progs/demos/streaming_rect.c b/progs/demos/streaming_rect.c index 4d4656e722b..f65ac4ce36c 100644 --- a/progs/demos/streaming_rect.c +++ b/progs/demos/streaming_rect.c @@ -47,7 +47,10 @@ static void Idle( void ) } /*static int max( int a, int b ) { return a > b ? a : b; }*/ + +#ifndef min static int min( int a, int b ) { return a < b ? a : b; } +#endif static void DrawObject() { @@ -150,6 +153,7 @@ static void Display( void ) GLfloat fps = Frames / seconds; printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + fflush(stdout); drift_increment = 2.2 * seconds / Frames; T0 = t; diff --git a/progs/demos/texcyl.c b/progs/demos/texcyl.c index e3b03039759..0e6089bced5 100644 --- a/progs/demos/texcyl.c +++ b/progs/demos/texcyl.c @@ -79,6 +79,7 @@ static void Display( void ) GLfloat seconds = (t - T0) / 1000.0; GLfloat fps = Frames / seconds; printf("%d frames in %g seconds = %g FPS\n", Frames, seconds, fps); + fflush(stdout); T0 = t; Frames = 0; } |