diff options
author | José Fonseca <[email protected]> | 2010-01-08 15:42:57 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-01-08 15:42:57 +0000 |
commit | 080c40ab32b2abd6d8381b4a0cc143d36a1652b2 (patch) | |
tree | e173767ebc5a82d81b9fc086449d915e29348976 /progs | |
parent | 9cdf6f025b2ed55cfb13dd09f870f01d0c7947d3 (diff) | |
parent | a1de400e8de06a80ab140bb0fa950e990607572d (diff) |
Merge remote branch 'origin/master' into lp-binning
Conflicts:
src/gallium/auxiliary/util/u_surface.c
src/gallium/drivers/llvmpipe/Makefile
src/gallium/drivers/llvmpipe/SConscript
src/gallium/drivers/llvmpipe/lp_bld_arit.c
src/gallium/drivers/llvmpipe/lp_bld_flow.c
src/gallium/drivers/llvmpipe/lp_bld_interp.c
src/gallium/drivers/llvmpipe/lp_clear.c
src/gallium/drivers/llvmpipe/lp_context.c
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_draw_arrays.c
src/gallium/drivers/llvmpipe/lp_jit.c
src/gallium/drivers/llvmpipe/lp_jit.h
src/gallium/drivers/llvmpipe/lp_prim_vbuf.c
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_setup_point.c
src/gallium/drivers/llvmpipe/lp_state.h
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_fs.c
src/gallium/drivers/llvmpipe/lp_state_sampler.c
src/gallium/drivers/llvmpipe/lp_state_surface.c
src/gallium/drivers/llvmpipe/lp_tex_cache.c
src/gallium/drivers/llvmpipe/lp_tex_cache.h
src/gallium/drivers/llvmpipe/lp_tex_sample.h
src/gallium/drivers/llvmpipe/lp_tile_cache.c
Diffstat (limited to 'progs')
348 files changed, 2760 insertions, 1253 deletions
diff --git a/progs/.gitignore b/progs/.gitignore new file mode 100644 index 00000000000..cb77d18a4b3 --- /dev/null +++ b/progs/.gitignore @@ -0,0 +1 @@ +*.dSYM diff --git a/progs/Makefile b/progs/Makefile index c99f4eebcc1..5bc444e9524 100644 --- a/progs/Makefile +++ b/progs/Makefile @@ -15,7 +15,7 @@ message: subdirs: - @for dir in $(SUBDIRS) ; do \ + @list='$(SUBDIRS)'; for dir in $$list ; do \ if [ -d $$dir ] ; then \ (cd $$dir && $(MAKE)) || exit 1 ; \ fi \ @@ -25,7 +25,7 @@ subdirs: install: clean: - -@for dir in $(SUBDIRS) tests ; do \ + @list='$(SUBDIRS)'; for dir in $$list tests ; do \ if [ -d $$dir ] ; then \ (cd $$dir && $(MAKE) clean) ; \ fi \ diff --git a/progs/SConscript b/progs/SConscript index 66eaf9e5410..3b180d00bc2 100644 --- a/progs/SConscript +++ b/progs/SConscript @@ -1,5 +1,43 @@ SConscript([ 'util/SConscript', +]) + +Import('*') + +progs_env = env.Clone() + +if progs_env['platform'] == 'windows': + progs_env.Append(CPPDEFINES = ['NOMINMAX']) + progs_env.Prepend(LIBS = [ + 'winmm', + 'kernel32', + 'user32', + 'gdi32', + ]) + +# OpenGL +if progs_env['platform'] == 'windows': + progs_env.Prepend(LIBS = ['glu32', 'opengl32']) +else: + progs_env.Prepend(LIBS = ['GLU', 'GL']) + +# Glut +progs_env.Prepend(LIBS = [glut]) + +# GLEW +progs_env.Prepend(LIBS = [glew]) + +progs_env.Prepend(CPPPATH = [ + '#progs/util', +]) + +progs_env.Prepend(LIBS = [ + util, +]) + +Export('progs_env') + +SConscript([ 'demos/SConscript', 'glsl/SConscript', 'redbook/SConscript', diff --git a/progs/SConstruct b/progs/SConstruct deleted file mode 100644 index 4d268cc6d7b..00000000000 --- a/progs/SConstruct +++ /dev/null @@ -1,65 +0,0 @@ -import os -import os.path -import sys - -env = Environment( - tools = ['generic'], - toolpath = ['../scons'], - ENV = os.environ, -) - - -# Use Mesa's headers and libs -if 1: - build_topdir = 'build' - build_subdir = env['platform'] - if env['machine'] != 'generic': - build_subdir += '-' + env['machine'] - if env['debug']: - build_subdir += "-debug" - if env['profile']: - build_subdir += "-profile" - build_dir = os.path.join(build_topdir, build_subdir) - - env.Append(CPPDEFINES = ['GLEW_STATIC']) - env.Append(CPPPATH = ['#../include']) - env.Append(LIBPATH = [ - '#../' + build_dir + '/glew/', - '#../' + build_dir + '/glut/glx', - ]) - - -conf = Configure(env) - -# OpenGL -if env['platform'] == 'windows': - env.Prepend(LIBS = ['glu32', 'opengl32']) -else: - env.Prepend(LIBS = ['GLU', 'GL']) - -# Glut -env['GLUT'] = False -if conf.CheckCHeader('GL/glut.h'): - if env['platform'] == 'windows': - env['GLUT_LIB'] = 'glut32' - else: - env['GLUT_LIB'] = 'glut' - env['GLUT'] = True - -# GLEW -env['GLEW'] = False -if conf.CheckCHeader('GL/glew.h'): - env['GLEW_LIB'] = 'glew' - env['GLEW'] = True - env.Prepend(LIBS = ['glew']) - -conf.Finish() - - -Export('env') - -SConscript( - 'SConscript', - build_dir = env['build'], - duplicate = 0 # http://www.scons.org/doc/0.97/HTML/scons-user/x2261.html -) diff --git a/progs/demos/SConscript b/progs/demos/SConscript index f851870bcf3..742dd66f36f 100644 --- a/progs/demos/SConscript +++ b/progs/demos/SConscript @@ -1,84 +1,66 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ - 'arbfplight', - 'arbfslight', - 'arbocclude', - 'bounce', - 'clearspd', - 'copypix', - 'cubemap', - 'drawpix', - 'engine', - 'fbo_firecube', - 'fire', - 'fogcoord', - 'fplight', - 'fslight', - 'gamma', - 'gearbox', - 'gears', - 'geartrain', - 'glinfo', - 'gloss', - 'gltestperf', - 'ipers', - 'isosurf', - 'lodbias', - 'morph3d', - 'multiarb', - 'paltex', - 'pointblast', - 'ray', - 'readpix', - 'reflect', - 'renormal', - 'shadowtex', - 'singlebuffer', - 'spectex', - 'spriteblast', - 'stex3d', - 'teapot', - 'terrain', - 'tessdemo', - 'texcyl', - 'texenv', - 'textures', - 'trispd', - 'tunnel', - 'tunnel2', - 'vao_demo', - 'winpos', - 'dinoshade', - 'fbotexture', - 'projtex', + 'arbfplight', + 'arbfslight', + 'arbocclude', + 'bounce', + 'clearspd', + 'copypix', + 'cubemap', + 'drawpix', + 'engine', + 'fbo_firecube', + 'fire', + 'fogcoord', + 'fplight', + 'fslight', + 'gamma', + 'gearbox', + 'gears', + 'geartrain', + 'glinfo', + 'gloss', + 'gltestperf', + 'ipers', + 'isosurf', + 'lodbias', + 'morph3d', + 'multiarb', + 'paltex', + 'pointblast', + 'ray', + 'readpix', + 'reflect', + 'renormal', + 'shadowtex', + 'singlebuffer', + 'spectex', + 'spriteblast', + 'stex3d', + 'teapot', + 'terrain', + 'tessdemo', + 'texcyl', + 'texenv', + 'textures', + 'trispd', + 'tunnel', + 'tunnel2', + 'vao_demo', + 'winpos', + 'dinoshade', + 'fbotexture', + 'projtex', ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) -env.Program( +progs_env.Program( target = 'rain', source = [ 'rain.cxx', diff --git a/progs/demos/arbfplight.c b/progs/demos/arbfplight.c index 7b7a12bf88d..861b3b72522 100644 --- a/progs/demos/arbfplight.c +++ b/progs/demos/arbfplight.c @@ -388,9 +388,8 @@ static void Init( void ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 200, 200 ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Win = glutCreateWindow(argv[0]); glutReshapeFunc( Reshape ); diff --git a/progs/demos/arbfslight.c b/progs/demos/arbfslight.c index 275c85105ed..a0ce7f3f5bc 100644 --- a/progs/demos/arbfslight.c +++ b/progs/demos/arbfslight.c @@ -311,9 +311,8 @@ static void Init (void) int main (int argc, char *argv[]) { - glutInit (&argc, argv); - glutInitWindowPosition ( 0, 0); glutInitWindowSize (200, 200); + glutInit (&argc, argv); glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow (argv[0]); glutReshapeFunc (Reshape); diff --git a/progs/demos/arbocclude.c b/progs/demos/arbocclude.c index 9188ad5a565..f669a1f26ba 100644 --- a/progs/demos/arbocclude.c +++ b/progs/demos/arbocclude.c @@ -268,9 +268,8 @@ static void Init( void ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 400, 400 ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Win = glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/demos/bounce.c b/progs/demos/bounce.c index 436bc7d1fb8..a9a291e0a6f 100644 --- a/progs/demos/bounce.c +++ b/progs/demos/bounce.c @@ -192,10 +192,8 @@ visible(int vis) int main(int argc, char *argv[]) { - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(600, 450); - + glutInit(&argc, argv); IndexMode = argc > 1 && strcmp(argv[1], "-ci") == 0; if (IndexMode) diff --git a/progs/demos/clearspd.c b/progs/demos/clearspd.c index 42953f6675e..c40f118a64b 100644 --- a/progs/demos/clearspd.c +++ b/progs/demos/clearspd.c @@ -187,9 +187,8 @@ int main( int argc, char *argv[] ) Init( argc, argv ); - glutInit( &argc, argv ); glutInitWindowSize( (int) Width, (int) Height ); - glutInitWindowPosition( 0, 0 ); + glutInit( &argc, argv ); mode = ColorMode | GLUT_DOUBLE; if (BufferMask & GL_STENCIL_BUFFER_BIT) diff --git a/progs/demos/copypix.c b/progs/demos/copypix.c index a13339ea62f..98c835f44f8 100644 --- a/progs/demos/copypix.c +++ b/progs/demos/copypix.c @@ -237,6 +237,9 @@ int main( int argc, char *argv[] ) const char *filename = IMAGE_FILE; int i = 1; + glutInitWindowSize( WinWidth, WinHeight ); + glutInit( &argc, argv ); + if (argc > i && strcmp(argv[i], "-ci")==0) { ciMode = GL_TRUE; i++; @@ -245,10 +248,6 @@ int main( int argc, char *argv[] ) filename = argv[i]; } - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); - glutInitWindowSize( WinWidth, WinHeight ); - if (ciMode) glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE ); else diff --git a/progs/demos/cubemap.c b/progs/demos/cubemap.c index 20332b1d960..3e79d6a5589 100644 --- a/progs/demos/cubemap.c +++ b/progs/demos/cubemap.c @@ -613,9 +613,8 @@ static void parse_args(int argc, char *argv[]) int main( int argc, char *argv[] ) { - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(600, 500); + glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); glutCreateWindow("Texture Cube Mapping"); glewInit(); diff --git a/progs/demos/drawpix.c b/progs/demos/drawpix.c index 5490bcc6355..9bc7086e04b 100644 --- a/progs/demos/drawpix.c +++ b/progs/demos/drawpix.c @@ -328,6 +328,9 @@ int main( int argc, char *argv[] ) const char *filename = IMAGE_FILE; int i = 1; + glutInitWindowSize( 500, 400 ); + glutInit( &argc, argv ); + if (argc > i && strcmp(argv[i], "-ci")==0) { ciMode = GL_TRUE; i++; @@ -336,10 +339,6 @@ int main( int argc, char *argv[] ) filename = argv[i]; } - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); - glutInitWindowSize( 500, 400 ); - if (ciMode) glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE ); else diff --git a/progs/demos/engine.c b/progs/demos/engine.c index 3cf311e7782..c54e3b8fb80 100644 --- a/progs/demos/engine.c +++ b/progs/demos/engine.c @@ -1308,8 +1308,8 @@ Init(void) int main(int argc, char *argv[]) { - glutInit(&argc, argv); glutInitWindowSize(WinWidth, WinHeight); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); glutCreateWindow("OpenGL Engine Demo"); glewInit(); diff --git a/progs/demos/fbo_firecube.c b/progs/demos/fbo_firecube.c index 4e42924a09e..17767a148f9 100644 --- a/progs/demos/fbo_firecube.c +++ b/progs/demos/fbo_firecube.c @@ -938,7 +938,14 @@ reshape(int width, int height) static void init_fbotexture() { + static const GLenum depthFormats[] = { + GL_DEPTH_COMPONENT, + GL_DEPTH_COMPONENT16, + GL_DEPTH_COMPONENT32 + }; + static int numDepthFormats = sizeof(depthFormats) / sizeof(depthFormats[0]); GLint i; + GLenum stat; /* gen framebuffer id, delete it, do some assertions, just for testing */ glGenFramebuffersEXT(1, &MyFB); @@ -969,18 +976,31 @@ init_fbotexture() /* make depth renderbuffer */ glGenRenderbuffersEXT(1, &DepthRB); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, DepthRB); - glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT16, - TexWidth, TexHeight); - CheckError(__LINE__); + /* we may have to try several formats */ + for (i = 0; i < numDepthFormats; i++) { + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, depthFormats[i], + TexWidth, TexHeight); + CheckError(__LINE__); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, DepthRB); + CheckError(__LINE__); + stat = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + if (stat == GL_FRAMEBUFFER_COMPLETE_EXT) { + break; + } + } + + if (stat != GL_FRAMEBUFFER_COMPLETE_EXT) { + fprintf(stderr, "Error: unable to get usable FBO combination!\n"); + exit(1); + } + glGetRenderbufferParameterivEXT(GL_RENDERBUFFER_EXT, - GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i); + GL_RENDERBUFFER_DEPTH_SIZE_EXT, &i); CheckError(__LINE__); printf("Depth renderbuffer size = %d bits\n", i); - /* attach DepthRB to MyFB */ - glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, - GL_RENDERBUFFER_EXT, DepthRB); - CheckError(__LINE__); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); /* @@ -1031,11 +1051,11 @@ visible(int vis) int main(int argc, char *argv[]) { + glutInitWindowSize(WinWidth, WinHeight); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - glutInitWindowSize(WinWidth, WinHeight); Win = glutCreateWindow("fbo_firecube"); glewInit(); init(argc, argv); diff --git a/progs/demos/fire.c b/progs/demos/fire.c index dd70f6141db..3db45418fad 100644 --- a/progs/demos/fire.c +++ b/progs/demos/fire.c @@ -733,7 +733,6 @@ main(int ac, char **av) HEIGHT = atoi(av[3]); } - glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTH, HEIGHT); glutInit(&ac, av); diff --git a/progs/demos/fogcoord.c b/progs/demos/fogcoord.c index 6f50993c98f..336aa580755 100644 --- a/progs/demos/fogcoord.c +++ b/progs/demos/fogcoord.c @@ -15,8 +15,6 @@ #define DEPTH 5.0f -static PFNGLFOGCOORDPOINTEREXTPROC glFogCoordPointer_ext; - static GLfloat camz; static GLint fogMode; @@ -406,8 +404,8 @@ Init(void) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); glutInitWindowSize( 600, 600 ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/demos/fplight.c b/progs/demos/fplight.c index c297354103f..f52a4f78686 100644 --- a/progs/demos/fplight.c +++ b/progs/demos/fplight.c @@ -268,9 +268,8 @@ static void Init( void ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 200, 200 ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Win = glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/demos/fslight.c b/progs/demos/fslight.c index f0d76a4a06f..395b7caa2c1 100644 --- a/progs/demos/fslight.c +++ b/progs/demos/fslight.c @@ -353,6 +353,7 @@ MakeSphere(void) glNewList(SphereList, GL_COMPILE); gluSphere(obj, 2.0f, 10, 5); glEndList(); + gluDeleteQuadric(obj); } static void @@ -599,9 +600,8 @@ ParseOptions(int argc, char *argv[]) int main(int argc, char *argv[]) { - glutInit(&argc, argv); - glutInitWindowPosition( 0, 0); glutInitWindowSize(200, 200); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); glutReshapeFunc(Reshape); diff --git a/progs/demos/gamma.c b/progs/demos/gamma.c index 9b2c3e1052b..61c6d125fbe 100644 --- a/progs/demos/gamma.c +++ b/progs/demos/gamma.c @@ -146,12 +146,9 @@ display(void) int main(int argc, char **argv) { + glutInitWindowSize(500, 400); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE); - - glutInitWindowPosition(50, 50); - glutInitWindowSize(500, 400); - glutCreateWindow("gamma test patterns"); glutReshapeFunc(Reshape); glutDisplayFunc(display); diff --git a/progs/demos/gearbox.c b/progs/demos/gearbox.c index 2dcf32f92ff..71d0281904b 100644 --- a/progs/demos/gearbox.c +++ b/progs/demos/gearbox.c @@ -474,10 +474,10 @@ visible(int vis) int main(int argc, char *argv[]) { + glutInitWindowSize(WinWidth, WinHeight); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - glutInitWindowSize(WinWidth, WinHeight); Win = glutCreateWindow("gearbox"); init(argc, argv); diff --git a/progs/demos/gears.c b/progs/demos/gears.c index 6016162d6f7..31a5b79eab9 100644 --- a/progs/demos/gears.c +++ b/progs/demos/gears.c @@ -385,11 +385,9 @@ visible(int vis) int main(int argc, char *argv[]) { + glutInitWindowSize(300, 300); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); - - glutInitWindowPosition(0, 0); - glutInitWindowSize(300, 300); win = glutCreateWindow("Gears"); init(argc, argv); diff --git a/progs/demos/geartrain.c b/progs/demos/geartrain.c index 8fe405e8076..00b6e78b724 100644 --- a/progs/demos/geartrain.c +++ b/progs/demos/geartrain.c @@ -25,6 +25,7 @@ */ +#include <assert.h> #include <math.h> #include <stdlib.h> #include <GL/glut.h> @@ -129,8 +130,10 @@ Clear_Buffers () static void LoadTriplet (TDA A) { + int result; Clear_Buffers (); - fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4); + result = fscanf (mainfile, "%s %s %s %s", Buf1, Buf2, Buf3, Buf4); + assert(result != EOF); A[0] = atof (Buf2); A[1] = atof (Buf3); A[2] = atof (Buf4); @@ -140,8 +143,10 @@ LoadTriplet (TDA A) static void LoadReal (float *a) { + int result; Clear_Buffers (); - fscanf (mainfile, "%s %s", Buf1, Buf2); + result = fscanf (mainfile, "%s %s", Buf1, Buf2); + assert(result != EOF); *a = atof (Buf2); } @@ -149,8 +154,10 @@ LoadReal (float *a) static void LoadInteger (int *a) { + int result; Clear_Buffers (); - fscanf (mainfile, "%s %s", Buf1, Buf2); + result = fscanf (mainfile, "%s %s", Buf1, Buf2); + assert(result != EOF); *a = atoi (Buf2); } @@ -158,8 +165,10 @@ LoadInteger (int *a) static void LoadText (char *a) { + int result; Clear_Buffers (); - fscanf (mainfile, "%s %s", Buf1, Buf2); + result = fscanf (mainfile, "%s %s", Buf1, Buf2); + assert(result != EOF); strcpy (a, Buf2); } @@ -177,8 +186,10 @@ getdata (char filename[]) do { + int result; Clear_Buffers (); - fscanf (mainfile, "%s", Buf1); + result = fscanf (mainfile, "%s", Buf1); + (void) result; if (ferror (mainfile)) { printf ("\nError opening file !\n"); @@ -1049,19 +1060,18 @@ main (int argc, char *argv[]) { char *file; - if (argc < 2) - file = "geartrain.dat"; - else - file = argv[1]; - - glutInit(&argc, argv); - glutInitWindowPosition (0, 0); glutInitWindowSize(640,480); + glutInit(&argc, argv); glutInitDisplayMode (GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE ); if (glutCreateWindow ("Gear Train Simulation") == GL_FALSE) exit (1); + if (argc < 2) + file = "geartrain.dat"; + else + file = argv[1]; + getdata (file); process (); init (); diff --git a/progs/demos/gloss.c b/progs/demos/gloss.c index d32e8f8c68b..450861e5778 100644 --- a/progs/demos/gloss.c +++ b/progs/demos/gloss.c @@ -441,8 +441,8 @@ static void Init( int argc, char *argv[] ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); glutInitWindowSize(WinWidth, WinHeight); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Win = glutCreateWindow(argv[0] ); glewInit(); diff --git a/progs/demos/gltestperf.c b/progs/demos/gltestperf.c index 2188b024192..3658a395988 100644 --- a/progs/demos/gltestperf.c +++ b/progs/demos/gltestperf.c @@ -569,10 +569,9 @@ main(int ac, char **av) if (ac == 2) frontbuffer = 0; + glutInitWindowSize(640, 480); glutInit(&ac, av); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); - glutInitWindowPosition(0, 0); - glutInitWindowSize(640, 480); glutCreateWindow("OpenGL/Mesa Performances"); glutDisplayFunc(display); glutMainLoop(); diff --git a/progs/demos/ipers.c b/progs/demos/ipers.c index 5d82b0dc924..265378b90a9 100644 --- a/progs/demos/ipers.c +++ b/progs/demos/ipers.c @@ -133,6 +133,8 @@ initdlists(void) glEndList(); } + + gluDeleteQuadric(obj); } static void @@ -680,7 +682,6 @@ main(int ac, char **av) fprintf(stderr, "IperS V1.0\nWritten by David Bucciarelli ([email protected])\n"); - glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTH, HEIGHT); glutInit(&ac, av); diff --git a/progs/demos/isosurf.c b/progs/demos/isosurf.c index 2e9dff17261..dbe4d8d172a 100644 --- a/progs/demos/isosurf.c +++ b/progs/demos/isosurf.c @@ -132,9 +132,11 @@ static void read_surface( char *filename ) numverts = 0; while (!feof(f) && numverts<maxverts) { - fscanf( f, "%f %f %f %f %f %f", - &data[numverts][0], &data[numverts][1], &data[numverts][2], - &data[numverts][3], &data[numverts][4], &data[numverts][5] ); + int result; + result = fscanf( f, "%f %f %f %f %f %f", + &data[numverts][0], &data[numverts][1], &data[numverts][2], + &data[numverts][3], &data[numverts][4], &data[numverts][5] ); + (void) result; numverts++; } numverts--; @@ -1061,9 +1063,8 @@ int main(int argc, char **argv) read_surface( "isosurf.dat" ); - glutInit( &argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(400, 400); + glutInit( &argc, argv); type = GLUT_DEPTH; type |= GLUT_RGB; diff --git a/progs/demos/lodbias.c b/progs/demos/lodbias.c index 8d39bd605a7..23488b1616e 100644 --- a/progs/demos/lodbias.c +++ b/progs/demos/lodbias.c @@ -282,9 +282,8 @@ static void Init( void ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 350, 350 ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); win = glutCreateWindow(argv[0]); glutReshapeFunc( Reshape ); diff --git a/progs/demos/morph3d.c b/progs/demos/morph3d.c index 6aca8270ff5..0f8ac426f33 100644 --- a/progs/demos/morph3d.c +++ b/progs/demos/morph3d.c @@ -841,9 +841,8 @@ int main(int argc, char **argv) object=1; - glutInit(&argc, argv); - glutInitWindowPosition(0,0); glutInitWindowSize(640,480); + glutInit(&argc, argv); glutInitDisplayMode( GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGB ); @@ -887,5 +886,6 @@ int main(int argc, char **argv) glutIdleFunc( idle_ ); glutDisplayFunc( draw ); glutMainLoop(); - + + return 0; } diff --git a/progs/demos/multiarb.c b/progs/demos/multiarb.c index 85c4e3a266c..82796a0c3f4 100644 --- a/progs/demos/multiarb.c +++ b/progs/demos/multiarb.c @@ -27,6 +27,8 @@ #define ANIMATE 10 #define QUIT 100 +static GLint T0 = 0; +static GLint Frames = 0; static GLboolean Animate = GL_TRUE; static GLint NumUnits = 1; static GLboolean TexEnabled[8]; @@ -105,6 +107,20 @@ static void Display( void ) glPopMatrix(); glutSwapBuffers(); + + Frames++; + + { + GLint t = glutGet(GLUT_ELAPSED_TIME); + 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; + } + } } @@ -322,9 +338,8 @@ int main( int argc, char *argv[] ) { GLint i; - glutInit( &argc, argv ); glutInitWindowSize( 300, 300 ); - glutInitWindowPosition( 0, 0 ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); glutCreateWindow(argv[0] ); glewInit(); diff --git a/progs/demos/paltex.c b/progs/demos/paltex.c index d0cbcfb5e9a..5d4b8662b5c 100644 --- a/progs/demos/paltex.c +++ b/progs/demos/paltex.c @@ -248,12 +248,9 @@ static void Init2( void ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 400, 300 ); - + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); - glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/demos/pointblast.c b/progs/demos/pointblast.c index 2d70b725894..b4d0a67f993 100644 --- a/progs/demos/pointblast.c +++ b/progs/demos/pointblast.c @@ -427,10 +427,10 @@ int main(int argc, char **argv) { int i; + + glutInitWindowSize(300, 300); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); - glutInitWindowPosition(0, 0); - glutInitWindowSize(300, 300); for (i=1; i<argc; i++) { if(!strcmp("-noms", argv[i])) { diff --git a/progs/demos/projtex.c b/progs/demos/projtex.c index 99154d7bdc8..d162568b9f0 100644 --- a/progs/demos/projtex.c +++ b/progs/demos/projtex.c @@ -245,6 +245,10 @@ loadImageTextures(void) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); } glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, borderColor); + + free(texData3); + free(texData4); + free(image); } } @@ -994,18 +998,17 @@ menu(int selection) int main(int argc, char **argv) { + glutInitWindowSize(500,500); glutInit(&argc, argv); + glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); + (void) glutCreateWindow("projtex"); + glewInit(); if (argc > 1) { NumTextures = atoi(argv[1]); } assert(NumTextures <= MAX_TEX); - glutInitDisplayMode(GLUT_RGBA | GLUT_DEPTH | GLUT_DOUBLE); - glutInitWindowSize(500,500); - (void) glutCreateWindow("projtex"); - glewInit(); - loadTexture = loadImageTextures; drawObject = drawCube; initialize(); diff --git a/progs/demos/ray.c b/progs/demos/ray.c index c2d8e4f545e..9cc464d2390 100644 --- a/progs/demos/ray.c +++ b/progs/demos/ray.c @@ -834,6 +834,8 @@ initdlists(void) gluQuadricTexture(obj, GL_TRUE); gluSphere(obj, SPHERE_RADIUS, 16, 16); glEndList(); + + gluDeleteQuadric(obj); } int @@ -854,7 +856,6 @@ main(int ac, char **av) } */ - glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTH, HEIGHT); glutInit(&ac, av); diff --git a/progs/demos/readpix.c b/progs/demos/readpix.c index bbb3a68effa..cc4e4902694 100644 --- a/progs/demos/readpix.c +++ b/progs/demos/readpix.c @@ -219,7 +219,7 @@ Display( void ) GLint reads = 0; GLint endTime; GLint startTime = glutGet(GLUT_ELAPSED_TIME); - GLdouble seconds, pixelsPerSecond; + GLdouble seconds, mpixels, mpixelsPerSecond; printf("Benchmarking...\n"); do { glReadPixels(APosX, APosY, ImgWidth, ImgHeight, @@ -228,9 +228,10 @@ Display( void ) endTime = glutGet(GLUT_ELAPSED_TIME); } while (endTime - startTime < 4000); /* 4 seconds */ seconds = (double) (endTime - startTime) / 1000.0; - pixelsPerSecond = reads * ImgWidth * ImgHeight / seconds; - printf("Result: %d reads in %f seconds = %f pixels/sec\n", - reads, seconds, pixelsPerSecond); + mpixels = reads * (ImgWidth * ImgHeight / (1000.0 * 1000.0)); + mpixelsPerSecond = mpixels / seconds; + printf("Result: %d reads in %f seconds = %f Mpixels/sec\n", + reads, seconds, mpixelsPerSecond); Benchmark = GL_FALSE; } else { @@ -382,12 +383,11 @@ int main( int argc, char *argv[] ) { GLboolean ciMode = GL_FALSE; + glutInitWindowSize( 750, 250 ); + glutInit( &argc, argv ); if (argc > 1 && strcmp(argv[1], "-ci")==0) { ciMode = GL_TRUE; } - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); - glutInitWindowSize( 750, 250 ); if (ciMode) glutInitDisplayMode( GLUT_INDEX | GLUT_DOUBLE ); else diff --git a/progs/demos/renormal.c b/progs/demos/renormal.c index 9e5da95484c..61dd860ddbe 100644 --- a/progs/demos/renormal.c +++ b/progs/demos/renormal.c @@ -112,12 +112,9 @@ key(unsigned char k, int x, int y) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition(0, 0); glutInitWindowSize( 400, 400 ); - + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); - glutCreateWindow(argv[0]); Init(); diff --git a/progs/demos/shadowtex.c b/progs/demos/shadowtex.c index dc5a4bbc480..036f73d40b6 100644 --- a/progs/demos/shadowtex.c +++ b/progs/demos/shadowtex.c @@ -1022,9 +1022,8 @@ PrintHelp(void) int main(int argc, char *argv[]) { - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(WindowWidth, WindowHeight); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_STENCIL); glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/demos/spectex.c b/progs/demos/spectex.c index 6ab1191579c..c1dada9d634 100644 --- a/progs/demos/spectex.c +++ b/progs/demos/spectex.c @@ -239,13 +239,9 @@ static void ModeMenu(int entry) int main( int argc, char *argv[] ) { - - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( 300, 300 ); - + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); - glutCreateWindow( "spectex" ); Init(); diff --git a/progs/demos/spriteblast.c b/progs/demos/spriteblast.c index d73b680b791..36e226e1d07 100644 --- a/progs/demos/spriteblast.c +++ b/progs/demos/spriteblast.c @@ -493,6 +493,8 @@ int main(int argc, char **argv) { int i; + + glutInitWindowSize(600,300); glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH | GLUT_MULTISAMPLE); @@ -506,8 +508,6 @@ main(int argc, char **argv) linearFiltering = 0; } } - glutInitWindowPosition(0, 0); - glutInitWindowSize(600,300); glutCreateWindow("sprite blast"); glewInit(); glutReshapeFunc(reshape); diff --git a/progs/demos/teapot.c b/progs/demos/teapot.c index 6bf6e064095..04a675f36e6 100644 --- a/progs/demos/teapot.c +++ b/progs/demos/teapot.c @@ -638,7 +638,6 @@ int main(int ac, char **av) } */ - glutInitWindowPosition(0,0); glutInitWindowSize(WIDTH,HEIGHT); glutInit(&ac,av); diff --git a/progs/demos/terrain.c b/progs/demos/terrain.c index be78ea4950f..a72c8d3caea 100644 --- a/progs/demos/terrain.c +++ b/progs/demos/terrain.c @@ -8,6 +8,7 @@ * based on a Mikael SkiZoWalker's (MoDEL) / France ([email protected]) demo */ +#include <assert.h> #include <stdio.h> #include <math.h> #include <stdlib.h> @@ -559,12 +560,14 @@ loadpic(void) FILE *FilePic; int i, tmp; GLenum gluerr; + size_t result; if ((FilePic = fopen("terrain.dat", "r")) == NULL) { fprintf(stderr, "Error loading terrain.dat\n"); exit(-1); } - fread(bufferter, 256 * 256, 1, FilePic); + result = fread(bufferter, 256 * 256, 1, FilePic); + assert(result == 1); fclose(FilePic); for (i = 0; i < (256 * 256); i++) { @@ -623,7 +626,6 @@ init(void) int main(int ac, char **av) { - glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTH, HEIGHT); glutInit(&ac, av); diff --git a/progs/demos/tessdemo.c b/progs/demos/tessdemo.c index f71cea12744..8b988e36c13 100644 --- a/progs/demos/tessdemo.c +++ b/progs/demos/tessdemo.c @@ -503,10 +503,9 @@ int main( int argc, char **argv ) usage(); + glutInitWindowSize( 400, 400 ); glutInit( &argc, argv ); glutInitDisplayMode( GLUT_SINGLE | GLUT_RGB ); - glutInitWindowPosition(0, 0); - glutInitWindowSize( 400, 400 ); glutCreateWindow( argv[0] ); /* GH: Bit of a hack... diff --git a/progs/demos/texcyl.c b/progs/demos/texcyl.c index 0e6089bced5..4df97ec4f50 100644 --- a/progs/demos/texcyl.c +++ b/progs/demos/texcyl.c @@ -261,10 +261,8 @@ static void Init( int argc, char *argv[] ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); glutInitWindowSize( 400, 400 ); - glutInitWindowPosition( 0, 0 ); - + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); Win = glutCreateWindow(argv[0] ); diff --git a/progs/demos/texenv.c b/progs/demos/texenv.c index c5a8b13f35f..260ca8718f0 100644 --- a/progs/demos/texenv.c +++ b/progs/demos/texenv.c @@ -765,6 +765,7 @@ int main( int argc, char *argv[] ) GLboolean info = GL_FALSE; int i; + glutInitWindowSize( winWidth, winHeight ); glutInit( &argc, argv ); for ( i = 1 ; i < argc ; i++ ) { @@ -786,8 +787,6 @@ int main( int argc, char *argv[] ) glutInitDisplayMode( GLUT_RGB | GLUT_SINGLE ); } - glutInitWindowSize( winWidth, winHeight ); - glutInitWindowPosition( 0, 0 ); Win = glutCreateWindow( "Texture Environment Test" ); initialize(); diff --git a/progs/demos/textures.c b/progs/demos/textures.c index b7bf135d219..1415ef1c43c 100644 --- a/progs/demos/textures.c +++ b/progs/demos/textures.c @@ -57,7 +57,7 @@ Idle(void) { Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.02; Yrot = glutGet(GLUT_ELAPSED_TIME) * 0.04; - //Zrot += 2.0; + /* Zrot += 2.0; */ glutPostRedisplay(); } @@ -356,9 +356,8 @@ Usage(void) int main(int argc, char *argv[]) { - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(700, 700); + glutInit(&argc, argv); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); Win = glutCreateWindow(argv[0]); glutReshapeFunc(Reshape); diff --git a/progs/demos/trispd.c b/progs/demos/trispd.c index 165d088e3d3..c07c3409472 100644 --- a/progs/demos/trispd.c +++ b/progs/demos/trispd.c @@ -227,15 +227,12 @@ static void Help( const char *program ) int main( int argc, char *argv[] ) { - printf("For options: %s -help\n", argv[0]); - glutInit( &argc, argv ); glutInitWindowSize( (int) Width, (int) Height ); - glutInitWindowPosition( 0, 0 ); - + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); - glutCreateWindow( argv[0] ); + printf("For options: %s -help\n", argv[0]); if (argc==2 && strcmp(argv[1],"-help")==0) { Help(argv[0]); return 0; diff --git a/progs/demos/tunnel.c b/progs/demos/tunnel.c index 6981da32988..efc007c79aa 100644 --- a/progs/demos/tunnel.c +++ b/progs/demos/tunnel.c @@ -491,7 +491,6 @@ main(int ac, char **av) fprintf(stderr, "Tunnel V1.5\nWritten by David Bucciarelli ([email protected])\n"); - glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTH, HEIGHT); glutInit(&ac, av); diff --git a/progs/demos/tunnel2.c b/progs/demos/tunnel2.c index 0288ea0f8ce..f15da95b18b 100644 --- a/progs/demos/tunnel2.c +++ b/progs/demos/tunnel2.c @@ -559,7 +559,6 @@ main(int ac, char **av) fprintf(stderr, "Tunnel2 V1.0\nWritten by David Bucciarelli ([email protected])\n"); - glutInitWindowPosition(0, 0); glutInitWindowSize(WIDTHC0, HEIGHTC0); glutInit(&ac, av); diff --git a/progs/demos/vao_demo.c b/progs/demos/vao_demo.c index 206e06fc6c7..5ce07ecc63b 100644 --- a/progs/demos/vao_demo.c +++ b/progs/demos/vao_demo.c @@ -317,9 +317,8 @@ static void Init( void ) int main( int argc, char *argv[] ) { - glutInit( &argc, argv ); - glutInitWindowPosition( 0, 0 ); glutInitWindowSize( Width, Height ); + glutInit( &argc, argv ); glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); Win = glutCreateWindow( "GL_APPLE_vertex_array_object demo" ); glutReshapeFunc( Reshape ); diff --git a/progs/demos/winpos.c b/progs/demos/winpos.c index 13a9c7e9a8f..f935f9bee0f 100644 --- a/progs/demos/winpos.c +++ b/progs/demos/winpos.c @@ -96,9 +96,8 @@ static void init( void ) int main( int argc, char *argv[] ) { - glutInit(&argc, argv); - glutInitWindowPosition(0, 0); glutInitWindowSize(500, 500); + glutInit(&argc, argv); glutInitDisplayMode( GLUT_RGB ); if (glutCreateWindow("winpos") <= 0) { diff --git a/progs/egl/eglgears.c b/progs/egl/eglgears.c index 0eee9ecf4da..2d9b8cac7f7 100644 --- a/progs/egl/eglgears.c +++ b/progs/egl/eglgears.c @@ -274,10 +274,10 @@ draw(void) static void reshape(int width, int height) { - glViewport(0, 0, (GLint) width, (GLint) height); - GLfloat h = (GLfloat) height / (GLfloat) width; + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); @@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) double st = current_time(); double ct = st; int frames = 0; + GLfloat seconds, fps; + while (ct - st < ttr) { double tt = current_time(); @@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) frames++; } - GLfloat seconds = ct - st; - GLfloat fps = frames / seconds; + seconds = ct - st; + fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); } @@ -372,7 +374,8 @@ main(int argc, char *argv[]) EGLint screenAttribs[10]; EGLModeMESA mode[MAX_MODES]; EGLScreenMESA screen; - EGLint count, chosenMode; + EGLint count; + EGLint chosenMode = 0; GLboolean printInfo = GL_FALSE; EGLint width = 0, height = 0; diff --git a/progs/egl/eglscreen.c b/progs/egl/eglscreen.c index 47b3ce3366f..520f76ea036 100644 --- a/progs/egl/eglscreen.c +++ b/progs/egl/eglscreen.c @@ -52,7 +52,8 @@ main(int argc, char *argv[]) EGLint screenAttribs[10]; EGLModeMESA mode[MAX_MODES]; EGLScreenMESA screen; - EGLint count, chosenMode; + EGLint count; + EGLint chosenMode = 0; EGLint width = 0, height = 0; d = eglGetDisplay(EGL_DEFAULT_DISPLAY); diff --git a/progs/egl/egltri.c b/progs/egl/egltri.c index 79f6702007e..9bbc3cddaf1 100644 --- a/progs/egl/egltri.c +++ b/progs/egl/egltri.c @@ -127,6 +127,7 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr) double st = current_time(); double ct = st; int frames = 0; + GLfloat seconds, fps; while (ct - st < ttr) { @@ -139,8 +140,8 @@ static void run(EGLDisplay dpy, EGLSurface surf, int ttr) frames++; } - GLfloat seconds = ct - st; - GLfloat fps = frames / seconds; + seconds = ct - st; + fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); } diff --git a/progs/egl/peglgears.c b/progs/egl/peglgears.c index 1ddb691677f..212d1acf692 100644 --- a/progs/egl/peglgears.c +++ b/progs/egl/peglgears.c @@ -274,10 +274,10 @@ draw(void) static void reshape(int width, int height) { - glViewport(0, 0, (GLint) width, (GLint) height); - GLfloat h = (GLfloat) height / (GLfloat) width; + glViewport(0, 0, (GLint) width, (GLint) height); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0); @@ -333,6 +333,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) double st = current_time(); double ct = st; int frames = 0; + GLfloat seconds, fps; + while (ct - st < ttr) { double tt = current_time(); @@ -352,8 +354,8 @@ static void run_gears(EGLDisplay dpy, EGLSurface surf, int ttr) frames++; } - GLfloat seconds = ct - st; - GLfloat fps = frames / seconds; + seconds = ct - st; + fps = frames / seconds; printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds, fps); } diff --git a/progs/egl/xeglgears.c b/progs/egl/xeglgears.c index 72ed0052832..614a6256037 100644 --- a/progs/egl/xeglgears.c +++ b/progs/egl/xeglgears.c @@ -95,9 +95,6 @@ static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0; static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; -static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */ - - /* * * Draw a gear wheel. You'll probably want to call this function when @@ -327,122 +324,235 @@ init(void) } -/* - * Create an RGB, double-buffered X window. - * Return the window and context handles. - */ -static void -make_x_window(Display *x_dpy, EGLDisplay egl_dpy, - const char *name, - int x, int y, int width, int height, - Window *winRet, - EGLContext *ctxRet, - EGLSurface *surfRet) -{ - static const EGLint attribs[] = { - EGL_RED_SIZE, 1, - EGL_GREEN_SIZE, 1, - EGL_BLUE_SIZE, 1, - /*EGL_DOUBLEBUFFER,*/ - EGL_DEPTH_SIZE, 1, - EGL_NONE - }; +struct egl_manager { + EGLNativeDisplayType xdpy; + EGLNativeWindowType xwin; + EGLNativePixmapType xpix; - int scrnum; - XSetWindowAttributes attr; - unsigned long mask; - Window root; - Window win; - XVisualInfo *visInfo, visTemplate; - int num_visuals; + EGLDisplay dpy; + EGLConfig conf; EGLContext ctx; - EGLConfig config; - EGLint num_configs, vid; - scrnum = DefaultScreen( x_dpy ); - root = RootWindow( x_dpy, scrnum ); + EGLSurface win; + EGLSurface pix; + EGLSurface pbuf; - if (fullscreen) { - x = 0; y = 0; - width = DisplayWidth( x_dpy, scrnum ); - height = DisplayHeight( x_dpy, scrnum ); + EGLBoolean verbose; + EGLint major, minor; +}; + +static struct egl_manager * +egl_manager_new(EGLNativeDisplayType xdpy, const EGLint *attrib_list, + EGLBoolean verbose) +{ + struct egl_manager *eman; + const char *ver; + EGLint num_conf; + + eman = calloc(1, sizeof(*eman)); + if (!eman) + return NULL; + + eman->verbose = verbose; + eman->xdpy = xdpy; + + eman->dpy = eglGetDisplay(eman->xdpy); + if (eman->dpy == EGL_NO_DISPLAY) { + printf("eglGetDisplay() failed\n"); + free(eman); + return NULL; } - if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) { - printf("Error: couldn't get an EGL visual config\n"); - exit(1); + if (!eglInitialize(eman->dpy, &eman->major, &eman->minor)) { + printf("eglInitialize() failed\n"); + free(eman); + return NULL; } - if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) { - printf("Error: eglGetConfigAttrib() failed\n"); - exit(1); + ver = eglQueryString(eman->dpy, EGL_VERSION); + printf("EGL_VERSION = %s\n", ver); + + if (!eglChooseConfig(eman->dpy, attrib_list, &eman->conf, 1, &num_conf) || + !num_conf) { + printf("eglChooseConfig() failed\n"); + eglTerminate(eman->dpy); + free(eman); + return NULL; } - /* The X window visual must match the EGL config */ - visTemplate.visualid = vid; - visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals); - if (!visInfo) { - printf("Error: couldn't get X visual\n"); - exit(1); + eman->ctx = eglCreateContext(eman->dpy, eman->conf, EGL_NO_CONTEXT, NULL); + if (eman->ctx == EGL_NO_CONTEXT) { + printf("eglCreateContext() failed\n"); + eglTerminate(eman->dpy); + free(eman); + return NULL; + } + + return eman; +} + +static EGLBoolean +egl_manager_create_window(struct egl_manager *eman, const char *name, + EGLint w, EGLint h, EGLBoolean need_surface, + EGLBoolean fullscreen, const EGLint *attrib_list) +{ + XVisualInfo vinfo_template, *vinfo = NULL; + EGLint val, num_vinfo; + Window root; + XSetWindowAttributes attrs; + unsigned long mask; + EGLint x = 0, y = 0; + + if (!eglGetConfigAttrib(eman->dpy, eman->conf, + EGL_NATIVE_VISUAL_ID, &val)) { + printf("eglGetConfigAttrib() failed\n"); + return EGL_FALSE; + } + if (val) { + vinfo_template.visualid = (VisualID) val; + vinfo = XGetVisualInfo(eman->xdpy, VisualIDMask, &vinfo_template, &num_vinfo); + } + /* try harder if window surface is not needed */ + if (!vinfo && !need_surface && + eglGetConfigAttrib(eman->dpy, eman->conf, EGL_BUFFER_SIZE, &val)) { + if (val == 32) + val = 24; + vinfo_template.depth = val; + vinfo = XGetVisualInfo(eman->xdpy, VisualDepthMask, &vinfo_template, &num_vinfo); + } + + if (!vinfo) { + printf("XGetVisualInfo() failed\n"); + return EGL_FALSE; + } + + root = DefaultRootWindow(eman->xdpy); + if (fullscreen) { + x = y = 0; + w = DisplayWidth(eman->xdpy, DefaultScreen(eman->xdpy)); + h = DisplayHeight(eman->xdpy, DefaultScreen(eman->xdpy)); } /* window attributes */ - attr.background_pixel = 0; - attr.border_pixel = 0; - attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone); - attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; - attr.override_redirect = fullscreen; + attrs.background_pixel = 0; + attrs.border_pixel = 0; + attrs.colormap = XCreateColormap(eman->xdpy, root, vinfo->visual, AllocNone); + attrs.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask; + attrs.override_redirect = fullscreen; mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect; - win = XCreateWindow( x_dpy, root, 0, 0, width, height, - 0, visInfo->depth, InputOutput, - visInfo->visual, mask, &attr ); + eman->xwin = XCreateWindow(eman->xdpy, root, x, y, w, h, + 0, vinfo->depth, InputOutput, + vinfo->visual, mask, &attrs); + XFree(vinfo); /* set hints and properties */ { XSizeHints sizehints; sizehints.x = x; sizehints.y = y; - sizehints.width = width; - sizehints.height = height; + sizehints.width = w; + sizehints.height = h; sizehints.flags = USSize | USPosition; - XSetNormalHints(x_dpy, win, &sizehints); - XSetStandardProperties(x_dpy, win, name, name, - None, (char **)NULL, 0, &sizehints); + XSetNormalHints(eman->xdpy, eman->xwin, &sizehints); + XSetStandardProperties(eman->xdpy, eman->xwin, name, name, + None, (char **)NULL, 0, &sizehints); } - eglBindAPI(EGL_OPENGL_API); + if (need_surface) { + eman->win = eglCreateWindowSurface(eman->dpy, eman->conf, + eman->xwin, attrib_list); + if (eman->win == EGL_NO_SURFACE) { + printf("eglCreateWindowSurface() failed\n"); + XDestroyWindow(eman->xdpy, eman->xwin); + eman->xwin = None; + return EGL_FALSE; + } + } + + XMapWindow(eman->xdpy, eman->xwin); + + return EGL_TRUE; +} - ctx = eglCreateContext(egl_dpy, config, EGL_NO_CONTEXT, NULL ); - if (!ctx) { - printf("Error: glXCreateContext failed\n"); - exit(1); +static EGLBoolean +egl_manager_create_pixmap(struct egl_manager *eman, EGLNativeWindowType xwin, + EGLBoolean need_surface, const EGLint *attrib_list) +{ + XWindowAttributes attrs; + + if (!XGetWindowAttributes(eman->xdpy, xwin, &attrs)) { + printf("XGetWindowAttributes() failed\n"); + return EGL_FALSE; + } + + eman->xpix = XCreatePixmap(eman->xdpy, xwin, + attrs.width, attrs.height, attrs.depth); + + if (need_surface) { + eman->pix = eglCreatePixmapSurface(eman->dpy, eman->conf, + eman->xpix, attrib_list); + if (eman->pix == EGL_NO_SURFACE) { + printf("eglCreatePixmapSurface() failed\n"); + XFreePixmap(eman->xdpy, eman->xpix); + eman->xpix = None; + return EGL_FALSE; + } } - *surfRet = eglCreateWindowSurface(egl_dpy, config, win, NULL); + return EGL_TRUE; +} - XFree(visInfo); +static EGLBoolean +egl_manager_create_pbuffer(struct egl_manager *eman, const EGLint *attrib_list) +{ + eman->pbuf = eglCreatePbufferSurface(eman->dpy, eman->conf, attrib_list); + if (eman->pbuf == EGL_NO_SURFACE) { + printf("eglCreatePbufferSurface() failed\n"); + return EGL_FALSE; + } - *winRet = win; - *ctxRet = ctx; + return EGL_TRUE; } +static void +egl_manager_destroy(struct egl_manager *eman) +{ + eglMakeCurrent(eman->dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + eglTerminate(eman->dpy); + + if (eman->xwin != None) + XDestroyWindow(eman->xdpy, eman->xwin); + if (eman->xpix != None) + XFreePixmap(eman->xdpy, eman->xpix); + + free(eman); +} static void -event_loop(Display *dpy, Window win, - EGLDisplay egl_dpy, EGLSurface egl_surf) +event_loop(struct egl_manager *eman, EGLint surface_type, EGLint w, EGLint h) { + GC gc = XCreateGC(eman->xdpy, eman->xwin, 0, NULL); + EGLint orig_w = w, orig_h = h; + + if (surface_type == EGL_PBUFFER_BIT) + printf("there will be no screen update if " + "eglCopyBuffers() is not implemented\n"); + while (1) { - while (XPending(dpy) > 0) { + while (XPending(eman->xdpy) > 0) { XEvent event; - XNextEvent(dpy, &event); + XNextEvent(eman->xdpy, &event); switch (event.type) { - case Expose: + case Expose: /* we'll redraw below */ - break; - case ConfigureNotify: - reshape(event.xconfigure.width, event.xconfigure.height); - break; + break; + case ConfigureNotify: + w = event.xconfigure.width; + h = event.xconfigure.height; + if (surface_type == EGL_WINDOW_BIT) + reshape(w, h); + break; case KeyPress: { char buffer[10]; @@ -476,6 +586,7 @@ event_loop(Display *dpy, Window win, static int frames = 0; static double tRot0 = -1.0, tRate0 = -1.0; double dt, t = current_time(); + int x, y; if (tRot0 < 0.0) tRot0 = t; dt = t - tRot0; @@ -487,7 +598,25 @@ event_loop(Display *dpy, Window win, angle -= 3600.0; draw(); - eglSwapBuffers(egl_dpy, egl_surf); + switch (surface_type) { + case EGL_WINDOW_BIT: + eglSwapBuffers(eman->dpy, eman->win); + break; + case EGL_PBUFFER_BIT: + eglWaitClient(); + if (!eglCopyBuffers(eman->xdpy, eman->pbuf, eman->xpix)) + break; + /* fall through */ + case EGL_PIXMAP_BIT: + eglWaitClient(); + for (x = 0; x < w; x += orig_w) { + for (y = 0; y < h; y += orig_h) { + XCopyArea(eman->xdpy, eman->xpix, eman->xwin, gc, + 0, 0, orig_w, orig_h, x, y); + } + } + break; + } frames++; @@ -503,6 +632,8 @@ event_loop(Display *dpy, Window win, } } } + + XFreeGC(eman->xdpy, gc); } @@ -513,6 +644,8 @@ usage(void) printf(" -display <displayname> set the display to run on\n"); printf(" -fullscreen run in fullscreen mode\n"); printf(" -info display OpenGL renderer info\n"); + printf(" -pixmap use pixmap surface\n"); + printf(" -pbuffer use pbuffer surface\n"); } @@ -521,15 +654,23 @@ main(int argc, char *argv[]) { const int winWidth = 300, winHeight = 300; Display *x_dpy; - Window win; - EGLSurface egl_surf; - EGLContext egl_ctx; - EGLDisplay egl_dpy; char *dpyName = NULL; + struct egl_manager *eman; + EGLint attribs[] = { + EGL_SURFACE_TYPE, 0, /* filled later */ + EGL_RED_SIZE, 1, + EGL_GREEN_SIZE, 1, + EGL_BLUE_SIZE, 1, + EGL_DEPTH_SIZE, 1, + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, + EGL_NONE + }; + char win_title[] = "xeglgears (window/pixmap/pbuffer)"; + EGLint surface_type = EGL_WINDOW_BIT; GLboolean printInfo = GL_FALSE; - EGLint egl_major, egl_minor; + GLboolean fullscreen = GL_FALSE; + EGLBoolean ret; int i; - const char *s; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-display") == 0) { @@ -542,12 +683,21 @@ main(int argc, char *argv[]) else if (strcmp(argv[i], "-fullscreen") == 0) { fullscreen = GL_TRUE; } + else if (strcmp(argv[i], "-pixmap") == 0) { + surface_type = EGL_PIXMAP_BIT; + } + else if (strcmp(argv[i], "-pbuffer") == 0) { + surface_type = EGL_PBUFFER_BIT; + } else { usage(); return -1; } } + /* set surface type */ + attribs[1] = surface_type; + x_dpy = XOpenDisplay(dpyName); if (!x_dpy) { printf("Error: couldn't open display %s\n", @@ -555,26 +705,60 @@ main(int argc, char *argv[]) return -1; } - egl_dpy = eglGetDisplay(x_dpy); - if (!egl_dpy) { - printf("Error: eglGetDisplay() failed\n"); - return -1; - } + eglBindAPI(EGL_OPENGL_API); - if (!eglInitialize(egl_dpy, &egl_major, &egl_minor)) { - printf("Error: eglInitialize() failed\n"); + eman = egl_manager_new(x_dpy, attribs, printInfo); + if (!eman) { + XCloseDisplay(x_dpy); return -1; } - s = eglQueryString(egl_dpy, EGL_VERSION); - printf("EGL_VERSION = %s\n", s); - - make_x_window(x_dpy, egl_dpy, - "glxgears", 0, 0, winWidth, winHeight, - &win, &egl_ctx, &egl_surf); + snprintf(win_title, sizeof(win_title), "xeglgears (%s)", + (surface_type == EGL_WINDOW_BIT) ? "window" : + (surface_type == EGL_PIXMAP_BIT) ? "pixmap" : "pbuffer"); + + /* create surface(s) */ + switch (surface_type) { + case EGL_WINDOW_BIT: + ret = egl_manager_create_window(eman, win_title, winWidth, winHeight, + EGL_TRUE, fullscreen, NULL); + if (ret) + ret = eglMakeCurrent(eman->dpy, eman->win, eman->win, eman->ctx); + break; + case EGL_PIXMAP_BIT: + ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight, + EGL_FALSE, fullscreen, NULL) && + egl_manager_create_pixmap(eman, eman->xwin, + EGL_TRUE, NULL)); + if (ret) + ret = eglMakeCurrent(eman->dpy, eman->pix, eman->pix, eman->ctx); + break; + case EGL_PBUFFER_BIT: + { + EGLint pbuf_attribs[] = { + EGL_WIDTH, winWidth, + EGL_HEIGHT, winHeight, + EGL_NONE + }; + ret = (egl_manager_create_window(eman, win_title, winWidth, winHeight, + EGL_FALSE, fullscreen, NULL) && + egl_manager_create_pixmap(eman, eman->xwin, + EGL_FALSE, NULL) && + egl_manager_create_pbuffer(eman, pbuf_attribs)); + if (ret) + ret = eglMakeCurrent(eman->dpy, eman->pbuf, eman->pbuf, eman->ctx); + } + break; + default: + ret = EGL_FALSE; + break; + } - XMapWindow(x_dpy, win); - eglMakeCurrent(egl_dpy, egl_surf, egl_surf, egl_ctx); + if (!ret) { + egl_manager_destroy(eman); + XCloseDisplay(x_dpy); + return -1; + } if (printInfo) { printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); @@ -590,18 +774,13 @@ main(int argc, char *argv[]) */ reshape(winWidth, winHeight); - event_loop(x_dpy, win, egl_dpy, egl_surf); + event_loop(eman, surface_type, winWidth, winHeight); glDeleteLists(gear1, 1); glDeleteLists(gear2, 1); glDeleteLists(gear3, 1); - eglDestroyContext(egl_dpy, egl_ctx); - eglDestroySurface(egl_dpy, egl_surf); - eglTerminate(egl_dpy); - - - XDestroyWindow(x_dpy, win); + egl_manager_destroy(eman); XCloseDisplay(x_dpy); return 0; diff --git a/progs/fp/Makefile b/progs/fp/Makefile index 681928cf260..d77cd32b4df 100755 --- a/progs/fp/Makefile +++ b/progs/fp/Makefile @@ -17,6 +17,7 @@ SOURCES = \ tri-depth2.c \ tri-depthwrite.c \ tri-depthwrite2.c \ + tri-inv.c \ tri-param.c \ fp-tri.c diff --git a/progs/fp/SConscript b/progs/fp/SConscript index a78318542c1..113e11ab54e 100644 --- a/progs/fp/SConscript +++ b/progs/fp/SConscript @@ -1,15 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'fp-tri', @@ -24,7 +13,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = [prog + '.c'], ) diff --git a/progs/fp/fp-tri.c b/progs/fp/fp-tri.c index 52a8fcfc22a..70676d4c400 100644 --- a/progs/fp/fp-tri.c +++ b/progs/fp/fp-tri.c @@ -73,7 +73,7 @@ static void Init( void ) GLuint Texture; GLint errno; GLuint prognum; - char buf[4096]; + char buf[50000]; GLuint sz; FILE *f; @@ -176,6 +176,17 @@ static void Init( void ) } + { + const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 }; + const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 }; + const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 }; + const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 }; + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse); + glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission); + } + glClearColor(.1, .3, .5, 0); } @@ -197,7 +208,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/mov-imm.txt b/progs/fp/mov-imm.txt new file mode 100644 index 00000000000..38e48079d09 --- /dev/null +++ b/progs/fp/mov-imm.txt @@ -0,0 +1,3 @@ +!!ARBfp1.0 +MOV result.color, {0.5, 0.8, 0.3, 1.0}; +END diff --git a/progs/fp/mov-param.txt b/progs/fp/mov-param.txt new file mode 100644 index 00000000000..13d82fe00b8 --- /dev/null +++ b/progs/fp/mov-param.txt @@ -0,0 +1,4 @@ +!!ARBfp1.0 +PARAM Diffuse = state.material.diffuse; +MOV result.color, Diffuse; +END diff --git a/progs/fp/point-position.c b/progs/fp/point-position.c index c0963d7a0b5..1ae753c1d05 100644 --- a/progs/fp/point-position.c +++ b/progs/fp/point-position.c @@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-depth.c b/progs/fp/tri-depth.c index 5488469e806..a9f3a6a5be3 100644 --- a/progs/fp/tri-depth.c +++ b/progs/fp/tri-depth.c @@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-depth2.c b/progs/fp/tri-depth2.c index 6ed23071157..8c4336817be 100644 --- a/progs/fp/tri-depth2.c +++ b/progs/fp/tri-depth2.c @@ -59,7 +59,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-depthwrite.c b/progs/fp/tri-depthwrite.c index 8e4f3e62451..7b9d70f292a 100644 --- a/progs/fp/tri-depthwrite.c +++ b/progs/fp/tri-depthwrite.c @@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-depthwrite2.c b/progs/fp/tri-depthwrite2.c index 3c0b4d30c97..599949551d1 100644 --- a/progs/fp/tri-depthwrite2.c +++ b/progs/fp/tri-depthwrite2.c @@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-inv.c b/progs/fp/tri-inv.c index 7e8d8c5ce29..7e490fa61ca 100644 --- a/progs/fp/tri-inv.c +++ b/progs/fp/tri-inv.c @@ -56,7 +56,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-param.c b/progs/fp/tri-param.c index 57443d71bd0..26a804d4b38 100644 --- a/progs/fp/tri-param.c +++ b/progs/fp/tri-param.c @@ -54,7 +54,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/fp/tri-tex.c b/progs/fp/tri-tex.c index 1dbbb201cef..64299e94531 100644 --- a/progs/fp/tri-tex.c +++ b/progs/fp/tri-tex.c @@ -76,7 +76,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/glsl/CH11-bumpmaptex.frag b/progs/glsl/CH11-bumpmaptex.frag new file mode 100644 index 00000000000..b1f93b784d9 --- /dev/null +++ b/progs/glsl/CH11-bumpmaptex.frag @@ -0,0 +1,47 @@ +// +// Fragment shader for procedural bumps +// +// Authors: John Kessenich, Randi Rost +// +// Copyright (c) 2002-2006 3Dlabs Inc. Ltd. +// +// See 3Dlabs-License.txt for license information +// +// Texture mapping/modulation added by Brian Paul +// + +varying vec3 LightDir; +varying vec3 EyeDir; + +uniform float BumpDensity; // = 16.0 +uniform float BumpSize; // = 0.15 +uniform float SpecularFactor; // = 0.5 + +sampler2D Tex; + +void main() +{ + vec3 ambient = vec3(0.25); + vec3 litColor; + vec2 c = BumpDensity * gl_TexCoord[0].st; + vec2 p = fract(c) - vec2(0.5); + + float d, f; + d = p.x * p.x + p.y * p.y; + f = inversesqrt(d + 1.0); + + if (d >= BumpSize) + { p = vec2(0.0); f = 1.0; } + + vec3 SurfaceColor = texture2D(Tex, gl_TexCoord[0].st).xyz; + + vec3 normDelta = vec3(p.x, p.y, 1.0) * f; + litColor = SurfaceColor * (ambient + max(dot(normDelta, LightDir), 0.0)); + vec3 reflectDir = reflect(LightDir, normDelta); + + float spec = max(dot(EyeDir, reflectDir), 0.0); + spec *= SpecularFactor; + litColor = min(litColor + spec, vec3(1.0)); + + gl_FragColor = vec4(litColor, 1.0); +} diff --git a/progs/glsl/CH18-mandel.frag b/progs/glsl/CH18-mandel.frag index a472d812526..a972d68bcfb 100644 --- a/progs/glsl/CH18-mandel.frag +++ b/progs/glsl/CH18-mandel.frag @@ -31,7 +31,7 @@ void main() float iter; // for (iter = 0.0; iter < MaxIterations && r2 < 4.0; ++iter) - for (iter = 0.0; iter < 12 && r2 < 4.0; ++iter) + for (iter = 0.0; iter < 12.0 && r2 < 4.0; ++iter) { float tempreal = real; diff --git a/progs/glsl/SConscript b/progs/glsl/SConscript index 7a4549cd705..8f2ebcf69c4 100644 --- a/progs/glsl/SConscript +++ b/progs/glsl/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ 'array', 'bitmap', @@ -48,7 +30,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/glsl/bump.c b/progs/glsl/bump.c index 87669aec736..e31afab9392 100644 --- a/progs/glsl/bump.c +++ b/progs/glsl/bump.c @@ -12,15 +12,20 @@ #include <GL/glew.h> #include <GL/glut.h> #include "shaderutil.h" +#include "readtex.h" static char *FragProgFile = "CH11-bumpmap.frag"; +static char *FragTexProgFile = "CH11-bumpmaptex.frag"; static char *VertProgFile = "CH11-bumpmap.vert"; +static char *TextureFile = "../images/tile.rgb"; /* program/shader objects */ static GLuint fragShader; +static GLuint fragTexShader; static GLuint vertShader; static GLuint program; +static GLuint texProgram; static struct uniform_info Uniforms[] = { @@ -32,13 +37,26 @@ static struct uniform_info Uniforms[] = { END_OF_UNIFORMS }; +static struct uniform_info TexUniforms[] = { + { "LightPosition", 1, GL_FLOAT_VEC3, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 }, + { "Tex", 1, GL_INT, { 0, 0, 0, 0 }, -1 }, + { "BumpDensity", 1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 }, + { "BumpSize", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 }, + { "SpecularFactor", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 }, + END_OF_UNIFORMS +}; + static GLint win = 0; static GLfloat xRot = 20.0f, yRot = 0.0f, zRot = 0.0f; -static GLuint tangentAttrib; +static GLint tangentAttrib; +static GLint tangentAttribTex; + +static GLuint Texture; static GLboolean Anim = GL_FALSE; +static GLboolean Textured = GL_FALSE; static void @@ -135,6 +153,11 @@ Redisplay(void) glRotatef(yRot, 0.0f, 1.0f, 0.0f); glRotatef(zRot, 0.0f, 0.0f, 1.0f); + if (Textured) + glUseProgram(texProgram); + else + glUseProgram(program); + Cube(1.5); glPopMatrix(); @@ -163,8 +186,10 @@ static void CleanUp(void) { glDeleteShader(fragShader); + glDeleteShader(fragTexShader); glDeleteShader(vertShader); glDeleteProgram(program); + glDeleteProgram(texProgram); glutDestroyWindow(win); } @@ -181,6 +206,9 @@ Key(unsigned char key, int x, int y) Anim = !Anim; glutIdleFunc(Anim ? Idle : NULL); break; + case 't': + Textured = !Textured; + break; case 'z': zRot += step; break; @@ -254,6 +282,26 @@ Init(void) CheckError(__LINE__); + + /* + * As above, but fragment shader also uses a texture map. + */ + fragTexShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragTexProgFile); + texProgram = LinkShaders(vertShader, fragTexShader); + glUseProgram(texProgram); + assert(glIsProgram(texProgram)); + assert(glIsShader(fragTexShader)); + SetUniformValues(texProgram, TexUniforms); + PrintUniforms(TexUniforms); + + /* + * Load tex image. + */ + glGenTextures(1, &Texture); + glBindTexture(GL_TEXTURE_2D, Texture); + LoadRGBMipmaps(TextureFile, GL_RGB); + + glClearColor(0.4f, 0.4f, 0.8f, 0.0f); glEnable(GL_DEPTH_TEST); @@ -268,10 +316,13 @@ ParseOptions(int argc, char *argv[]) int i; for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-fs") == 0) { - FragProgFile = argv[i+1]; + FragProgFile = argv[++i]; } else if (strcmp(argv[i], "-vs") == 0) { - VertProgFile = argv[i+1]; + VertProgFile = argv[++i]; + } + else if (strcmp(argv[i], "-t") == 0) { + TextureFile = argv[++i]; } } } diff --git a/progs/glsl/convolutions.c b/progs/glsl/convolutions.c index c2fb76e1aa5..350e61bbdc5 100644 --- a/progs/glsl/convolutions.c +++ b/progs/glsl/convolutions.c @@ -369,7 +369,7 @@ static void keyPress(unsigned char key, int x, int y) case 27: exit(0); default: - return; + break; } glutPostRedisplay(); } diff --git a/progs/glsl/deriv.c b/progs/glsl/deriv.c index 265a5157154..588246b71ac 100644 --- a/progs/glsl/deriv.c +++ b/progs/glsl/deriv.c @@ -27,11 +27,15 @@ static GLuint SphereList, RectList, CurList; static GLint win = 0; static GLboolean anim = GL_TRUE; static GLfloat xRot = 0.0f, yRot = 0.0f; +static GLint WinSize[2]; +static GLint WinSizeUniform = -1; static void Redisplay(void) { + glUniform2iv(WinSizeUniform, 1, WinSize); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); @@ -55,6 +59,8 @@ Idle(void) static void Reshape(int width, int height) { + WinSize[0] = width; + WinSize[1] = height; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); @@ -140,6 +146,7 @@ MakeSphere(void) glNewList(SphereList, GL_COMPILE); gluSphere(obj, 2.0f, 30, 15); glEndList(); + gluDeleteQuadric(obj); } @@ -162,8 +169,10 @@ static void Init(void) { static const char *fragShaderText = + "uniform ivec2 WinSize; \n" "void main() {\n" - " gl_FragColor = abs(dFdy(gl_TexCoord[0])) * 50.0;\n" + " vec2 d = dFdy(gl_TexCoord[0].xy) * vec2(WinSize); \n" + " gl_FragColor = vec4(d.x, d.y, 0.0, 1.0);\n" " // gl_FragColor = gl_TexCoord[0];\n" "}\n"; static const char *vertShaderText = @@ -180,6 +189,7 @@ Init(void) program = LinkShaders(vertShader, fragShader); glUseProgram(program); + WinSizeUniform = glGetUniformLocation(program, "WinSize"); /*assert(glGetError() == 0);*/ @@ -219,8 +229,10 @@ ParseOptions(int argc, char *argv[]) int main(int argc, char *argv[]) { + WinSize[0] = WinSize[1] = 200; + glutInit(&argc, argv); - glutInitWindowSize(200, 200); + glutInitWindowSize(WinSize[0], WinSize[1]); glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); win = glutCreateWindow(argv[0]); glewInit(); diff --git a/progs/glsl/multinoise.c b/progs/glsl/multinoise.c index 0d4026e29cf..d504ba1cc4e 100644 --- a/progs/glsl/multinoise.c +++ b/progs/glsl/multinoise.c @@ -22,22 +22,22 @@ static const char *FragShaderText[ 4 ] = { "void main()\n" "{\n" " gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].w ) * 0.5 + 0.5;\n" - " gl_FragColor.a = 1;\n" + " gl_FragColor.a = 1.0;\n" "}\n", "void main()\n" "{\n" " gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xw ) * 0.5 + 0.5;\n" - " gl_FragColor.a = 1;\n" + " gl_FragColor.a = 1.0;\n" "}\n", "void main()\n" "{\n" " gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xyw ) * 0.5 + 0.5;\n" - " gl_FragColor.a = 1;\n" + " gl_FragColor.a = 1.0;\n" "}\n", "void main()\n" "{\n" " gl_FragColor.rgb = noise3( gl_TexCoord[ 0 ].xyzw ) * 0.5 + 0.5;\n" - " gl_FragColor.a = 1;\n" + " gl_FragColor.a = 1.0;\n" "}\n" }; @@ -125,6 +125,7 @@ Key(unsigned char key, int x, int y) case 'a': Anim = !Anim; glutIdleFunc(Anim ? Idle : NULL); + break; case 's': Slice -= step; break; @@ -193,7 +194,7 @@ LoadAndCompileShader(GLuint shader, const char *text) GLchar log[1000]; GLsizei len; glGetShaderInfoLog(shader, 1000, &len, log); - fprintf(stderr, "noise: problem compiling shader: %s\n", log); + fprintf(stderr, "multinoise: problem compiling shader: %s\n", log); exit(1); } else { diff --git a/progs/glsl/multitex.c b/progs/glsl/multitex.c index bf46fd5210e..49b32253eed 100644 --- a/progs/glsl/multitex.c +++ b/progs/glsl/multitex.c @@ -369,12 +369,9 @@ InitPrograms(void) static void InitGL(void) { - const char *version = (const char *) glGetString(GL_VERSION); + if (!ShadersSupported()) + exit(1); - if (version[0] != '2' || version[1] != '.') { - printf("Warning: this program expects OpenGL 2.0\n"); - /*exit(1);*/ - } printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); printf("Usage:\n"); printf(" a - toggle arrays vs. immediate mode rendering\n"); diff --git a/progs/glsl/noise.c b/progs/glsl/noise.c index fdab263ea6a..1148580ff4d 100644 --- a/progs/glsl/noise.c +++ b/progs/glsl/noise.c @@ -28,7 +28,7 @@ static const char *FragShaderText = " vec4 p;\n" " p.xy = gl_TexCoord[0].xy;\n" " p.z = Slice;\n" - " p.w = 0;\n" + " p.w = 0.0;\n" " vec4 n = noise4(p * scale);\n" " gl_FragColor = n * Scale + Bias;\n" "}\n"; @@ -119,6 +119,7 @@ Key(unsigned char key, int x, int y) case 'a': Anim = !Anim; glutIdleFunc(Anim ? Idle : NULL); + break; case 's': Slice -= step; break; diff --git a/progs/glsl/shtest.c b/progs/glsl/shtest.c index 628a7dd5b98..e9800c307f3 100644 --- a/progs/glsl/shtest.c +++ b/progs/glsl/shtest.c @@ -492,9 +492,8 @@ ReadConfigFile(const char *filename, struct config_file *conf) conf->num_uniforms = 0; /* ugly but functional parser */ - while (!feof(f)) { - fgets(line, sizeof(line), f); - if (!feof(f) && line[0]) { + while (fgets(line, sizeof(line), f) != NULL) { + if (line[0]) { if (strncmp(line, "vs ", 3) == 0) { VertShaderFile = strdup(line + 3); VertShaderFile[strlen(VertShaderFile) - 1] = 0; @@ -627,7 +626,7 @@ Init(void) NumAttribs = GetAttribs(Program, Attribs); PrintAttribs(Attribs); - //assert(glGetError() == 0); + /* assert(glGetError() == 0); */ glClearColor(0.4f, 0.4f, 0.8f, 0.0f); diff --git a/progs/glsl/texaaline.c b/progs/glsl/texaaline.c index 2e4f932ad60..00edab73108 100644 --- a/progs/glsl/texaaline.c +++ b/progs/glsl/texaaline.c @@ -310,8 +310,8 @@ MakeMipmap(void) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); - ////glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5); + /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 4); */ + /* glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5); */ glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); #undef SZ diff --git a/progs/glsl/texdemo1.c b/progs/glsl/texdemo1.c index 5b1913a722b..2076e6aef94 100644 --- a/progs/glsl/texdemo1.c +++ b/progs/glsl/texdemo1.c @@ -400,11 +400,8 @@ InitPrograms(void) static void Init(GLboolean useImageFiles) { - const char *version = (const char *) glGetString(GL_VERSION); - - if (version[0] != '2' || version[1] != '.') { - printf("Warning: this program expects OpenGL 2.0\n"); - /*exit(1);*/ + if (!ShadersSupported()) { + exit(1); } printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); diff --git a/progs/glsl/trirast.c b/progs/glsl/trirast.c index 53bd91ef976..857342636dc 100644 --- a/progs/glsl/trirast.c +++ b/progs/glsl/trirast.c @@ -179,9 +179,9 @@ Init(void) "\n" "void main() {\n" " vec2 p = gl_FragCoord.xy; \n" - " if (crs(v1 - v0, p - v0) >= 0 && \n" - " crs(v2 - v1, p - v1) >= 0 && \n" - " crs(v0 - v2, p - v2) >= 0) \n" + " if (crs(v1 - v0, p - v0) >= 0.0 && \n" + " crs(v2 - v1, p - v1) >= 0.0 && \n" + " crs(v0 - v2, p - v2) >= 0.0) \n" " gl_FragColor = vec4(1.0); \n" " else \n" " gl_FragColor = vec4(0.5); \n" diff --git a/progs/glsl/vert-tex.c b/progs/glsl/vert-tex.c index 4c8bfa587aa..2b93c788889 100644 --- a/progs/glsl/vert-tex.c +++ b/progs/glsl/vert-tex.c @@ -40,15 +40,6 @@ static GLboolean Anim = GL_TRUE; static GLboolean WireFrame = GL_TRUE; static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f; - -/* value[0] = tex unit */ -static struct uniform_info Uniforms[] = { - { "tex1", 1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 }, - END_OF_UNIFORMS -}; - - - static void Idle(void) { diff --git a/progs/objviewer/.gitignore b/progs/objviewer/.gitignore new file mode 100644 index 00000000000..ff094f833e4 --- /dev/null +++ b/progs/objviewer/.gitignore @@ -0,0 +1,8 @@ +extfuncs.h +objview +readtex.c +readtex.h +shaderutil.c +shaderutil.h +trackball.c +trackball.h diff --git a/progs/osdemos/Makefile b/progs/osdemos/Makefile index 023ea02ae27..f53515cb0a7 100644 --- a/progs/osdemos/Makefile +++ b/progs/osdemos/Makefile @@ -5,7 +5,7 @@ include $(TOP)/configs/current INCDIR = $(TOP)/include -OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS) +OSMESA_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) -l$(OSMESA_LIB) $(APP_LIB_DEPS) OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa16 -l$(GLU_LIB) \ -l$(GL_LIB) $(APP_LIB_DEPS) @@ -13,12 +13,6 @@ OSMESA16_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa16 -l$(GLU_LIB) \ OSMESA32_LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -lOSMesa32 -l$(GLU_LIB) \ -l$(GL_LIB) $(APP_LIB_DEPS) -LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) \ - $(TOP)/$(LIB_DIR)/$(GLUT_LIB_NAME) - -LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLU_LIB) -l$(GL_LIB) \ - $(APP_LIB_DEPS) - PROGS = \ osdemo \ ostest1 @@ -30,11 +24,6 @@ PROGS = \ .SUFFIXES: .c -# make executable from .c file: -.c: $(LIB_DEP) readtex.o - $(CC) -I$(INCDIR) $(CFLAGS) $(LDFLAGS) $< readtex.o $(LIBS) -o $@ - - ##### TARGETS ##### default: readtex.o $(PROGS) diff --git a/progs/perf/.gitignore b/progs/perf/.gitignore new file mode 100644 index 00000000000..7e8fe616cd5 --- /dev/null +++ b/progs/perf/.gitignore @@ -0,0 +1,10 @@ +copytex +drawoverhead +fbobind +fill +genmipmap +readpixels +swapbuffers +teximage +vbo +vertexrate diff --git a/progs/perf/SConscript b/progs/perf/SConscript index a5ec9a7c2a0..691478ab64d 100644 --- a/progs/perf/SConscript +++ b/progs/perf/SConscript @@ -1,11 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'copytex', @@ -21,7 +14,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = [ prog + '.c', diff --git a/progs/perf/genmipmap.c b/progs/perf/genmipmap.c index 4b7d6ad155b..20e2fa34107 100644 --- a/progs/perf/genmipmap.c +++ b/progs/perf/genmipmap.c @@ -27,6 +27,7 @@ */ #include <string.h> +#include <stdio.h> #include "glmain.h" #include "common.h" @@ -53,6 +54,11 @@ static const struct vertex vertices[1] = { void PerfInit(void) { + if (!PerfExtensionSupported("GL_ARB_framebuffer_object")) { + printf("Sorry, this test requires GL_ARB_framebuffer_object\n"); + exit(1); + } + /* setup VBO w/ vertex data */ glGenBuffersARB(1, &VBO); glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBO); diff --git a/progs/rbug/bin_to_bmp.c b/progs/rbug/bin_to_bmp.c index cdae3486ce0..49a5416787a 100644 --- a/progs/rbug/bin_to_bmp.c +++ b/progs/rbug/bin_to_bmp.c @@ -25,8 +25,10 @@ #include "pipe/p_compiler.h" #include "pipe/p_format.h" #include "pipe/p_state.h" +#include "util/u_format.h" #include "util/u_memory.h" #include "util/u_debug.h" +#include "util/u_format.h" #include "util/u_network.h" #include "util/u_tile.h" @@ -54,10 +56,7 @@ static void dump(unsigned width, unsigned height, unsigned src_stride, enum pipe_format src_format, uint8_t *data, unsigned src_size) { - struct pipe_format_block src_block; - enum pipe_format dst_format = PIPE_FORMAT_R32G32B32A32_FLOAT; - struct pipe_format_block dst_block; unsigned dst_stride; unsigned dst_size; float *rgba; @@ -65,20 +64,17 @@ static void dump(unsigned width, unsigned height, char filename[512]; { - pf_get_block(src_format, &src_block); - assert(src_stride >= pf_get_stride(&src_block, width)); - assert(src_size >= pf_get_2d_size(&src_block, src_stride, width)); + assert(src_stride >= util_format_get_stride(src_format, width)); } { - pf_get_block(dst_format, &dst_block); - dst_stride = pf_get_stride(&dst_block, width); - dst_size = pf_get_2d_size(&dst_block, dst_stride, width); + dst_stride = util_format_get_stride(dst_format, width); + dst_size = util_format_get_2d_size(dst_format, dst_stride, width); rgba = MALLOC(dst_size); } util_snprintf(filename, 512, "%s.bmp", pf_name(src_format)); - if (pf_is_compressed(src_format)) { + if (util_format_is_compressed(src_format)) { debug_printf("skipping: %s\n", filename); return; } diff --git a/progs/rbug/simple_server.c b/progs/rbug/simple_server.c index 04380c33109..3a842c06c4e 100644 --- a/progs/rbug/simple_server.c +++ b/progs/rbug/simple_server.c @@ -29,7 +29,7 @@ #include "rbug/rbug.h" -static void wait() +static void rbug_wait() { int s = u_socket_listen_on_port(13370); int c = u_socket_accept(s); @@ -57,6 +57,6 @@ static void wait() int main(int argc, char** argv) { - wait(); + rbug_wait(); return 0; } diff --git a/progs/rbug/tex_dump.c b/progs/rbug/tex_dump.c index f9e06ee994a..963f8eeedea 100644 --- a/progs/rbug/tex_dump.c +++ b/progs/rbug/tex_dump.c @@ -27,6 +27,7 @@ #include "pipe/p_state.h" #include "util/u_memory.h" #include "util/u_debug.h" +#include "util/u_format.h" #include "util/u_network.h" #include "util/u_tile.h" #include "rbug/rbug.h" @@ -49,7 +50,7 @@ static void dump(rbug_texture_t tex, util_snprintf(filename, 512, "%llu_%s_%u.bmp", (unsigned long long)tex, pf_name(info->format), mip); - if (pf_is_compressed(info->format)) { + if (util_format_is_compressed(info->format)) { debug_printf("skipping: %s\n", filename); return; } diff --git a/progs/redbook/SConscript b/progs/redbook/SConscript index 242cb6647fc..24d7cff1b67 100644 --- a/progs/redbook/SConscript +++ b/progs/redbook/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ 'aaindex', 'aapoly', @@ -85,7 +67,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/redbook/aaindex.c b/progs/redbook/aaindex.c index 7dbc7b4b9b2..6011ec44b67 100644 --- a/progs/redbook/aaindex.c +++ b/progs/redbook/aaindex.c @@ -56,7 +56,7 @@ static float rotAngle = 0.; * at RAMP1START, and a blue color ramp starting * at RAMP2START. The ramps must be a multiple of 16. */ -void init(void) +static void init(void) { int i; @@ -76,7 +76,7 @@ void init(void) /* Draw 2 diagonal lines to form an X */ -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -101,7 +101,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -117,7 +117,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'r': diff --git a/progs/redbook/aapoly.c b/progs/redbook/aapoly.c index 757f0f48c43..b7b2b270902 100644 --- a/progs/redbook/aapoly.c +++ b/progs/redbook/aapoly.c @@ -59,7 +59,7 @@ static void init(void) #define NFACE 6 #define NVERT 8 -void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1, +static void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1, GLdouble z0, GLdouble z1) { static GLfloat v[8][3]; @@ -101,7 +101,7 @@ void drawCube(GLdouble x0, GLdouble x1, GLdouble y0, GLdouble y1, /* Note: polygons must be drawn from front to back * for proper blending. */ -void display(void) +static void display(void) { if (polySmooth) { glClear (GL_COLOR_BUFFER_BIT); @@ -126,7 +126,7 @@ void display(void) glFlush (); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -137,7 +137,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/redbook/aargb.c b/progs/redbook/aargb.c index f51984170e6..0021b549c2e 100644 --- a/progs/redbook/aargb.c +++ b/progs/redbook/aargb.c @@ -51,7 +51,7 @@ static float rotAngle = 0.; * blending, hint, and line width. Print out implementation * specific info on line width granularity and width. */ -void init(void) +static void init(void) { GLfloat values[2]; glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); @@ -72,7 +72,7 @@ void init(void) /* Draw 2 diagonal lines to form an X */ -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -97,7 +97,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); @@ -113,7 +113,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'r': diff --git a/progs/redbook/accanti.c b/progs/redbook/accanti.c index 12ca16f7a52..d1b25678419 100644 --- a/progs/redbook/accanti.c +++ b/progs/redbook/accanti.c @@ -45,7 +45,7 @@ /* Initialize lighting and other values. */ -void myinit(void) +static void myinit(void) { GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -68,7 +68,7 @@ void myinit(void) glClearAccum(0.0, 0.0, 0.0, 0.0); } -void displayObjects(void) +static void displayObjects(void) { GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 }; @@ -111,7 +111,7 @@ void displayObjects(void) #define ACSIZE 8 -void display(void) +static void display(void) { GLint viewport[4]; int jitter; @@ -137,7 +137,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/accpersp.c b/progs/redbook/accpersp.c index 46e369ae631..e172d0a917f 100644 --- a/progs/redbook/accpersp.c +++ b/progs/redbook/accpersp.c @@ -62,7 +62,7 @@ * probably want to insure that your ModelView matrix has been * initialized to identity before calling accFrustum(). */ -void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, +static void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) { @@ -99,7 +99,7 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, * * Note that accPerspective() calls accFrustum(). */ -void accPerspective(GLdouble fovy, GLdouble aspect, +static void accPerspective(GLdouble fovy, GLdouble aspect, GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) { @@ -119,7 +119,7 @@ void accPerspective(GLdouble fovy, GLdouble aspect, /* Initialize lighting and other values. */ -void init(void) +static void init(void) { GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -141,7 +141,7 @@ void init(void) glClearAccum(0.0, 0.0, 0.0, 0.0); } -void displayObjects(void) +static void displayObjects(void) { GLfloat torus_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; GLfloat cube_diffuse[] = { 0.0, 0.7, 0.7, 1.0 }; @@ -185,7 +185,7 @@ void displayObjects(void) #define ACSIZE 8 -void display(void) +static void display(void) { GLint viewport[4]; int jitter; @@ -205,13 +205,13 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/alpha.c b/progs/redbook/alpha.c index 6eeb45b96f1..b77c65e2c83 100644 --- a/progs/redbook/alpha.c +++ b/progs/redbook/alpha.c @@ -80,7 +80,7 @@ static void drawRightTriangle(void) glEnd(); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -96,7 +96,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -108,7 +108,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/redbook/alpha3D.c b/progs/redbook/alpha3D.c index 6169bd162be..494b1879d22 100644 --- a/progs/redbook/alpha3D.c +++ b/progs/redbook/alpha3D.c @@ -80,7 +80,7 @@ static void init(void) glEndList(); } -void display(void) +static void display(void) { GLfloat mat_solid[] = { 0.75, 0.75, 0.0, 1.0 }; GLfloat mat_zero[] = { 0.0, 0.0, 0.0, 1.0 }; @@ -113,7 +113,7 @@ void display(void) glutSwapBuffers(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLint) w, (GLint) h); glMatrixMode(GL_PROJECTION); @@ -128,7 +128,7 @@ void reshape(int w, int h) glLoadIdentity(); } -void animate(void) +static void animate(void) { static double t0 = -1.; if (solidZ <= MINZ || transparentZ >= MAXZ) @@ -150,7 +150,7 @@ void animate(void) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'a': diff --git a/progs/redbook/anti.c b/progs/redbook/anti.c index 9eab0bc3511..a97a3ebc948 100644 --- a/progs/redbook/anti.c +++ b/progs/redbook/anti.c @@ -49,7 +49,7 @@ * blending, hint, and line width. Print out implementation * specific info on line width granularity and width. */ -void myinit(void) +static void myinit(void) { GLfloat values[2]; glGetFloatv (GL_LINE_WIDTH_GRANULARITY, values); @@ -73,7 +73,7 @@ void myinit(void) /* display() draws an icosahedron with a large alpha value, 1.0. */ -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor4f (1.0, 1.0, 1.0, 1.0); @@ -81,7 +81,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/bezcurve.c b/progs/redbook/bezcurve.c index 5dee440396b..60a9c680802 100644 --- a/progs/redbook/bezcurve.c +++ b/progs/redbook/bezcurve.c @@ -45,7 +45,7 @@ GLfloat ctrlpoints[4][3] = { { -4.0, -4.0, 0.0}, { -2.0, 4.0, 0.0}, {2.0, -4.0, 0.0}, {4.0, 4.0, 0.0}}; -void init(void) +static void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); @@ -53,7 +53,7 @@ void init(void) glEnable(GL_MAP1_VERTEX_3); } -void display(void) +static void display(void) { int i; @@ -73,7 +73,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -89,7 +89,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/bezmesh.c b/progs/redbook/bezmesh.c index 55e7e827f2b..1abc7488bcb 100644 --- a/progs/redbook/bezmesh.c +++ b/progs/redbook/bezmesh.c @@ -68,7 +68,7 @@ GLfloat ctrlpoints[4][4][3] = {1.5, 1.5, -1.0}} }; -void +static void initlights(void) { GLfloat ambient[] = @@ -93,7 +93,7 @@ initlights(void) glMaterialfv(GL_FRONT, GL_SHININESS, mat_shininess); } -void +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -104,7 +104,7 @@ display(void) glFlush(); } -void +static void myinit(void) { glClearColor(0.0, 0.0, 0.0, 1.0); @@ -118,7 +118,7 @@ myinit(void) initlights(); /* for lighted version only */ } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/checker.c b/progs/redbook/checker.c index 06cbae7dd7e..60e6f7b60c8 100644 --- a/progs/redbook/checker.c +++ b/progs/redbook/checker.c @@ -50,7 +50,7 @@ #define checkImageHeight 64 GLubyte checkImage[checkImageWidth][checkImageHeight][3]; -void makeCheckImage(void) +static void makeCheckImage(void) { int i, j, c; @@ -64,7 +64,7 @@ void makeCheckImage(void) } } -void myinit(void) +static void myinit(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); @@ -84,7 +84,7 @@ void myinit(void) glShadeModel(GL_FLAT); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_QUADS); @@ -101,7 +101,7 @@ void display(void) glutSwapBuffers(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/clip.c b/progs/redbook/clip.c index 90816f2e278..85c464720db 100644 --- a/progs/redbook/clip.c +++ b/progs/redbook/clip.c @@ -42,13 +42,13 @@ #include <GL/glut.h> #include <stdlib.h> -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void display(void) +static void display(void) { GLdouble eqn[4] = {0.0, 1.0, 0.0, 0.0}; GLdouble eqn2[4] = {1.0, 0.0, 0.0, 0.0}; @@ -73,7 +73,7 @@ void display(void) glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -83,7 +83,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/colormat.c b/progs/redbook/colormat.c index 9db4491bac5..d77fcb1ed46 100644 --- a/progs/redbook/colormat.c +++ b/progs/redbook/colormat.c @@ -49,7 +49,7 @@ GLfloat diffuseMaterial[4] = { 0.5, 0.5, 0.5, 1.0 }; /* Initialize material property, light source, lighting model, * and depth buffer. */ -void init(void) +static void init(void) { GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 }; @@ -68,14 +68,14 @@ void init(void) glEnable(GL_COLOR_MATERIAL); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSolidSphere(1.0, 20, 16); glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -91,7 +91,7 @@ void reshape (int w, int h) } /* ARGSUSED2 */ -void mouse(int button, int state, int x, int y) +static void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: @@ -127,7 +127,7 @@ void mouse(int button, int state, int x, int y) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/cube.c b/progs/redbook/cube.c index 5ecc6280f33..3c6becb2157 100644 --- a/progs/redbook/cube.c +++ b/progs/redbook/cube.c @@ -44,13 +44,13 @@ #include <GL/glut.h> #include <stdlib.h> -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); @@ -62,7 +62,7 @@ void display(void) glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -72,7 +72,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/depthcue.c b/progs/redbook/depthcue.c index a3e5b743aa7..d4b604baf13 100644 --- a/progs/redbook/depthcue.c +++ b/progs/redbook/depthcue.c @@ -48,7 +48,7 @@ /* Initialize linear fog for depth cueing. */ -void myinit(void) +static void myinit(void) { GLfloat fogColor[4] = {0.0, 0.0, 0.0, 1.0}; @@ -67,7 +67,7 @@ void myinit(void) /* display() draws an icosahedron. */ -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); @@ -75,7 +75,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/dof.c b/progs/redbook/dof.c index 6673dc2d54f..8558f02deea 100644 --- a/progs/redbook/dof.c +++ b/progs/redbook/dof.c @@ -68,7 +68,7 @@ * probably want to insure that your ModelView matrix has been * initialized to identity before calling accFrustum(). */ -void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, +static void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) { @@ -105,7 +105,7 @@ void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, * * Note that accPerspective() calls accFrustum(). */ -void accPerspective(GLdouble fovy, GLdouble aspect, +static void accPerspective(GLdouble fovy, GLdouble aspect, GLdouble nnear, GLdouble ffar, GLdouble pixdx, GLdouble pixdy, GLdouble eyedx, GLdouble eyedy, GLdouble focus) { @@ -123,7 +123,7 @@ void accPerspective(GLdouble fovy, GLdouble aspect, pixdx, pixdy, eyedx, eyedy, focus); } -void myinit(void) +static void myinit(void) { GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -155,7 +155,7 @@ void myinit(void) glClearAccum(0.0, 0.0, 0.0, 0.0); } -void renderTeapot (GLfloat x, GLfloat y, GLfloat z, +static void renderTeapot (GLfloat x, GLfloat y, GLfloat z, GLfloat ambr, GLfloat ambg, GLfloat ambb, GLfloat difr, GLfloat difg, GLfloat difb, GLfloat specr, GLfloat specg, GLfloat specb, GLfloat shine) @@ -182,7 +182,7 @@ void renderTeapot (GLfloat x, GLfloat y, GLfloat z, * magnitude of the accPerspective() jitter; in this example, 0.33. * In this example, the teapots are drawn 8 times. See jitter.h */ -void display(void) +static void display(void) { int jitter; GLint viewport[4]; @@ -214,7 +214,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); } diff --git a/progs/redbook/double.c b/progs/redbook/double.c index 3153c70cc1d..c4ead224dc8 100644 --- a/progs/redbook/double.c +++ b/progs/redbook/double.c @@ -47,7 +47,7 @@ static GLfloat spin = 0.0; static GLdouble t0 = 0.; -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glPushMatrix(); @@ -59,12 +59,12 @@ void display(void) glutSwapBuffers(); } -GLdouble gettime(void) +static GLdouble gettime(void) { return (GLdouble)(glutGet(GLUT_ELAPSED_TIME)) / 1000.; } -void spinDisplay(void) +static void spinDisplay(void) { GLdouble t, dt; t = gettime(); @@ -76,13 +76,13 @@ void spinDisplay(void) glutPostRedisplay(); } -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -93,7 +93,7 @@ void reshape(int w, int h) } /* ARGSUSED2 */ -void mouse(int button, int state, int x, int y) +static void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: diff --git a/progs/redbook/drawf.c b/progs/redbook/drawf.c index 5bcccb6aeac..6c048be7844 100644 --- a/progs/redbook/drawf.c +++ b/progs/redbook/drawf.c @@ -48,13 +48,13 @@ GLubyte rasters[24] = { 0xff, 0x00, 0xff, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xc0, 0x00, 0xff, 0xc0, 0xff, 0xc0}; -void init(void) +static void init(void) { glPixelStorei (GL_UNPACK_ALIGNMENT, 1); glClearColor (0.0, 0.0, 0.0, 0.0); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); @@ -65,7 +65,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -75,7 +75,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/feedback.c b/progs/redbook/feedback.c index cc685d55d34..3c8c8cc7eaf 100644 --- a/progs/redbook/feedback.c +++ b/progs/redbook/feedback.c @@ -48,7 +48,7 @@ /* Initialize lighting. */ -void init(void) +static void init(void) { glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); @@ -58,7 +58,7 @@ void init(void) * be clipped. If in feedback mode, a passthrough token * is issued between the each primitive. */ -void drawGeometry (GLenum mode) +static void drawGeometry (GLenum mode) { glBegin (GL_LINE_STRIP); glNormal3f (0.0, 0.0, 1.0); @@ -80,8 +80,8 @@ void drawGeometry (GLenum mode) } /* Write contents of one vertex to stdout. */ -void print3DcolorVertex (GLint size, GLint *count, - GLfloat *buffer) +static void print3DcolorVertex (GLint size, GLint *count, + GLfloat *buffer) { int i; @@ -94,7 +94,7 @@ void print3DcolorVertex (GLint size, GLint *count, } /* Write contents of entire buffer. (Parse tokens!) */ -void printBuffer(GLint size, GLfloat *buffer) +static void printBuffer(GLint size, GLfloat *buffer) { GLint count; GLfloat token; @@ -124,7 +124,7 @@ void printBuffer(GLint size, GLfloat *buffer) } } -void display(void) +static void display(void) { GLfloat feedBuffer[1024]; GLint size; @@ -148,7 +148,7 @@ void display(void) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/fog.c b/progs/redbook/fog.c index 14c7700eccf..4f4b8e3cc0a 100644 --- a/progs/redbook/fog.c +++ b/progs/redbook/fog.c @@ -52,7 +52,7 @@ GLint fogMode; -void +static void selectFog(int mode) { switch(mode) { @@ -73,7 +73,7 @@ selectFog(int mode) /* Initialize z-buffer, projection matrix, light source, * and lighting model. Do not specify a material property here. */ -void +static void myinit(void) { GLfloat position[] = @@ -106,7 +106,7 @@ myinit(void) } } -void +static void renderRedTeapot(GLfloat x, GLfloat y, GLfloat z) { float mat[4]; @@ -133,7 +133,7 @@ renderRedTeapot(GLfloat x, GLfloat y, GLfloat z) /* display() draws 5 teapots at different z positions. */ -void +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -145,7 +145,7 @@ display(void) glFlush(); } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/fogindex.c b/progs/redbook/fogindex.c index b8bb691e288..6b5aa353caa 100644 --- a/progs/redbook/fogindex.c +++ b/progs/redbook/fogindex.c @@ -53,7 +53,7 @@ #define NUM_COLORS 32 #define RAMPSTART 16 -void +static void myinit(void) { int i; @@ -77,7 +77,7 @@ myinit(void) /* display() renders 3 cones at different z positions. */ -void +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -104,7 +104,7 @@ display(void) glFlush(); } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/font.c b/progs/redbook/font.c index 2d92e9b6003..c7a1035aa99 100644 --- a/progs/redbook/font.c +++ b/progs/redbook/font.c @@ -80,7 +80,7 @@ GLubyte letters[][13] = { GLuint fontOffset; -void makeRasterFont(void) +static void makeRasterFont(void) { GLuint i, j; glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -96,13 +96,13 @@ void makeRasterFont(void) glEndList(); } -void init(void) +static void init(void) { glShadeModel (GL_FLAT); makeRasterFont(); } -void printString(char *s) +static void printString(char *s) { glPushAttrib (GL_LIST_BIT); glListBase(fontOffset); @@ -115,7 +115,7 @@ void printString(char *s) * to call makeRasterFont() before you start making * calls to printString(). */ -void display(void) +static void display(void) { GLfloat white[3] = { 1.0, 1.0, 1.0 }; @@ -129,7 +129,7 @@ void display(void) glFlush (); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -139,7 +139,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/hello.c b/progs/redbook/hello.c index fb3dae13252..84183b25b9f 100644 --- a/progs/redbook/hello.c +++ b/progs/redbook/hello.c @@ -42,7 +42,7 @@ #include <stdlib.h> #include <GL/glut.h> -void display(void) +static void display(void) { /* clear all pixels */ glClear (GL_COLOR_BUFFER_BIT); @@ -64,7 +64,7 @@ void display(void) glFlush (); } -void init (void) +static void init (void) { /* select clearing color */ glClearColor (0.0, 0.0, 0.0, 0.0); diff --git a/progs/redbook/image.c b/progs/redbook/image.c index dc1a7246eba..fa3b46f5ed4 100644 --- a/progs/redbook/image.c +++ b/progs/redbook/image.c @@ -58,7 +58,7 @@ GLubyte checkImage[checkImageHeight][checkImageWidth][3]; static GLdouble zoomFactor = 1.0; static GLint height; -void makeCheckImage(void) +static void makeCheckImage(void) { int i, j, c; @@ -72,7 +72,7 @@ void makeCheckImage(void) } } -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); @@ -80,7 +80,7 @@ void init(void) glPixelStorei(GL_UNPACK_ALIGNMENT, 1); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glRasterPos2i(0, 0); @@ -89,7 +89,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); height = (GLint) h; @@ -100,7 +100,7 @@ void reshape(int w, int h) glLoadIdentity(); } -void motion(int x, int y) +static void motion(int x, int y) { static GLint screeny; @@ -113,7 +113,7 @@ void motion(int x, int y) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'r': diff --git a/progs/redbook/light.c b/progs/redbook/light.c index 0eed85e10c2..9431dce508e 100644 --- a/progs/redbook/light.c +++ b/progs/redbook/light.c @@ -47,7 +47,7 @@ /* Initialize material property, light source, lighting model, * and depth buffer. */ -void init(void) +static void init(void) { GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_shininess[] = { 50.0 }; @@ -65,14 +65,14 @@ void init(void) glEnable(GL_DEPTH_TEST); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glutSolidSphere (1.0, 20, 16); glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -88,7 +88,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/lines.c b/progs/redbook/lines.c index b34d4c418c6..9f12da9acfe 100644 --- a/progs/redbook/lines.c +++ b/progs/redbook/lines.c @@ -46,13 +46,13 @@ #define drawOneLine(x1,y1,x2,y2) glBegin(GL_LINES); \ glVertex2f ((x1),(y1)); glVertex2f ((x2),(y2)); glEnd(); -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void display(void) +static void display(void) { int i; @@ -104,7 +104,7 @@ void display(void) glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -113,7 +113,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/list.c b/progs/redbook/list.c index 3b4f44bd6da..5dea26fcad1 100644 --- a/progs/redbook/list.c +++ b/progs/redbook/list.c @@ -69,7 +69,7 @@ static void drawLine (void) glEnd (); } -void display(void) +static void display(void) { GLuint i; @@ -82,7 +82,7 @@ void display(void) glFlush (); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); @@ -97,7 +97,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/material.c b/progs/redbook/material.c index f9a4fc59288..5edddd9ef84 100644 --- a/progs/redbook/material.c +++ b/progs/redbook/material.c @@ -49,7 +49,7 @@ /* Initialize z-buffer, projection matrix, light source, * and lighting model. Do not specify a material property here. */ -void myinit(void) +static void myinit(void) { GLfloat ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -87,7 +87,7 @@ void myinit(void) * glTranslatef() is used to move spheres to their appropriate locations. */ -void display(void) +static void display(void) { GLfloat no_mat[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat mat_ambient[] = { 0.7, 0.7, 0.7, 1.0 }; @@ -260,7 +260,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/mipmap.c b/progs/redbook/mipmap.c index d32dd725f4b..dadde055bef 100644 --- a/progs/redbook/mipmap.c +++ b/progs/redbook/mipmap.c @@ -54,7 +54,7 @@ GLubyte mipmapImage4[4][4][3]; GLubyte mipmapImage2[2][2][3]; GLubyte mipmapImage1[1][1][3]; -void makeImages(void) +static void makeImages(void) { int i, j; @@ -98,7 +98,7 @@ void makeImages(void) mipmapImage1[0][0][2] = 255; } -void myinit(void) +static void myinit(void) { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LESS); @@ -128,7 +128,7 @@ void myinit(void) glEnable(GL_TEXTURE_2D); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBegin(GL_QUADS); @@ -140,7 +140,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/model.c b/progs/redbook/model.c index 8411ef355f1..f7c92f4f87c 100644 --- a/progs/redbook/model.c +++ b/progs/redbook/model.c @@ -42,13 +42,13 @@ #include <GL/glut.h> #include <stdlib.h> -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void draw_triangle(void) +static void draw_triangle(void) { glBegin (GL_LINE_LOOP); glVertex2f(0.0, 25.0); @@ -57,7 +57,7 @@ void draw_triangle(void) glEnd(); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); @@ -86,7 +86,7 @@ void display(void) glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -101,7 +101,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/movelight.c b/progs/redbook/movelight.c index a108cad439a..93758a222a4 100644 --- a/progs/redbook/movelight.c +++ b/progs/redbook/movelight.c @@ -58,7 +58,7 @@ static int spin = 0; /* Initialize material property, light source, lighting model, * and depth buffer. */ -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); @@ -72,7 +72,7 @@ void init(void) * light at a new position in world coordinates. The cube * represents the position of the light. */ -void display(void) +static void display(void) { GLfloat position[] = { 0.0, 0.0, 1.5, 1.0 }; @@ -96,7 +96,7 @@ void display(void) glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -107,7 +107,7 @@ void reshape (int w, int h) } /* ARGSUSED2 */ -void mouse(int button, int state, int x, int y) +static void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: @@ -122,7 +122,7 @@ void mouse(int button, int state, int x, int y) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/nurbs.c b/progs/redbook/nurbs.c index a7c6f0c696e..fe03ce667ed 100644 --- a/progs/redbook/nurbs.c +++ b/progs/redbook/nurbs.c @@ -89,7 +89,7 @@ GLUnurbsObj *theNurb; /* Initialize material property, light source, lighting model, * and depth buffer. */ -void myinit(void) +static void myinit(void) { GLfloat mat_ambient[] = { 1.0, 1.0, 1.0, 1.0 }; GLfloat mat_diffuse[] = { 1.0, 0.2, 1.0, 1.0 }; @@ -122,7 +122,7 @@ void myinit(void) gluNurbsProperty(theNurb, GLU_DISPLAY_MODE, GLU_FILL); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -147,7 +147,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/pickdepth.c b/progs/redbook/pickdepth.c index ad5bdc81994..91d44a38c0a 100644 --- a/progs/redbook/pickdepth.c +++ b/progs/redbook/pickdepth.c @@ -51,7 +51,7 @@ #include <stdio.h> #include <GL/glut.h> -void +static void myinit(void) { glClearColor(0.0, 0.0, 0.0, 0.0); @@ -65,7 +65,7 @@ myinit(void) * each rectangle is given the same name. Note that * each rectangle is drawn with a different z value. */ -void +static void drawRects(GLenum mode) { if (mode == GL_SELECT) @@ -100,7 +100,7 @@ drawRects(GLenum mode) /* processHits() prints out the contents of the * selection array. */ -void +static void processHits(GLint hits, GLuint buffer[]) { GLint i; @@ -131,7 +131,7 @@ processHits(GLint hits, GLuint buffer[]) */ #define BUFSIZE 512 -void +static void pickRects(int button, int state, int x, int y) { GLuint selectBuf[BUFSIZE]; @@ -164,7 +164,7 @@ pickRects(int button, int state, int x, int y) processHits(hits, selectBuf); } -void +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -172,7 +172,7 @@ display(void) glutSwapBuffers(); } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/picksquare.c b/progs/redbook/picksquare.c index 636edc97b4b..cc092dbf538 100644 --- a/progs/redbook/picksquare.c +++ b/progs/redbook/picksquare.c @@ -49,7 +49,7 @@ int board[3][3]; /* amount of color for each square */ /* Clear color value for every square on the board */ -void init(void) +static void init(void) { int i, j; for (i = 0; i < 3; i++) @@ -64,7 +64,7 @@ void init(void) * square is determined by its position on the grid, and * the value in the board[][] array. */ -void drawSquares(GLenum mode) +static void drawSquares(GLenum mode) { GLuint i, j; for (i = 0; i < 3; i++) { @@ -85,7 +85,7 @@ void drawSquares(GLenum mode) /* processHits prints out the contents of the * selection array. */ -void processHits (GLint hits, GLuint buffer[]) +static void processHits (GLint hits, GLuint buffer[]) { GLint i; GLuint j, ii = 0, jj = 0, names, *ptr; @@ -117,7 +117,7 @@ void processHits (GLint hits, GLuint buffer[]) */ #define BUFSIZE 512 -void pickSquares(int button, int state, int x, int y) +static void pickSquares(int button, int state, int x, int y) { GLuint selectBuf[BUFSIZE]; GLint hits; @@ -152,14 +152,14 @@ void pickSquares(int button, int state, int x, int y) glutPostRedisplay(); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); drawSquares (GL_RENDER); glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); @@ -170,7 +170,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/plane.c b/progs/redbook/plane.c index dc17f7b2386..2c2e2d24d93 100644 --- a/progs/redbook/plane.c +++ b/progs/redbook/plane.c @@ -47,7 +47,7 @@ /* Initialize material property, light source, and lighting model. */ -void myinit(void) +static void myinit(void) { GLfloat mat_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; /* mat_specular and mat_shininess are NOT default values */ @@ -75,7 +75,7 @@ void myinit(void) glEnable(GL_DEPTH_TEST); } -void drawPlane(void) +static void drawPlane(void) { glBegin (GL_QUADS); glNormal3f (0.0, 0.0, 1.0); @@ -104,7 +104,7 @@ void drawPlane(void) glEnd(); } -void display (void) +static void display (void) { GLfloat infinite_light[] = { 1.0, 1.0, 1.0, 0.0 }; GLfloat local_light[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -125,7 +125,7 @@ void display (void) glFlush (); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); diff --git a/progs/redbook/planet.c b/progs/redbook/planet.c index e13672d3f63..cc428b4e427 100644 --- a/progs/redbook/planet.c +++ b/progs/redbook/planet.c @@ -47,13 +47,13 @@ static int year = 0, day = 0; -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); @@ -68,7 +68,7 @@ void display(void) glutSwapBuffers(); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -80,7 +80,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard (unsigned char key, int x, int y) +static void keyboard (unsigned char key, int x, int y) { switch (key) { case 'd': diff --git a/progs/redbook/polyoff.c b/progs/redbook/polyoff.c index de34b2e7675..0e0ce86ec91 100644 --- a/progs/redbook/polyoff.c +++ b/progs/redbook/polyoff.c @@ -60,7 +60,7 @@ GLboolean doubleBuffer; /* display() draws two spheres, one with a gray, diffuse material, * the other sphere with a magenta material with a specular highlight. */ -void display (void) +static void display (void) { GLfloat gray[] = { 0.8, 0.8, 0.8, 1.0 }; GLfloat black[] = { 0.0, 0.0, 0.0, 1.0 }; @@ -108,7 +108,7 @@ void display (void) * create display list with sphere * initialize lighting and depth buffer */ -void gfxinit (void) +static void gfxinit (void) { GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -134,7 +134,7 @@ void gfxinit (void) } /* call when window is resized */ -void reshape(int width, int height) +static void reshape(int width, int height) { glViewport (0, 0, width, height); glMatrixMode (GL_PROJECTION); @@ -176,7 +176,7 @@ static void Benchmark( float xdiff, float ydiff ) /* call when mouse button is pressed */ /* ARGSUSED2 */ -void mouse(int button, int state, int x, int y) { +static void mouse(int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: switch (state) { @@ -213,7 +213,7 @@ void mouse(int button, int state, int x, int y) { } /* ARGSUSED1 */ -void keyboard (unsigned char key, int x, int y) +static void keyboard (unsigned char key, int x, int y) { switch (key) { case 't': @@ -268,20 +268,7 @@ void keyboard (unsigned char key, int x, int y) fflush(stdout); } -static void -key(unsigned char k, int x, int y) -{ - switch (k) { - case 27: /* Escape */ - exit(0); - break; - default: - return; - } - glutPostRedisplay(); -} - -GLenum Args(int argc, char **argv) +static GLenum Args(int argc, char **argv) { GLint i; diff --git a/progs/redbook/polys.c b/progs/redbook/polys.c index 409abd17531..eeffe2301ce 100644 --- a/progs/redbook/polys.c +++ b/progs/redbook/polys.c @@ -44,7 +44,7 @@ #include <stdlib.h> #include <GL/glut.h> -void display(void) +static void display(void) { GLubyte fly[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x80, 0x01, 0xC0, 0x06, 0xC0, 0x03, 0x60, 0x04, 0x60, 0x06, 0x20, @@ -89,7 +89,7 @@ void display(void) glFlush (); } -void myinit (void) +static void myinit (void) { /* clear background to black */ glClearColor (0.0, 0.0, 0.0, 0.0); diff --git a/progs/redbook/quadric.c b/progs/redbook/quadric.c index 4e46c85f829..1cbd395e47b 100644 --- a/progs/redbook/quadric.c +++ b/progs/redbook/quadric.c @@ -54,7 +54,7 @@ GLuint startList; -void CALLBACK errorCallback(GLenum errorCode) +static void CALLBACK errorCallback(GLenum errorCode) { const GLubyte *estring; @@ -63,7 +63,7 @@ void CALLBACK errorCallback(GLenum errorCode) exit(0); } -void init(void) +static void init(void) { GLUquadricObj *qobj; GLfloat mat_ambient[] = { 0.5, 0.5, 0.5, 1.0 }; @@ -116,9 +116,11 @@ void init(void) glNewList(startList+3, GL_COMPILE); gluPartialDisk(qobj, 0.0, 1.0, 20, 4, 0.0, 225.0); glEndList(); + + gluDeleteQuadric(qobj); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); @@ -148,7 +150,7 @@ void display(void) glFlush(); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -164,7 +166,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/robot.c b/progs/redbook/robot.c index 94e20ac71eb..c90b72ab3ea 100644 --- a/progs/redbook/robot.c +++ b/progs/redbook/robot.c @@ -47,13 +47,13 @@ static int shoulder = 0, elbow = 0; -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_FLAT); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT); glPushMatrix(); @@ -77,7 +77,7 @@ void display(void) glutSwapBuffers(); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -89,7 +89,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard (unsigned char key, int x, int y) +static void keyboard (unsigned char key, int x, int y) { switch (key) { case 's': diff --git a/progs/redbook/sccolorlight.c b/progs/redbook/sccolorlight.c index 0ea750e5846..d9e0a254e90 100644 --- a/progs/redbook/sccolorlight.c +++ b/progs/redbook/sccolorlight.c @@ -49,7 +49,7 @@ /* Initialize material property and light source. */ -void myinit(void) +static void myinit(void) { GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 0.0, 1.0, 1.0 }; @@ -68,7 +68,7 @@ void myinit(void) glEnable(GL_DEPTH_TEST); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix (); @@ -95,7 +95,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/scene.c b/progs/redbook/scene.c index c3abc727b78..6f336a8db46 100644 --- a/progs/redbook/scene.c +++ b/progs/redbook/scene.c @@ -48,7 +48,7 @@ /* Initialize material property and light source. */ -void myinit (void) +static void myinit (void) { GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -67,7 +67,7 @@ void myinit (void) glEnable(GL_DEPTH_TEST); } -void display (void) +static void display (void) { glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -95,7 +95,7 @@ void display (void) glFlush (); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport (0, 0, w, h); glMatrixMode (GL_PROJECTION); diff --git a/progs/redbook/scenebamb.c b/progs/redbook/scenebamb.c index e7264d2003f..ea605f8c737 100644 --- a/progs/redbook/scenebamb.c +++ b/progs/redbook/scenebamb.c @@ -47,7 +47,7 @@ /* Initialize light source and lighting. */ -void myinit(void) +static void myinit(void) { GLfloat light_ambient[] = { 0.0, 0.0, 1.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -66,7 +66,7 @@ void myinit(void) glEnable(GL_DEPTH_TEST); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -94,7 +94,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/sceneflat.c b/progs/redbook/sceneflat.c index 10891fb9977..1b277334f5c 100644 --- a/progs/redbook/sceneflat.c +++ b/progs/redbook/sceneflat.c @@ -46,7 +46,7 @@ /* Initialize light source and shading model (GL_FLAT). */ -void myinit(void) +static void myinit(void) { GLfloat light_ambient[] = { 0.0, 0.0, 0.0, 1.0 }; GLfloat light_diffuse[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -66,7 +66,7 @@ void myinit(void) glShadeModel (GL_FLAT); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -94,7 +94,7 @@ void display(void) glFlush(); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/select.c b/progs/redbook/select.c index 928373b8796..537d5194d46 100644 --- a/progs/redbook/select.c +++ b/progs/redbook/select.c @@ -57,7 +57,7 @@ /* draw a triangle with vertices at (x1, y1), (x2, y2) * and (x3, y3) at z units away from the origin. */ -void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, +static void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2, GLfloat x3, GLfloat y3, GLfloat z) { glBegin (GL_TRIANGLES); @@ -68,8 +68,8 @@ void drawTriangle (GLfloat x1, GLfloat y1, GLfloat x2, } /* draw a rectangular box with these outer x, y, and z values */ -void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, - GLfloat y2, GLfloat z1, GLfloat z2) +static void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, + GLfloat y2, GLfloat z1, GLfloat z2) { glColor3f (1.0, 1.0, 1.0); glBegin (GL_LINE_LOOP); @@ -101,7 +101,7 @@ void drawViewVolume (GLfloat x1, GLfloat x2, GLfloat y1, /* drawScene draws 4 triangles and a wire frame * which represents the viewing volume. */ -void drawScene (void) +static void drawScene (void) { glMatrixMode (GL_PROJECTION); glLoadIdentity (); @@ -122,7 +122,7 @@ void drawScene (void) /* processHits prints out the contents of the selection array */ -void processHits (GLint hits, GLuint buffer[]) +static void processHits (GLint hits, GLuint buffer[]) { GLint i; GLuint j, names, *ptr; @@ -150,7 +150,7 @@ void processHits (GLint hits, GLuint buffer[]) */ #define BUFSIZE 512 -void selectObjects(void) +static void selectObjects(void) { GLuint selectBuf[BUFSIZE]; GLint hits; @@ -181,13 +181,13 @@ void selectObjects(void) processHits (hits, selectBuf); } -void init (void) +static void init (void) { glEnable(GL_DEPTH_TEST); glShadeModel(GL_FLAT); } -void display(void) +static void display(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -197,7 +197,7 @@ void display(void) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/smooth.c b/progs/redbook/smooth.c index 9d22fc90251..874033d5adf 100644 --- a/progs/redbook/smooth.c +++ b/progs/redbook/smooth.c @@ -43,13 +43,13 @@ #include <GL/glut.h> #include <stdlib.h> -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); } -void triangle(void) +static void triangle(void) { glBegin (GL_TRIANGLES); glColor3f (1.0, 0.0, 0.0); @@ -61,14 +61,14 @@ void triangle(void) glEnd(); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT); triangle (); glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -81,7 +81,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/stencil.c b/progs/redbook/stencil.c index b33e40a0307..5325abf8b77 100644 --- a/progs/redbook/stencil.c +++ b/progs/redbook/stencil.c @@ -64,7 +64,7 @@ #define YELLOWMAT 1 #define BLUEMAT 2 -void myinit (void) +static void myinit (void) { GLfloat yellow_diffuse[] = { 0.7, 0.7, 0.0, 1.0 }; GLfloat yellow_specular[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -101,7 +101,7 @@ void myinit (void) /* Draw a sphere in a diamond-shaped section in the * middle of a window with 2 tori. */ -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -132,7 +132,7 @@ void display(void) /* Whenever the window is reshaped, redefine the * coordinate system and redraw the stencil area. */ -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/stroke.c b/progs/redbook/stroke.c index 19b0391cbae..68b639abf4f 100644 --- a/progs/redbook/stroke.c +++ b/progs/redbook/stroke.c @@ -87,7 +87,7 @@ CP Sdata[] = { /* drawLetter() interprets the instructions from the array * for that letter and renders the letter with line segments. */ -void drawLetter(CP *l) +static void drawLetter(CP *l) { glBegin(GL_LINE_STRIP); for (;;) { @@ -111,7 +111,7 @@ void drawLetter(CP *l) } /* Create a display list for each of 6 characters */ -void myinit (void) +static void myinit (void) { GLuint base; @@ -130,13 +130,13 @@ void myinit (void) char *test1 = "A SPARE SERAPE APPEARS AS"; char *test2 = "APES PREPARE RARE PEPPERS"; -void printStrokedString(char *s) +static void printStrokedString(char *s) { GLsizei len = (GLsizei) strlen(s); glCallLists(len, GL_BYTE, (GLbyte *)s); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); diff --git a/progs/redbook/surface.c b/progs/redbook/surface.c index e33ce14f4fc..f0c5ab0b47c 100644 --- a/progs/redbook/surface.c +++ b/progs/redbook/surface.c @@ -53,7 +53,7 @@ GLUnurbsObj *theNurb; * Initializes the control points of the surface to a small hill. * The control points range from -3 to +3 in x, y, and z */ -void init_surface(void) +static void init_surface(void) { int u, v; for (u = 0; u < 4; u++) { @@ -71,7 +71,7 @@ void init_surface(void) /* Initialize material property and depth buffer. */ -void myinit(void) +static void myinit(void) { GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -100,7 +100,7 @@ void myinit(void) glTranslatef (0.0, 0.0, -5.0); } -void display(void) +static void display(void) { GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; int i, j; @@ -140,7 +140,7 @@ void display(void) glutSwapBuffers(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); @@ -150,7 +150,7 @@ void reshape(int w, int h) glMatrixMode(GL_MODELVIEW); } -void +static void menu(int value) { switch (value) { @@ -171,7 +171,7 @@ menu(int value) int down = 0, lastx; /* ARGSUSED1 */ -void +static void motion(int x, int y) { if (down) { @@ -182,7 +182,7 @@ motion(int x, int y) } /* ARGSUSED3 */ -void +static void mouse(int button, int state, int x, int y) { if (button == GLUT_LEFT_BUTTON) { diff --git a/progs/redbook/teaambient.c b/progs/redbook/teaambient.c index 53b5111752f..20ff1a4a33b 100644 --- a/progs/redbook/teaambient.c +++ b/progs/redbook/teaambient.c @@ -47,7 +47,7 @@ /* Initialize light source and lighting model. */ -void +static void myinit(void) { GLfloat light_ambient[] = @@ -78,7 +78,7 @@ myinit(void) glEnable(GL_DEPTH_TEST); } -void +static void display(void) { GLfloat low_ambient[] = @@ -114,7 +114,7 @@ display(void) glFlush(); } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/teapots.c b/progs/redbook/teapots.c index fb7aed380eb..102c18a3e33 100644 --- a/progs/redbook/teapots.c +++ b/progs/redbook/teapots.c @@ -49,7 +49,7 @@ * Initialize depth buffer, projection matrix, light source, and lighting * model. Do not specify a material property here. */ -void +static void myinit(void) { GLfloat ambient[] = @@ -83,7 +83,7 @@ myinit(void) * Move object into position. Use 3rd through 12th parameters to specify the * material property. Draw a teapot. */ -void +static void renderTeapot(GLfloat x, GLfloat y, GLfloat ambr, GLfloat ambg, GLfloat ambb, GLfloat difr, GLfloat difg, GLfloat difb, @@ -117,7 +117,7 @@ renderTeapot(GLfloat x, GLfloat y, * 3rd column: black, cyan, green, red, white, yellow plastic * 4th column: black, cyan, green, red, white, yellow rubber */ -void +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -173,7 +173,7 @@ display(void) glFlush(); } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/redbook/tess.c b/progs/redbook/tess.c index 238a469aff2..0bf8a8eb986 100644 --- a/progs/redbook/tess.c +++ b/progs/redbook/tess.c @@ -61,7 +61,7 @@ GLuint startList; -void display (void) { +static void display (void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glCallList(startList); @@ -69,12 +69,12 @@ void display (void) { glFlush(); } -void CALLBACK beginCallback(GLenum which) +static void CALLBACK beginCallback(GLenum which) { glBegin(which); } -void CALLBACK errorCallback(GLenum errorCode) +static void CALLBACK errorCallback(GLenum errorCode) { const GLubyte *estring; @@ -83,12 +83,12 @@ void CALLBACK errorCallback(GLenum errorCode) exit(0); } -void CALLBACK endCallback(void) +static void CALLBACK endCallback(void) { glEnd(); } -void CALLBACK vertexCallback(GLvoid *vertex) +static void CALLBACK vertexCallback(GLvoid *vertex) { const GLdouble *pointer; @@ -102,7 +102,7 @@ void CALLBACK vertexCallback(GLvoid *vertex) * but weight[4] may be used to average color, normal, or texture * coordinate data. In this program, color is weighted. */ -void CALLBACK combineCallback(GLdouble coords[3], +static void CALLBACK combineCallback(GLdouble coords[3], GLdouble *vertex_data[4], GLfloat weight[4], GLdouble **dataOut ) { @@ -122,7 +122,7 @@ void CALLBACK combineCallback(GLdouble coords[3], *dataOut = vertex; } -void init (void) +static void init (void) { GLUtesselator *tobj; GLdouble rect[4][3] = {{50.0, 50.0, 0.0}, @@ -199,7 +199,7 @@ void init (void) gluDeleteTess(tobj); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -208,7 +208,7 @@ void reshape (int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/tesswind.c b/progs/redbook/tesswind.c index 7d00c9f907d..4729880a57e 100644 --- a/progs/redbook/tesswind.c +++ b/progs/redbook/tesswind.c @@ -61,7 +61,7 @@ GLuint list; /* Make four display lists, * each with a different tessellated object. */ -void makeNewLists (void) { +static void makeNewLists (void) { int i; static GLdouble rects[12][3] = {{ 50.0, 50.0, 0.0}, {300.0, 50.0, 0.0}, @@ -153,7 +153,7 @@ void makeNewLists (void) { glEndList(); } -void display (void) { +static void display (void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); glPushMatrix(); @@ -168,12 +168,12 @@ void display (void) { glFlush(); } -void CALLBACK beginCallback(GLenum which) +static void CALLBACK beginCallback(GLenum which) { glBegin(which); } -void CALLBACK errorCallback(GLenum errorCode) +static void CALLBACK errorCallback(GLenum errorCode) { const GLubyte *estring; @@ -182,7 +182,7 @@ void CALLBACK errorCallback(GLenum errorCode) exit(0); } -void CALLBACK endCallback(void) +static void CALLBACK endCallback(void) { glEnd(); } @@ -193,7 +193,7 @@ void CALLBACK endCallback(void) * coordinate data. */ /* ARGSUSED */ -void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4], +static void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4], GLfloat weight[4], GLdouble **dataOut ) { GLdouble *vertex; @@ -205,7 +205,7 @@ void CALLBACK combineCallback(GLdouble coords[3], GLdouble *data[4], *dataOut = vertex; } -void init(void) +static void init(void) { glClearColor(0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); @@ -226,7 +226,7 @@ void init(void) makeNewLists(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -240,7 +240,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'w': diff --git a/progs/redbook/texbind.c b/progs/redbook/texbind.c index 6a828ab2bdf..b6404b32d8c 100644 --- a/progs/redbook/texbind.c +++ b/progs/redbook/texbind.c @@ -52,7 +52,7 @@ static GLubyte otherImage[checkImageHeight][checkImageWidth][4]; static GLuint texName[2]; -void makeCheckImages(void) +static void makeCheckImages(void) { int i, j, c; @@ -72,7 +72,7 @@ void makeCheckImages(void) } } -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); @@ -105,7 +105,7 @@ void init(void) glEnable(GL_TEXTURE_2D); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glBindTexture(GL_TEXTURE_2D, texName[0]); @@ -125,7 +125,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -137,7 +137,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/texgen.c b/progs/redbook/texgen.c index 7c1802a3be9..5cb97e5a43d 100644 --- a/progs/redbook/texgen.c +++ b/progs/redbook/texgen.c @@ -60,7 +60,7 @@ GLubyte stripeImage[4*stripeImageWidth]; static GLuint texName; #endif -void makeStripeImage(void) +static void makeStripeImage(void) { int j; @@ -79,7 +79,7 @@ static GLfloat *currentCoeff; static GLenum currentPlane; static GLint currentGenMode; -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); @@ -122,7 +122,7 @@ void init(void) glMaterialf (GL_FRONT, GL_SHININESS, 64.0); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -136,7 +136,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -152,7 +152,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard (unsigned char key, int x, int y) +static void keyboard (unsigned char key, int x, int y) { switch (key) { case 'e': diff --git a/progs/redbook/texprox.c b/progs/redbook/texprox.c index 6f1e853facd..c2d699a71b2 100644 --- a/progs/redbook/texprox.c +++ b/progs/redbook/texprox.c @@ -53,7 +53,7 @@ #define GL_TEXTURE_INTERNAL_FORMAT GL_TEXTURE_COMPONENTS #endif -void init(void) +static void init(void) { GLint proxyComponents; @@ -84,12 +84,12 @@ void init(void) putchar('\n'); } -void display(void) +static void display(void) { exit(0); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); diff --git a/progs/redbook/texsub.c b/progs/redbook/texsub.c index 4e829675aba..7827d5a45f3 100644 --- a/progs/redbook/texsub.c +++ b/progs/redbook/texsub.c @@ -58,7 +58,7 @@ static GLubyte subImage[subImageHeight][subImageWidth][4]; static GLuint texName; -void makeCheckImages(void) +static void makeCheckImages(void) { int i, j, c; @@ -82,7 +82,7 @@ void makeCheckImages(void) } } -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); @@ -102,7 +102,7 @@ void init(void) 0, GL_RGBA, GL_UNSIGNED_BYTE, checkImage); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); @@ -123,7 +123,7 @@ void display(void) glDisable(GL_TEXTURE_2D); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -135,7 +135,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard (unsigned char key, int x, int y) +static void keyboard (unsigned char key, int x, int y) { switch (key) { case 's': diff --git a/progs/redbook/texturesurf.c b/progs/redbook/texturesurf.c index 0170070eaa5..2023072dba8 100644 --- a/progs/redbook/texturesurf.c +++ b/progs/redbook/texturesurf.c @@ -60,7 +60,7 @@ GLfloat ctrlpoints[4][4][3] = { GLfloat texpts[2][2][2] = {{{0.0, 0.0}, {0.0, 1.0}}, {{1.0, 0.0}, {1.0, 1.0}}}; -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glColor3f(1.0, 1.0, 1.0); @@ -72,7 +72,7 @@ void display(void) #define imageHeight 64 GLubyte image[3*imageWidth*imageHeight]; -void makeImage(void) +static void makeImage(void) { int i, j; float ti, tj; @@ -89,7 +89,7 @@ void makeImage(void) } } -void myinit(void) +static void myinit(void) { glMap2f(GL_MAP2_VERTEX_3, 0, 1, 3, 4, 0, 1, 12, 4, &ctrlpoints[0][0][0]); @@ -112,7 +112,7 @@ void myinit(void) glShadeModel (GL_FLAT); } -void myReshape(int w, int h) +static void myReshape(int w, int h) { glViewport(0, 0, w, h); glMatrixMode(GL_PROJECTION); diff --git a/progs/redbook/torus.c b/progs/redbook/torus.c index 7ae4d41e263..a67d48e0f59 100644 --- a/progs/redbook/torus.c +++ b/progs/redbook/torus.c @@ -89,7 +89,7 @@ static void init(void) } /* Clear window and draw torus */ -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f (1.0, 1.0, 1.0); @@ -98,7 +98,7 @@ void display(void) } /* Handle window resize */ -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -112,7 +112,7 @@ void reshape(int w, int h) /* Rotate about x-axis when "x" typed; rotate about y-axis when "y" typed; "i" returns torus to original view */ /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'x': diff --git a/progs/redbook/trim.c b/progs/redbook/trim.c index f17674f6840..216f62a7c2f 100644 --- a/progs/redbook/trim.c +++ b/progs/redbook/trim.c @@ -59,7 +59,7 @@ GLUnurbsObj *theNurb; * Initializes the control points of the surface to a small hill. * The control points range from -3 to +3 in x, y, and z */ -void init_surface(void) +static void init_surface(void) { int u, v; for (u = 0; u < 4; u++) { @@ -75,7 +75,7 @@ void init_surface(void) } } -void nurbsError(GLenum errorCode) +static void nurbsError(GLenum errorCode) { const GLubyte *estring; @@ -86,7 +86,7 @@ void nurbsError(GLenum errorCode) /* Initialize material property and depth buffer. */ -void init(void) +static void init(void) { GLfloat mat_diffuse[] = { 0.7, 0.7, 0.7, 1.0 }; GLfloat mat_specular[] = { 1.0, 1.0, 1.0, 1.0 }; @@ -112,7 +112,7 @@ void init(void) (GLvoid (CALLBACK*) ()) nurbsError); } -void display(void) +static void display(void) { GLfloat knots[8] = {0.0, 0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 1.0}; GLfloat edgePt[5][2] = /* counter clockwise */ @@ -147,7 +147,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -160,7 +160,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/unproject.c b/progs/redbook/unproject.c index 134c361bac5..6d1c7dbeded 100644 --- a/progs/redbook/unproject.c +++ b/progs/redbook/unproject.c @@ -45,14 +45,14 @@ #include <stdlib.h> #include <stdio.h> -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); glFlush(); } /* Change these values for a different transformation */ -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -62,7 +62,7 @@ void reshape(int w, int h) glLoadIdentity(); } -void mouse(int button, int state, int x, int y) +static void mouse(int button, int state, int x, int y) { GLint viewport[4]; GLdouble mvmatrix[16], projmatrix[16]; @@ -98,7 +98,7 @@ void mouse(int button, int state, int x, int y) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/varray.c b/progs/redbook/varray.c index b22e723e0ec..8ce39d77633 100644 --- a/progs/redbook/varray.c +++ b/progs/redbook/varray.c @@ -54,7 +54,7 @@ int setupMethod = POINTER; int derefMethod = DRAWARRAY; -void setupPointers(void) +static void setupPointers(void) { static GLint vertices[] = {25, 25, 100, 325, @@ -76,7 +76,7 @@ void setupPointers(void) glColorPointer (3, GL_FLOAT, 0, colors); } -void setupInterleave(void) +static void setupInterleave(void) { static GLfloat intertwined[] = {1.0, 0.2, 1.0, 100.0, 100.0, 0.0, @@ -89,14 +89,14 @@ void setupInterleave(void) glInterleavedArrays (GL_C3F_V3F, 0, intertwined); } -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel (GL_SMOOTH); setupPointers (); } -void display(void) +static void display(void) { glClear (GL_COLOR_BUFFER_BIT); @@ -117,7 +117,7 @@ void display(void) glFlush (); } -void reshape (int w, int h) +static void reshape (int w, int h) { glViewport (0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode (GL_PROJECTION); @@ -126,7 +126,7 @@ void reshape (int w, int h) } /* ARGSUSED2 */ -void mouse (int button, int state, int x, int y) +static void mouse (int button, int state, int x, int y) { switch (button) { case GLUT_LEFT_BUTTON: @@ -160,7 +160,7 @@ void mouse (int button, int state, int x, int y) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: diff --git a/progs/redbook/wrap.c b/progs/redbook/wrap.c index f9a1f162ab6..67749716e83 100644 --- a/progs/redbook/wrap.c +++ b/progs/redbook/wrap.c @@ -59,7 +59,7 @@ static GLubyte checkImage[checkImageHeight][checkImageWidth][4]; static GLuint texName; #endif -void makeCheckImage(void) +static void makeCheckImage(void) { int i, j, c; @@ -74,7 +74,7 @@ void makeCheckImage(void) } } -void init(void) +static void init(void) { glClearColor (0.0, 0.0, 0.0, 0.0); glShadeModel(GL_FLAT); @@ -101,7 +101,7 @@ void init(void) #endif } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_TEXTURE_2D); @@ -125,7 +125,7 @@ void display(void) glDisable(GL_TEXTURE_2D); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -137,7 +137,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard (unsigned char key, int x, int y) +static void keyboard (unsigned char key, int x, int y) { switch (key) { case 's': diff --git a/progs/samples/.gitignore b/progs/samples/.gitignore index f60d6e94eac..c15b886b884 100644 --- a/progs/samples/.gitignore +++ b/progs/samples/.gitignore @@ -36,6 +36,7 @@ prim quad readtex.c readtex.h +rgbtoppm select shape sphere diff --git a/progs/samples/Makefile b/progs/samples/Makefile index b300e38b9c2..64fa47addb5 100644 --- a/progs/samples/Makefile +++ b/progs/samples/Makefile @@ -10,7 +10,7 @@ LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) $(TOP)/$(LIB_DIR)/$(GLU_LIB_NAME) $(T LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB) $(APP_LIB_DEPS) PROGS = accum bitmap1 bitmap2 blendeq blendxor copy cursor depth eval fog \ - font line logo nurb olympic overlay point prim quad select \ + font line logo nurb olympic overlay point prim rgbtoppm quad select \ shape sphere star stencil stretch texture tri wave diff --git a/progs/samples/SConscript b/progs/samples/SConscript index 7a8a0d62d81..134dfa99807 100644 --- a/progs/samples/SConscript +++ b/progs/samples/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - progs = [ 'accum', 'bitmap1', @@ -52,7 +34,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/samples/olympic.c b/progs/samples/olympic.c index 5385e487026..209a8c141b2 100644 --- a/progs/samples/olympic.c +++ b/progs/samples/olympic.c @@ -74,7 +74,7 @@ int iters[RINGS]; GLuint theTorus; -void FillTorus(float rc, int numc, float rt, int numt) +static void FillTorus(float rc, int numc, float rt, int numt) { int i, j, k; double s, t; @@ -106,7 +106,7 @@ void FillTorus(float rc, int numc, float rt, int numt) } } -float Clamp(int iters_left, float t) +static float Clamp(int iters_left, float t) { if (iters_left < 3) { return 0.0; @@ -114,7 +114,7 @@ float Clamp(int iters_left, float t) return (iters_left-2)*t/iters_left; } -void DrawScene(void) +static void DrawScene(void) { int i, j; GLboolean goIdle; @@ -172,7 +172,7 @@ void DrawScene(void) } } -float MyRand(void) +static float MyRand(void) { return 10.0 * ( (float) rand() / (float) RAND_MAX - 0.5 ); } @@ -181,12 +181,12 @@ float MyRand(void) #define GLUTCALLBACK #endif -void GLUTCALLBACK glut_post_redisplay_p(void) +static void GLUTCALLBACK glut_post_redisplay_p(void) { glutPostRedisplay(); } -void ReInit(void) +static void ReInit(void) { int i; float deviation; @@ -206,7 +206,7 @@ void ReInit(void) glutIdleFunc(glut_post_redisplay_p); } -void Init(void) +static void Init(void) { float base, height; float aspect, x, y; @@ -312,13 +312,13 @@ void Init(void) glMatrixMode(GL_MODELVIEW); } -void Reshape(int width, int height) +static void Reshape(int width, int height) { glViewport(0, 0, width, height); } -void Key(unsigned char key, int x, int y) +static void Key(unsigned char key, int x, int y) { switch (key) { @@ -330,7 +330,7 @@ void Key(unsigned char key, int x, int y) } } -GLenum Args(int argc, char **argv) +static GLenum Args(int argc, char **argv) { GLint i; diff --git a/progs/samples/overlay.c b/progs/samples/overlay.c index 23b5a4793ba..6087cef2815 100644 --- a/progs/samples/overlay.c +++ b/progs/samples/overlay.c @@ -69,19 +69,19 @@ starRec stars[MAXSTARS]; float sinTable[MAXANGLES]; -float Sin(float angle) +static float Sin(float angle) { return (sinTable[(GLint)angle]); } -float Cos(float angle) +static float Cos(float angle) { return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]); } -void NewStar(GLint n, GLint d) +static void NewStar(GLint n, GLint d) { if (rand()%4 == 0) { @@ -103,7 +103,7 @@ void NewStar(GLint n, GLint d) } } -void RotatePoint(float *x, float *y, float rotation) +static void RotatePoint(float *x, float *y, float rotation) { float tmpX, tmpY; @@ -113,7 +113,7 @@ void RotatePoint(float *x, float *y, float rotation) *y = tmpY; } -void MoveStars(void) +static void MoveStars(void) { float offset; GLint n; @@ -134,7 +134,7 @@ void MoveStars(void) } } -GLenum StarPoint(GLint n) +static GLenum StarPoint(GLint n) { float x0, y0, x1, y1, width; GLint i; @@ -182,7 +182,7 @@ GLenum StarPoint(GLint n) } } -void ShowStars(void) +static void ShowStars(void) { GLint n; @@ -221,7 +221,7 @@ static void Init(void) glDisable(GL_DITHER); } -void Reshape(int width, int height) +static void Reshape(int width, int height) { windW = (GLint)width; @@ -262,7 +262,7 @@ static void Key(unsigned char key, int x, int y) } } -void Idle(void) +static void Idle(void) { if (overlayInit == GL_FALSE) { diff --git a/progs/samples/rgbtoppm.c b/progs/samples/rgbtoppm.c index 116d9a8cfa5..403578ef423 100644 --- a/progs/samples/rgbtoppm.c +++ b/progs/samples/rgbtoppm.c @@ -3,6 +3,7 @@ /* texload is a simplistic routine for reading an SGI .rgb image file. */ +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -25,7 +26,7 @@ typedef struct _ImageRec { int *rowSize; } ImageRec; -void +static void rgbtorgb(unsigned char *r,unsigned char *g,unsigned char *b,unsigned char *l,int n) { while(n--) { l[0] = r[0]; @@ -72,6 +73,7 @@ static ImageRec *ImageOpen(char *fileName) ImageRec *image; int swapFlag; int x; + int result; endianTest.testWord = 1; if (endianTest.testByte[0] == 1) { @@ -86,13 +88,20 @@ static ImageRec *ImageOpen(char *fileName) exit(1); } if ((image->file = fopen(fileName, "rb")) == NULL) { - return NULL; + free(image); + return NULL; } - fread(image, 1, 12, image->file); + result = fread(image, 1, 12, image->file); + assert(result == 12); if (swapFlag) { - ConvertShort(&image->imagic, 6); + ConvertShort(&image->imagic, 1); + ConvertShort(&image->type, 1); + ConvertShort(&image->dim, 1); + ConvertShort(&image->xsize, 1); + ConvertShort(&image->ysize, 1); + ConvertShort(&image->zsize, 1); } image->tmp = (unsigned char *)malloc(image->xsize*256); @@ -111,8 +120,10 @@ static ImageRec *ImageOpen(char *fileName) } image->rleEnd = 512 + (2 * x); fseek(image->file, 512, SEEK_SET); - fread(image->rowStart, 1, x, image->file); - fread(image->rowSize, 1, x, image->file); + result = fread(image->rowStart, 1, x, image->file); + assert(result == x); + result = fread(image->rowSize, 1, x, image->file); + assert(result == x); if (swapFlag) { ConvertUint(image->rowStart, x/(int) sizeof(unsigned)); ConvertUint((unsigned *)image->rowSize, x/(int) sizeof(int)); @@ -132,11 +143,13 @@ static void ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { unsigned char *iPtr, *oPtr, pixel; int count; + int result; if ((image->type & 0xFF00) == 0x0100) { fseek(image->file, (long) image->rowStart[y+z*image->ysize], SEEK_SET); - fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], - image->file); + result = fread(image->tmp, 1, (unsigned int)image->rowSize[y+z*image->ysize], + image->file); + assert(result == (unsigned int)image->rowSize[y+z*image->ysize]); iPtr = image->tmp; oPtr = buf; @@ -160,11 +173,13 @@ ImageGetRow(ImageRec *image, unsigned char *buf, int y, int z) { } else { fseek(image->file, 512+(y*image->xsize)+(z*image->xsize*image->ysize), SEEK_SET); - fread(buf, 1, image->xsize, image->file); + result = fread(buf, 1, image->xsize, image->file); + assert(result == image->xsize); } } -GLubyte * +#if 0 +static GLubyte * read_alpha_texture(char *name, int *width, int *height) { unsigned char *base, *lptr; @@ -193,8 +208,9 @@ read_alpha_texture(char *name, int *width, int *height) return (unsigned char *) base; } +#endif -GLubyte * +static GLubyte * read_rgb_texture(char *name, int *width, int *height) { unsigned char *base, *ptr; @@ -224,6 +240,7 @@ read_rgb_texture(char *name, int *width, int *height) if (gbuf) free(gbuf); if (bbuf) free(bbuf); if (abuf) free(abuf); + ImageClose(image); return NULL; } ptr = base; @@ -254,7 +271,8 @@ read_rgb_texture(char *name, int *width, int *height) int main(int argc, char **argv) { - int width, height; + int width = 0; + int height = 0; GLubyte *data; char buff[32]; int n; diff --git a/progs/samples/sphere.c b/progs/samples/sphere.c index 7d0508dee9f..23d4fe32c02 100644 --- a/progs/samples/sphere.c +++ b/progs/samples/sphere.c @@ -445,7 +445,7 @@ GLfloat identity[16] = { }; -void BuildCylinder(int numEdges) +static void BuildCylinder(int numEdges) { int i, top = 1.0, bottom = -1.0; float x[100], y[100], angle; @@ -481,7 +481,7 @@ void BuildCylinder(int numEdges) glEndList(); } -void BuildTorus(float rc, int numc, float rt, int numt) +static void BuildTorus(float rc, int numc, float rt, int numt) { int i, j, k; double s, t; @@ -515,7 +515,7 @@ void BuildTorus(float rc, int numc, float rt, int numt) glEndList(); } -void BuildCage(void) +static void BuildCage(void) { int i; float inc; @@ -609,7 +609,7 @@ void BuildCage(void) glEndList(); } -void BuildCube(void) +static void BuildCube(void) { int i, j; @@ -628,7 +628,7 @@ void BuildCube(void) glEndList(); } -void BuildLists(void) +static void BuildLists(void) { cube = glGenLists(1); @@ -646,7 +646,7 @@ void BuildLists(void) genericObject = torus; } -void SetDefaultSettings(void) +static void SetDefaultSettings(void) { magFilter = nnearest; @@ -657,7 +657,7 @@ void SetDefaultSettings(void) autoRotate = GL_TRUE; } -unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha) +static unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha) { unsigned char *outData, *out_ptr, *in_ptr; int i; @@ -677,7 +677,7 @@ unsigned char *AlphaPadImage(int bufSize, unsigned char *inData, int alpha) return outData; } -void Init(void) +static void Init(void) { float ambient[] = {0.0, 0.0, 0.0, 1.0}; float diffuse[] = {1.0, 1.0, 1.0, 1.0}; @@ -753,7 +753,7 @@ void Init(void) BuildLists(); } -void ReInit(void) +static void ReInit(void) { if (genericObject == torus) { glEnable(GL_DEPTH_TEST); @@ -773,7 +773,7 @@ void ReInit(void) glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, textureEnvironment); } -void Draw(void) +static void Draw(void) { glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); @@ -806,7 +806,7 @@ void Draw(void) glutSwapBuffers(); } -void Reshape(int width, int height) +static void Reshape(int width, int height) { W = width; H = height; @@ -818,7 +818,7 @@ void Reshape(int width, int height) glMatrixMode(GL_MODELVIEW); } -void Idle(void) +static void Idle(void) { static double t0 = -1.; double t, dt; @@ -833,7 +833,7 @@ void Idle(void) glutPostRedisplay(); } -void Key2(int key, int x, int y) +static void Key2(int key, int x, int y) { switch (key) { @@ -863,7 +863,7 @@ void Key2(int key, int x, int y) glutPostRedisplay(); } -void Key(unsigned char key, int x, int y) +static void Key(unsigned char key, int x, int y) { switch (key) { @@ -950,7 +950,7 @@ void Key(unsigned char key, int x, int y) glutPostRedisplay(); } -GLenum Args(int argc, char **argv) +static GLenum Args(int argc, char **argv) { GLint i; diff --git a/progs/samples/star.c b/progs/samples/star.c index 2cf470e2a2f..2c44ebfd49e 100644 --- a/progs/samples/star.c +++ b/progs/samples/star.c @@ -67,19 +67,19 @@ starRec stars[MAXSTARS]; float sinTable[MAXANGLES]; -float Sin(float angle) +static float Sin(float angle) { return (sinTable[(GLint)angle]); } -float Cos(float angle) +static float Cos(float angle) { return (sinTable[((GLint)angle+(MAXANGLES/4))%MAXANGLES]); } -void NewStar(GLint n, GLint d) +static void NewStar(GLint n, GLint d) { if (rand()%4 == 0) { @@ -101,7 +101,7 @@ void NewStar(GLint n, GLint d) } } -void RotatePoint(float *x, float *y, float rotation) +static void RotatePoint(float *x, float *y, float rotation) { float tmpX, tmpY; @@ -111,7 +111,7 @@ void RotatePoint(float *x, float *y, float rotation) *y = tmpY; } -void MoveStars(void) +static void MoveStars(void) { float offset; GLint n; @@ -142,7 +142,7 @@ void MoveStars(void) } } -GLenum StarPoint(GLint n) +static GLenum StarPoint(GLint n) { float x0, y0, x1, y1, width; GLint i; @@ -190,7 +190,7 @@ GLenum StarPoint(GLint n) } } -void ShowStars(void) +static void ShowStars(void) { GLint n; @@ -229,7 +229,7 @@ static void Init(void) glDisable(GL_DITHER); } -void Reshape(int width, int height) +static void Reshape(int width, int height) { windW = (GLint)width; @@ -260,7 +260,7 @@ static void Key(unsigned char key, int x, int y) } } -void Draw(void) +static void Draw(void) { MoveStars(); @@ -307,7 +307,7 @@ static GLenum Args(int argc, char **argv) #define GLUTCALLBACK #endif -void GLUTCALLBACK glut_post_redisplay_p(void) +static void GLUTCALLBACK glut_post_redisplay_p(void) { glutPostRedisplay(); } diff --git a/progs/samples/stretch.c b/progs/samples/stretch.c index 1fd015d794a..11201dca230 100644 --- a/progs/samples/stretch.c +++ b/progs/samples/stretch.c @@ -67,7 +67,7 @@ int cCount, cIndex[2], cStep; GLenum op = OP_NOOP; -void DrawImage(void) +static void DrawImage(void) { glRasterPos2i(0, 0); @@ -84,7 +84,7 @@ void DrawImage(void) image->data); } -void DrawPoint(void) +static void DrawPoint(void) { int i; @@ -102,7 +102,7 @@ void DrawPoint(void) } } -void InitVList(void) +static void InitVList(void) { vList[0].x = 0.0; @@ -141,7 +141,7 @@ void InitVList(void) vList[4].tY = cList[0].y / (float)imageSizeY; } -void ScaleImage(int sizeX, int sizeY) +static void ScaleImage(int sizeX, int sizeY) { GLubyte *buf; @@ -154,7 +154,7 @@ void ScaleImage(int sizeX, int sizeY) image->sizeY = sizeY; } -void SetPoint(int x, int y) +static void SetPoint(int x, int y) { cList[cCount].x = (float)x; @@ -162,7 +162,7 @@ void SetPoint(int x, int y) cCount++; } -void Stretch(void) +static void Stretch(void) { glBegin(GL_TRIANGLES); @@ -221,7 +221,7 @@ void Stretch(void) } } -void Key(unsigned char key, int x, int y) +static void Key(unsigned char key, int x, int y) { switch (key) { @@ -245,7 +245,7 @@ void Key(unsigned char key, int x, int y) glutPostRedisplay(); } -void Mouse(int button, int state, int mouseX, int mouseY) +static void Mouse(int button, int state, int mouseX, int mouseY) { if (state != GLUT_DOWN) @@ -263,7 +263,7 @@ void Mouse(int button, int state, int mouseX, int mouseY) glutPostRedisplay(); } -void Animate(void) +static void Animate(void) { static double t0 = -1.; double t, dt; @@ -322,7 +322,7 @@ static GLenum Args(int argc, char **argv) #define GLUTCALLBACK #endif -void GLUTCALLBACK glut_post_redisplay_p(void) +static void GLUTCALLBACK glut_post_redisplay_p(void) { glutPostRedisplay(); } diff --git a/progs/samples/wave.c b/progs/samples/wave.c index d3c4687459e..396a6943e33 100644 --- a/progs/samples/wave.c +++ b/progs/samples/wave.c @@ -92,7 +92,7 @@ GLubyte contourTexture2[] = { #endif -void GLUTCALLBACK glut_post_redisplay_p(void) +static void GLUTCALLBACK glut_post_redisplay_p(void) { static double t0 = -1.; double t, dt; diff --git a/progs/slang/cltest.c b/progs/slang/cltest.c index 2753f59f85b..dfff6cb226a 100644 --- a/progs/slang/cltest.c +++ b/progs/slang/cltest.c @@ -237,7 +237,7 @@ void RenderScene (void) if (p != NULL) p++; } - if (*p != '\0') + if (p && *p != '\0') printf ("*** %s\n", "I/O error"); nextprogram = program->next; diff --git a/progs/slang/vstest.c b/progs/slang/vstest.c index 472ea9b62e2..33c6f09dc55 100644 --- a/progs/slang/vstest.c +++ b/progs/slang/vstest.c @@ -220,6 +220,12 @@ static void load_test_file (const char *filename) fseek (f, 0, SEEK_END); size = ftell (f); + + if (size == -1) { + fclose (f); + return; + } + fseek (f, 0, SEEK_SET); code = (char *) (malloc (size)); diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 4d9b4e8388c..836396b2499 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -25,9 +25,11 @@ SOURCES = \ arbvptorus.c \ arbvpwarpmesh.c \ arraytexture.c \ + auxbuffer.c \ blendminmax.c \ blendsquare.c \ blendxor.c \ + blitfb.c \ bufferobj.c \ bumpmap.c \ bug_3050.c \ @@ -35,11 +37,14 @@ SOURCES = \ bug_3195.c \ bug_texstore_i8.c \ calibrate_rast.c \ + condrender.c \ copypixrate.c \ crossbar.c \ cva.c \ drawbuffers.c \ + drawbuffers2.c \ exactrast.c \ + ext422square.c \ floattex.c \ fbotest1.c \ fbotest2.c \ @@ -65,6 +70,8 @@ SOURCES = \ mipmap_limits.c \ mipmap_view.c \ multipal.c \ + multitexarray.c \ + multiwindow.c \ no_s3tc.c \ packedpixels.c \ pbo.c \ @@ -87,10 +94,13 @@ SOURCES = \ subtex \ subtexrate.c \ tex1d.c \ + texcmp.c \ texcompress2.c \ texcompsub.c \ texdown \ texfilt.c \ + texgenmix.c \ + texleak.c \ texline.c \ texobj.c \ texobjshare.c \ @@ -100,6 +110,7 @@ SOURCES = \ vao-01.c \ vao-02.c \ vparray.c \ + vpeval.c \ vptest1.c \ vptest2.c \ vptest3.c \ diff --git a/progs/tests/SConscript b/progs/tests/SConscript index bb6a1d2b8a9..e2c65382887 100644 --- a/progs/tests/SConscript +++ b/progs/tests/SConscript @@ -1,23 +1,5 @@ Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(CPPPATH = [ - '../util', -]) - -env.Prepend(LIBS = [ - util, - '$GLUT_LIB' -]) - -if env['platform'] == 'windows': - env.Append(CPPDEFINES = ['NOMINMAX']) - env.Prepend(LIBS = ['winmm']) - linux_progs = [ 'api_speed', ] @@ -52,16 +34,19 @@ progs = [ 'blendminmax', 'blendsquare', 'blendxor', + 'blitfb', 'bufferobj', 'bug_3050', 'bug_3101', 'bug_3195', 'bug_texstore_i8', 'calibrate_rast', + 'condrender', 'copypixrate', 'crossbar', 'cva', 'drawbuffers', + 'drawbuffers2', 'exactrast', 'ext422square', 'fbotest1', @@ -137,7 +122,7 @@ progs = [ ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/tests/arbgpuprog.c b/progs/tests/arbgpuprog.c index 23aa899d963..6098dca787b 100644 --- a/progs/tests/arbgpuprog.c +++ b/progs/tests/arbgpuprog.c @@ -134,6 +134,8 @@ static void Init( const char *vertProgFile, } len = fread(buf, 1, 10*1000,f); + fclose(f); + glProgramStringARB_func(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, len, @@ -170,6 +172,8 @@ static void Init( const char *vertProgFile, } len = fread(buf, 1, 10*1000,f); + fclose(f); + glProgramStringARB_func(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, len, diff --git a/progs/tests/arraytexture.c b/progs/tests/arraytexture.c index 6c0484df0de..28252a354bf 100644 --- a/progs/tests/arraytexture.c +++ b/progs/tests/arraytexture.c @@ -77,10 +77,6 @@ static GLfloat texZ = 0.0; static GLfloat texZ_dir = 0.01; static GLint num_layers; -static PFNGLBINDPROGRAMARBPROC bind_program; -static PFNGLPROGRAMSTRINGARBPROC program_string; -static PFNGLGENPROGRAMSARBPROC gen_programs; - static void PrintString(const char *s) @@ -125,13 +121,13 @@ static void Display(void) glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); glColor3f(1,1,1); glRasterPos3f(-0.9, -0.9, 0.0); sprintf(str, "Texture Z coordinate = %4.1f", texZ); PrintString(str); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 1); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 1); GL_CHECK_ERROR(); glEnable(GL_TEXTURE_2D_ARRAY_EXT); GL_CHECK_ERROR(); @@ -159,7 +155,7 @@ static void Display(void) glDisable(GL_TEXTURE_2D_ARRAY_EXT); GL_CHECK_ERROR(); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, 0); + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); GL_CHECK_ERROR(); glutSwapBuffers(); @@ -226,8 +222,8 @@ compile_fragment_program(GLuint id, const char *prog) int err; err = glGetError(); - (*bind_program)(GL_FRAGMENT_PROGRAM_ARB, id); - (*program_string)(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, id); + glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(prog), (const GLubyte *) prog); glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorPos); @@ -264,11 +260,6 @@ static void Init(void) require_extension("GL_MESA_texture_array"); require_extension("GL_SGIS_generate_mipmap"); - bind_program = glutGetProcAddress("glBindProgramARB"); - program_string = glutGetProcAddress("glProgramStringARB"); - gen_programs = glutGetProcAddress("glGenProgramsARB"); - - for (num_layers = 0; textures[num_layers] != NULL; num_layers++) /* empty */ ; diff --git a/progs/tests/blitfb.c b/progs/tests/blitfb.c new file mode 100644 index 00000000000..18c8380a5e2 --- /dev/null +++ b/progs/tests/blitfb.c @@ -0,0 +1,259 @@ +/** + * Test glFramebufferBlit() + * Brian Paul + * 27 Oct 2009 + */ + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + + +static int Win; +static int WinWidth = 1100, WinHeight = 600; + +static int SrcWidth = 512, SrcHeight = 512; +static int DstWidth = 512, DstHeight = 512; + +static GLuint SrcFB, DstFB; +static GLuint SrcTex, DstTex; + +#if 0 +static GLenum SrcTexTarget = GL_TEXTURE_2D, SrcTexFace = GL_TEXTURE_2D; +#else +static GLenum SrcTexTarget = GL_TEXTURE_CUBE_MAP, SrcTexFace = GL_TEXTURE_CUBE_MAP_POSITIVE_X; +#endif + +static GLenum DstTexTarget = GL_TEXTURE_2D, DstTexFace = GL_TEXTURE_2D; + +static GLuint SrcTexLevel = 01, DstTexLevel = 0; + + +static void +Draw(void) +{ + GLboolean rp = GL_FALSE; + GLubyte *buf; + GLint srcWidth = SrcWidth >> SrcTexLevel; + GLint srcHeight = SrcHeight >> SrcTexLevel; + GLint dstWidth = DstWidth >> DstTexLevel; + GLint dstHeight = DstHeight >> DstTexLevel; + GLenum status; + + /* clear window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glClearColor(0.5, 0.5, 0.5, 1.0); + glClear(GL_COLOR_BUFFER_BIT); + + + /* clear src buf */ + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + assert(status == GL_FRAMEBUFFER_COMPLETE_EXT); + glClearColor(0, 1, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + /* clear dst buf */ + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); + assert(status == GL_FRAMEBUFFER_COMPLETE_EXT); + glClearColor(1, 0, 0, 0); + glClear(GL_COLOR_BUFFER_BIT); + + /* blit src -> dst */ + glBindFramebufferEXT(GL_READ_FRAMEBUFFER, SrcFB); + glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, DstFB); + glBlitFramebufferEXT(0, 0, srcWidth, srcHeight, + 0, 0, dstWidth, dstHeight, + GL_COLOR_BUFFER_BIT, GL_NEAREST); + +#if 01 + /* read src results */ + buf = malloc(4 * srcWidth * srcHeight); + memset(buf, 0x88, 4 * srcWidth * srcHeight); + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + if (rp) + glReadPixels(0, 0, srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + else { + glBindTexture(SrcTexTarget, SrcTex); + glGetTexImage(SrcTexFace, SrcTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf); + } + + /* draw dst in window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glWindowPos2i(0, 0); + glDrawPixels(srcWidth, srcHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("Src Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]); + free(buf); +#endif + + glFinish(); + + /* read dst results */ + buf = malloc(4 * dstWidth * dstHeight); + memset(buf, 0x88, 4 * dstWidth * dstHeight); + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + if (rp) + glReadPixels(0, 0, dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + else { + glBindTexture(DstTexTarget, DstTex); + glGetTexImage(DstTexFace, DstTexLevel, GL_RGBA, GL_UNSIGNED_BYTE, buf); + } + + /* draw dst in window */ + glBindFramebufferEXT(GL_FRAMEBUFFER, 0); + glWindowPos2i(srcWidth + 2, 0); + glDrawPixels(dstWidth, dstHeight, GL_RGBA, GL_UNSIGNED_BYTE, buf); + + printf("Dst Pix[0] = %d %d %d %d\n", buf[0], buf[1], buf[2], buf[3]); + free(buf); + + glFinish(); + + glutSwapBuffers(); +} + + +static void +Reshape(int width, int height) +{ + WinWidth = width; + WinHeight = height; + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -15.0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glutDestroyWindow(Win); + exit(0); + break; + } + glutPostRedisplay(); +} + + +static void +SpecialKey(int key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + } + glutPostRedisplay(); +} + + +static void +InitFBOs(void) +{ + GLuint w, h, lvl; + + /* Src */ + glGenTextures(1, &SrcTex); + glBindTexture(SrcTexTarget, SrcTex); + w = SrcWidth; + h = SrcHeight; + lvl = 0; + for (lvl = 0; ; lvl++) { + if (SrcTexTarget == GL_TEXTURE_CUBE_MAP) { + GLuint f; + for (f = 0; f < 6; f++) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + f, lvl, GL_RGBA8, + w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + } + else { + /* single face */ + glTexImage2D(SrcTexFace, lvl, GL_RGBA8, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + } + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + } + + glGenFramebuffersEXT(1, &SrcFB); + glBindFramebufferEXT(GL_FRAMEBUFFER, SrcFB); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + SrcTexFace, SrcTex, SrcTexLevel); + + /* Dst */ + glGenTextures(1, &DstTex); + glBindTexture(DstTexTarget, DstTex); + w = DstWidth; + h = DstHeight; + lvl = 0; + for (lvl = 0; ; lvl++) { + glTexImage2D(DstTexFace, lvl, GL_RGBA8, w, h, 0, + GL_RGBA, GL_UNSIGNED_BYTE, NULL); + if (w == 1 && h == 1) + break; + if (w > 1) + w /= 2; + if (h > 1) + h /= 2; + } + + glGenFramebuffersEXT(1, &DstFB); + glBindFramebufferEXT(GL_FRAMEBUFFER, DstFB); + glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + DstTexFace, DstTex, DstTexLevel); +} + + +static void +Init(void) +{ + if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + fprintf(stderr, "This test requires GL_EXT_framebuffer_object\n"); + exit(1); + } + + if (!glutExtensionSupported("GL_EXT_framebuffer_blit")) { + fprintf(stderr, "This test requires GL_EXT_framebuffer_blit,\n"); + exit(1); + } + + InitFBOs(); + + printf("Left rect = src FBO, Right rect = dst FBO.\n"); + printf("Both should be green.\n"); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowSize(WinWidth, WinHeight); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutSpecialFunc(SpecialKey); + glutDisplayFunc(Draw); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/bug_texstore_i8.c b/progs/tests/bug_texstore_i8.c index 10e5eba7c5e..b070011bd2e 100644 --- a/progs/tests/bug_texstore_i8.c +++ b/progs/tests/bug_texstore_i8.c @@ -73,7 +73,7 @@ static void Init(void) 0, sourceFormat, GL_UNSIGNED_BYTE, - //GL_UNSIGNED_INT, + /* GL_UNSIGNED_INT, */ tex2d); glEnable(Target); diff --git a/progs/tests/condrender.c b/progs/tests/condrender.c new file mode 100644 index 00000000000..1db8a7c15af --- /dev/null +++ b/progs/tests/condrender.c @@ -0,0 +1,242 @@ +/* + * Test GL_NV_conditional_render + * + * Brian Paul + * 30 Dec 2009 + * + * Copyright (C) 2009 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + +#define TEST_DISPLAY_LISTS 0 + +static GLboolean Anim = GL_TRUE; +static GLfloat Xpos = 0; +static GLuint OccQuery; +static GLint Win = 0; + + +static void Idle(void) +{ + static int lastTime = 0; + static int sign = +1; + int time = glutGet(GLUT_ELAPSED_TIME); + float step; + + if (lastTime == 0) + lastTime = time; + else if (time - lastTime < 20) /* 50Hz update */ + return; + + step = (time - lastTime) / 1000.0 * sign; + lastTime = time; + + Xpos += step; + + if (Xpos > 2.5) { + Xpos = 2.5; + sign = -1; + } + else if (Xpos < -2.5) { + Xpos = -2.5; + sign = +1; + } + glutPostRedisplay(); +} + + +static void Display( void ) +{ + glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); + + glEnable(GL_DEPTH_TEST); + + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glFrustum( -1.0, 1.0, -1.0, 1.0, 5.0, 25.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -15.0 ); + + /* draw the occluding polygons */ + glColor3f(0, 0.6, 0.8); + glBegin(GL_QUADS); + glVertex2f(-1.6, -1.5); + glVertex2f(-0.4, -1.5); + glVertex2f(-0.4, 1.5); + glVertex2f(-1.6, 1.5); + + glVertex2f( 0.4, -1.5); + glVertex2f( 1.6, -1.5); + glVertex2f( 1.6, 1.5); + glVertex2f( 0.4, 1.5); + glEnd(); + + /* draw the test polygon with occlusion testing */ + glPushMatrix(); + glTranslatef(Xpos, 0, -0.5); + glScalef(0.3, 0.3, 1.0); + glRotatef(-90.0 * Xpos, 0, 0, 1); + +#if TEST_DISPLAY_LISTS + glNewList(10, GL_COMPILE); + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); + glEndList(); + glCallList(10); +#else + glBeginQueryARB(GL_SAMPLES_PASSED_ARB, OccQuery); +#endif + + glColorMask(0, 0, 0, 0); + glDepthMask(GL_FALSE); + + glBegin(GL_POLYGON); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + +#if TEST_DISPLAY_LISTS + glNewList(11, GL_COMPILE); + glEndQueryARB(GL_SAMPLES_PASSED_ARB); + glEndList(); + glCallList(11); +#else + glEndQueryARB(GL_SAMPLES_PASSED_ARB); +#endif + + glColorMask(1, 1, 1, 1); + glDepthMask(GL_TRUE); + + /* Note: disable depth test here so that we'll always see the orange + * box, except when it's totally culled. + */ + glDisable(GL_DEPTH_TEST); + + glBeginConditionalRenderNV(OccQuery, GL_QUERY_WAIT_NV); + /* draw the orange rect, so we can see what's going on */ + glColor3f(0.8, 0.5, 0); + glBegin(GL_POLYGON); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + glEndConditionalRenderNV(); + + /* always draw white outline around orange box */ + glColor3f(1.0, 1.0, 1.0); + glBegin(GL_LINE_LOOP); + glVertex3f(-1, -1, 0); + glVertex3f( 1, -1, 0); + glVertex3f( 1, 1, 0); + glVertex3f(-1, 1, 0); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + glDeleteQueriesARB(1, &OccQuery); + glutDestroyWindow(Win); + exit(0); + break; + case ' ': + Anim = !Anim; + if (Anim) + glutIdleFunc(Idle); + else + glutIdleFunc(NULL); + break; + } + glutPostRedisplay(); +} + + +static void SpecialKey( int key, int x, int y ) +{ + const GLfloat step = 0.1; + (void) x; + (void) y; + switch (key) { + case GLUT_KEY_LEFT: + Xpos -= step; + break; + case GLUT_KEY_RIGHT: + Xpos += step; + break; + } + glutPostRedisplay(); +} + + +static void Init( void ) +{ + if (!glutExtensionSupported("GL_ARB_occlusion_query") || + !glutExtensionSupported("GL_NV_conditional_render")) { + printf("Sorry, this demo requires the extensions:\n"); + printf(" GL_ARB_occlusion_query\n"); + printf(" GL_NV_conditional_render\n"); + exit(-1); + } + + glGenQueriesARB(1, &OccQuery); + assert(OccQuery > 0); +} + + +int main( int argc, char *argv[] ) +{ + glutInitWindowSize( 400, 400 ); + glutInit( &argc, argv ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH ); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutSpecialFunc( SpecialKey ); + glutIdleFunc( Idle ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/crossbar.c b/progs/tests/crossbar.c index 3dd21372f9a..2988e209200 100644 --- a/progs/tests/crossbar.c +++ b/progs/tests/crossbar.c @@ -145,7 +145,7 @@ static void Init( void ) { const char * const ver_string = (const char * const) glGetString( GL_VERSION ); - float ver = strtof( ver_string, NULL ); + float ver = strtod( ver_string, NULL ); GLint tex_units; GLint temp[ 256 ]; @@ -174,7 +174,7 @@ static void Init( void ) exit(1); } - printf("\nAll %u squares should be the same color.\n", NUM_TESTS + 1); + printf("\nAll %lu squares should be the same color.\n", (unsigned long) NUM_TESTS + 1); (void) memset( temp, 0x00, sizeof( temp ) ); glBindTexture( GL_TEXTURE_2D, 1 ); diff --git a/progs/tests/cva.c b/progs/tests/cva.c index 80483900cb7..02d1dcba2ec 100644 --- a/progs/tests/cva.c +++ b/progs/tests/cva.c @@ -39,7 +39,7 @@ GLboolean compiled = GL_TRUE; GLboolean doubleBuffer = GL_TRUE; -void init( void ) +static void init( void ) { glClearColor( 0.0, 0.0, 0.0, 0.0 ); glShadeModel( GL_SMOOTH ); @@ -69,7 +69,7 @@ void init( void ) #endif } -void display( void ) +static void display( void ) { glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); @@ -81,7 +81,7 @@ void display( void ) } } -void keyboard( unsigned char key, int x, int y ) +static void keyboard( unsigned char key, int x, int y ) { switch ( key ) { case 27: @@ -92,7 +92,7 @@ void keyboard( unsigned char key, int x, int y ) glutPostRedisplay(); } -GLboolean args( int argc, char **argv ) +static GLboolean args( int argc, char **argv ) { GLint i; diff --git a/progs/tests/drawbuffers.c b/progs/tests/drawbuffers.c index d75a870c26b..7a19933e627 100644 --- a/progs/tests/drawbuffers.c +++ b/progs/tests/drawbuffers.c @@ -43,6 +43,8 @@ Display(void) glUseProgram_func(Program); + glEnable(GL_DEPTH_TEST); + /* draw to user framebuffer */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject); @@ -68,18 +70,23 @@ Display(void) glPopMatrix(); /* read from user framebuffer */ - /* bottom half = colorbuffer 0 */ + /* left half = colorbuffer 0 */ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); - glReadPixels(0, 0, Width, Height / 2, GL_RGBA, GL_UNSIGNED_BYTE, + glPixelStorei(GL_PACK_ROW_LENGTH, Width); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); - /* top half = colorbuffer 1 */ + + /* right half = colorbuffer 1 */ glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); - glReadPixels(0, Height/2, Width, Height - Height / 2, + glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2); + glReadPixels(Width / 2, 0, Width - Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE, - buffer + Width * (Height / 2) * 4); + buffer); /* draw to window */ glUseProgram_func(0); + glDisable(GL_DEPTH_TEST); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glWindowPos2iARB(0, 0); glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); diff --git a/progs/tests/drawbuffers2.c b/progs/tests/drawbuffers2.c new file mode 100644 index 00000000000..7b8cc5ca6a3 --- /dev/null +++ b/progs/tests/drawbuffers2.c @@ -0,0 +1,364 @@ +/* + * Test GL_ARB_draw_buffers2, GL_ARB_draw_buffers, GL_EXT_framebuffer_object + * and GLSL's gl_FragData[]. + * + * We draw to two color buffers and show the left half of the first + * color buffer on the left side of the window, and show the right + * half of the second color buffer on the right side of the window. + * + * Different color masks are used for the two color buffers. + * Blending is enabled for the second buffer only. + * + * Brian Paul + * 31 Dec 2009 + */ + + +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> +#include "extfuncs.h" + +static int Win; +static int Width = 400, Height = 400; +static GLuint FBobject, RBobjects[3]; +static GLfloat Xrot = 0.0, Yrot = 0.0; +static GLuint Program; +static GLboolean Anim = GL_TRUE; + + +static void +CheckError(int line) +{ + GLenum err = glGetError(); + if (err) { + printf("GL Error 0x%x at line %d\n", (int) err, line); + } +} + + +static void +Display(void) +{ + GLubyte *buffer = malloc(Width * Height * 4); + static const GLenum buffers[2] = { + GL_COLOR_ATTACHMENT0_EXT, + GL_COLOR_ATTACHMENT1_EXT + }; + + glUseProgram_func(Program); + + glEnable(GL_DEPTH_TEST); + + /* draw to user framebuffer */ + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject); + + /* Clear color buffer 0 (blue) */ + glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); + glClear(GL_COLOR_BUFFER_BIT); + + /* Clear color buffer 1 (1 - blue) */ + glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); + glClear(GL_COLOR_BUFFER_BIT); + + glClear(GL_DEPTH_BUFFER_BIT); + + /* draw to two buffers w/ fragment shader */ + glDrawBuffersARB(2, buffers); + + /* different color masks for each buffer */ + if (1) { + glColorMaskIndexedEXT(0, GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE); + glColorMaskIndexedEXT(1, GL_FALSE, GL_TRUE, GL_FALSE, GL_FALSE); + } + + glPushMatrix(); + glRotatef(Xrot, 1, 0, 0); + glRotatef(Yrot, 0, 1, 0); + glPushMatrix(); + glTranslatef(1, 0, 0); + glutSolidTorus(1.0, 2.0, 10, 20); + glPopMatrix(); + glPushMatrix(); + glTranslatef(-1, 0, 0); + glRotatef(90, 1, 0, 0); + glutSolidTorus(1.0, 2.0, 10, 20); + glPopMatrix(); + glPopMatrix(); + + /* restore default color masks */ + glColorMaskIndexedEXT(0, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + glColorMaskIndexedEXT(1, GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); + + /* read from user framebuffer */ + /* left half = colorbuffer 0 */ + glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); + glPixelStorei(GL_PACK_ROW_LENGTH, Width); + glPixelStorei(GL_PACK_SKIP_PIXELS, 0); + glReadPixels(0, 0, Width / 2, Height, GL_RGBA, GL_UNSIGNED_BYTE, + buffer); + + /* right half = colorbuffer 1 */ + glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + glPixelStorei(GL_PACK_SKIP_PIXELS, Width / 2); + glReadPixels(Width / 2, 0, Width - Width / 2, Height, + GL_RGBA, GL_UNSIGNED_BYTE, + buffer); + + /* draw to window */ + glUseProgram_func(0); + glDisable(GL_DEPTH_TEST); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glWindowPos2iARB(0, 0); + glDrawPixels(Width, Height, GL_RGBA, GL_UNSIGNED_BYTE, buffer); + + free(buffer); + glutSwapBuffers(); + CheckError(__LINE__); +} + + +static void +Idle(void) +{ + Xrot = glutGet(GLUT_ELAPSED_TIME) * 0.05; + glutPostRedisplay(); +} + + +static void +Reshape(int width, int height) +{ + float ar = (float) width / (float) height; + + glViewport(0, 0, width, height); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glFrustum(-ar, ar, -1.0, 1.0, 5.0, 35.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + glTranslatef(0.0, 0.0, -20.0); + + Width = width; + Height = height; + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, + Width, Height); +} + + +static void +CleanUp(void) +{ + glDeleteFramebuffersEXT(1, &FBobject); + glDeleteRenderbuffersEXT(3, RBobjects); + glutDestroyWindow(Win); + exit(0); +} + + +static void +Key(unsigned char key, int x, int y) +{ + (void) x; + (void) y; + switch (key) { + case ' ': + Anim = !Anim; + glutIdleFunc(Anim ? Idle : NULL); + break; + case 'x': + Xrot += 5.0; + break; + case 'X': + Xrot -= 5.0; + break; + case 'y': + Yrot += 5.0; + break; + case 'Y': + Yrot -= 5.0; + break; + case 27: + CleanUp(); + break; + } + glutPostRedisplay(); +} + + +static void +CheckExtensions(void) +{ + const char *req[] = { + "GL_EXT_framebuffer_object", + "GL_ARB_draw_buffers", + "GL_EXT_draw_buffers2" + }; + + const char *version = (const char *) glGetString(GL_VERSION); + GLint numBuf; + GLint i; + + for (i = 0; i < 3; i++) { + if (!glutExtensionSupported(req[i])) { + printf("Sorry, %s extension is required!\n", req[i]); + exit(1); + } + } + if (version[0] != '2') { + printf("Sorry, OpenGL 2.0 is required!\n"); + exit(1); + } + + glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &numBuf); + printf("GL_MAX_DRAW_BUFFERS_ARB = %d\n", numBuf); + if (numBuf < 2) { + printf("Sorry, GL_MAX_DRAW_BUFFERS_ARB needs to be >= 2\n"); + exit(1); + } + + printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); +} + + +static void +SetupRenderbuffers(void) +{ + glGenFramebuffersEXT(1, &FBobject); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, FBobject); + + glGenRenderbuffersEXT(3, RBobjects); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[0]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[1]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB, Width, Height); + + glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, RBobjects[2]); + glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, + Width, Height); + + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, + GL_RENDERBUFFER_EXT, RBobjects[0]); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT1_EXT, + GL_RENDERBUFFER_EXT, RBobjects[1]); + glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, + GL_RENDERBUFFER_EXT, RBobjects[2]); + + CheckError(__LINE__); +} + + +static GLuint +LoadAndCompileShader(GLenum target, const char *text) +{ + GLint stat; + GLuint shader = glCreateShader_func(target); + glShaderSource_func(shader, 1, (const GLchar **) &text, NULL); + glCompileShader_func(shader); + glGetShaderiv_func(shader, GL_COMPILE_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetShaderInfoLog_func(shader, 1000, &len, log); + fprintf(stderr, "drawbuffers: problem compiling shader:\n%s\n", log); + exit(1); + } + return shader; +} + + +static void +CheckLink(GLuint prog) +{ + GLint stat; + glGetProgramiv_func(prog, GL_LINK_STATUS, &stat); + if (!stat) { + GLchar log[1000]; + GLsizei len; + glGetProgramInfoLog_func(prog, 1000, &len, log); + fprintf(stderr, "drawbuffers: shader link error:\n%s\n", log); + } +} + + +static void +SetupShaders(void) +{ + /* emit same color to both draw buffers */ + static const char *fragShaderText = + "void main() {\n" + " gl_FragData[0] = gl_Color; \n" + " gl_FragData[1] = gl_Color; \n" + "}\n"; + + GLuint fragShader; + + fragShader = LoadAndCompileShader(GL_FRAGMENT_SHADER, fragShaderText); + Program = glCreateProgram_func(); + + glAttachShader_func(Program, fragShader); + glLinkProgram_func(Program); + CheckLink(Program); + glUseProgram_func(Program); +} + + +static void +SetupLighting(void) +{ + static const GLfloat ambient[4] = { 0.0, 0.0, 0.0, 0.0 }; + static const GLfloat diffuse[4] = { 1.0, 1.0, 1.0, 0.75 }; + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, ambient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, diffuse); + + glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, 0); + glEnable(GL_LIGHT0); + glEnable(GL_LIGHTING); +} + + +static void +Init(void) +{ + CheckExtensions(); + GetExtensionFuncs(); + SetupRenderbuffers(); + SetupShaders(); + SetupLighting(); + glEnable(GL_DEPTH_TEST); + + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glEnableIndexedEXT(GL_BLEND, 1); +} + + +int +main(int argc, char *argv[]) +{ + glutInit(&argc, argv); + glutInitWindowPosition(0, 0); + glutInitWindowSize(Width, Height); + glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE); + Win = glutCreateWindow(argv[0]); + glewInit(); + glutIdleFunc(Anim ? Idle : NULL); + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Display); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/tests/fptest1.c b/progs/tests/fptest1.c index 2b8f8d0f5ec..1f30d5733e7 100644 --- a/progs/tests/fptest1.c +++ b/progs/tests/fptest1.c @@ -57,6 +57,7 @@ static void Key( unsigned char key, int x, int y ) static void Init( void ) { +#if 0 static const char *prog0 = "!!FP1.0\n" "MUL o[COLR], R0, f[WPOS]; \n" @@ -73,6 +74,7 @@ static void Init( void ) "MOV HC, H2; \n" "END \n" ; +#endif /* masked updates, defines, declarations */ static const char *prog1 = diff --git a/progs/tests/getprocaddress.c b/progs/tests/getprocaddress.c index a09ea58e1da..e699baf44bc 100644 --- a/progs/tests/getprocaddress.c +++ b/progs/tests/getprocaddress.c @@ -1188,7 +1188,7 @@ exercise_buffer_objects(enum Map_Buffer_Usage usage) GLuint bufferID; GLint bufferMapped; static GLubyte data[BUFFER_DATA_SIZE] = {0}; - float *dataPtr; + float *dataPtr = NULL; /* Get the function pointers we need. These are from * GL_ARB_vertex_buffer_object and are required in all @@ -3516,7 +3516,7 @@ check_functions( const char *extensions ) struct name_test_pair *entry; int failures = 0, passes = 0, untested = 0; int totalFail = 0, totalPass = 0, totalUntested = 0, totalUnsupported = 0; - int doTests; + int doTests = 0; const char *version = (const char *) glGetString(GL_VERSION); /* The functions list will have "real" entries (consisting of diff --git a/progs/tests/getteximage.c b/progs/tests/getteximage.c index 71f29b4ac84..e4053b8de1a 100644 --- a/progs/tests/getteximage.c +++ b/progs/tests/getteximage.c @@ -58,6 +58,26 @@ TestGetTexImage(GLboolean npot) abort(); } } + + /* get as BGRA */ + glGetTexImage(GL_TEXTURE_2D, level, GL_BGRA, GL_UNSIGNED_BYTE, data2); + + /* compare */ + { + const GLubyte *rgba = (GLubyte *) data; + const GLubyte *bgra = (GLubyte *) data2; + for (i = 0; i < w * h; i += 4) { + if (rgba[i+0] != bgra[i+2] || + rgba[i+1] != bgra[i+1] || + rgba[i+2] != bgra[i+0] || + rgba[i+3] != bgra[i+3]) { + printf("glTexImage + glGetTexImage(GL_BGRA) failure!\n"); + printf("Expected value %d, found %d\n", data[i], data2[i]); + abort(); + } + } + } + } printf("Passed\n"); diff --git a/progs/tests/invert.c b/progs/tests/invert.c index 63099fbd221..45001b44d07 100644 --- a/progs/tests/invert.c +++ b/progs/tests/invert.c @@ -128,7 +128,7 @@ static void Init( void ) { const char * const ver_string = (const char * const) glGetString( GL_VERSION ); - const float ver = strtof( ver_string, NULL ); + const float ver = strtod( ver_string, NULL ); printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); @@ -165,7 +165,7 @@ static void Init( void ) "square should look upside-down.\n"); - image = LoadRGBImage( IMAGE_FILE, & img_width, & img_height, + image = LoadRGBImage( IMAGE_FILE, (GLint *) & img_width, (GLint *) & img_height, & img_format ); if ( image == NULL ) { printf( "Could not open image file \"%s\".\n", IMAGE_FILE ); diff --git a/progs/tests/minmag.c b/progs/tests/minmag.c index 03019f94faa..179be511207 100644 --- a/progs/tests/minmag.c +++ b/progs/tests/minmag.c @@ -16,7 +16,6 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <unistd.h> #include <GL/glew.h> #include <GL/glut.h> diff --git a/progs/tests/mipmap_comp.c b/progs/tests/mipmap_comp.c index 5842e2b8805..dd2232113b6 100644 --- a/progs/tests/mipmap_comp.c +++ b/progs/tests/mipmap_comp.c @@ -285,6 +285,12 @@ main(int argc, char** argv) glutInitWindowSize (600, 600); glutCreateWindow (argv[0]); glewInit(); + + if (!glutExtensionSupported("GL_EXT_texture_compression_s3tc")) { + fprintf(stderr, "This test requires GL_EXT_texture_compression_s3tc.\n"); + exit(1); + } + myInit(); glutReshapeFunc (myReshape); glutDisplayFunc(display); diff --git a/progs/tests/packedpixels.c b/progs/tests/packedpixels.c index 1703b271cb0..34df95549a6 100644 --- a/progs/tests/packedpixels.c +++ b/progs/tests/packedpixels.c @@ -17,53 +17,53 @@ struct pixel_format { GLenum format; GLenum type; GLint bytes; - GLuint redTexel, greenTexel; + GLuint redTexel, greenTexel; /* with approx 51% alpha, when applicable */ }; static const struct pixel_format Formats[] = { { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8", - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000000, 0x00ff0000 }, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, 4, 0xff000080, 0x00ff0080 }, { "GL_RGBA/GL_UNSIGNED_INT_8_8_8_8_REV", - GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x000000ff, 0x0000ff00 }, + GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x800000ff, 0x8000ff00 }, { "GL_RGBA/GL_UNSIGNED_INT_10_10_10_2", - GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00000, 0x3ff000 }, + GL_RGBA, GL_UNSIGNED_INT_10_10_10_2, 4, 0xffc00002, 0x3ff002 }, { "GL_RGBA/GL_UNSIGNED_INT_2_10_10_10_REV", - GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0x3ff, 0xffc00 }, + GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, 4, 0xc00003ff, 0xc00ffc00 }, { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4", - GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf000, 0x0f00 }, + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0xf008, 0x0f08 }, { "GL_RGBA/GL_UNSIGNED_SHORT_4_4_4_4_REV", - GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x000f, 0x00f0 }, + GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x800f, 0x80f0 }, { "GL_RGBA/GL_UNSIGNED_SHORT_5_5_5_1", - GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf800, 0x7c0 }, + GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0x7c1 }, { "GL_RGBA/GL_UNSIGNED_SHORT_1_5_5_5_REV", - GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x1f, 0x3e0 }, + GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x801f, 0x83e0 }, { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8", - GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff00, 0x00ff0000 }, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8, 4, 0x0000ff80, 0x00ff0080 }, { "GL_BGRA/GL_UNSIGNED_INT_8_8_8_8_REV", - GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x00ff0000, 0x0000ff00 }, + GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0x80ff0000, 0x8000ff00 }, { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4", - GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f0, 0x0f00 }, + GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x00f8, 0x0f08 }, { "GL_BGRA/GL_UNSIGNED_SHORT_4_4_4_4_REV", - GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x0f00, 0x00f0 }, + GL_BGRA, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0x8f00, 0x80f0 }, { "GL_BGRA/GL_UNSIGNED_SHORT_5_5_5_1", - GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3e, 0x7c0 }, + GL_BGRA, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x3f, 0x7c1 }, { "GL_BGRA/GL_UNSIGNED_SHORT_1_5_5_5_REV", - GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x7c00, 0x3e0 }, + GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0xfc00, 0x83e0 }, { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8", - GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x000000ff, 0x0000ff00 }, + GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8, 4, 0x800000ff, 0x8000ff00 }, { "GL_ABGR_EXT/GL_UNSIGNED_INT_8_8_8_8_REV", - GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000000, 0x00ff0000 }, + GL_ABGR_EXT, GL_UNSIGNED_INT_8_8_8_8_REV, 4, 0xff000080, 0x00ff0080 }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x000f, 0x00f0 }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4, 2, 0x800f, 0x80f0 }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_4_4_4_4_REV", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf000, 0x0f00 }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_4_4_4_4_REV, 2, 0xf008, 0x0f08 }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_5_5_5_1", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0x1, 0x3e }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_5_5_5_1, 2, 0xf801, 0xf83e }, { "GL_ABGR_EXT/GL_UNSIGNED_SHORT_1_5_5_5_REV", - GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x8000, 0x7c00 }, + GL_ABGR_EXT, GL_UNSIGNED_SHORT_1_5_5_5_REV, 2, 0x800f, 0x7c0f }, { "GL_RGB/GL_UNSIGNED_SHORT_5_6_5", GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 2, 0xf800, 0x7e0 }, @@ -108,7 +108,7 @@ static const struct name_format IntFormats[] = { static GLuint CurFormat = 0; static GLboolean Test3D = GL_FALSE; - +static GLboolean Blend = GL_FALSE; static void @@ -191,6 +191,19 @@ MakeTexture(const struct pixel_format *format, GLenum intFormat, GLboolean swap) format->format, format->type, texBuffer); } + if (0) { + GLint r, g, b, a, l, i; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i); + printf("IntFormat: 0x%x R %d G %d B %d A %d L %d I %d\n", + intFormat, r, g, b, a, l, i); + glGetError(); + } + if (glGetError()) { printf("GL Error for %s\n", format->name); memset(texBuffer, 255, 1000); @@ -221,6 +234,10 @@ Draw(void) glEnable(GL_TEXTURE_3D); else glEnable(GL_TEXTURE_2D); + + if (Blend) + glEnable(GL_BLEND); + glBegin(GL_POLYGON); glTexCoord3f(0, 0, 0.5); glVertex2f(0, 0); glTexCoord3f(1, 0, 0.5); glVertex2f(w, 0); @@ -232,6 +249,9 @@ Draw(void) glDisable(GL_TEXTURE_3D); else glDisable(GL_TEXTURE_2D); + + glDisable(GL_BLEND); + glColor3f(0, 0, 0); glRasterPos2i(8, 6); PrintString(Formats[i].name); @@ -252,8 +272,8 @@ Draw(void) glPushMatrix(); glTranslatef(2, (i + 1) * (h + 2), 0); glRasterPos2i(8, 6); - sprintf(s, "Internal Texture Format [f/F]: %s (%d of %d)", - IntFormats[CurFormat].name, CurFormat + 1, NUM_INT_FORMATS); + sprintf(s, "Internal Texture Format [f/F]: %s (%d of %lu)", + IntFormats[CurFormat].name, CurFormat + 1, (unsigned long) NUM_INT_FORMATS); PrintString(s); glPopMatrix(); @@ -266,6 +286,15 @@ Draw(void) PrintString("Target [2/3]: GL_TEXTURE_2D"); glPopMatrix(); + glPushMatrix(); + glTranslatef(2, (i + 3) * (h + 2), 0); + glRasterPos2i(8, 6); + if (Blend) + PrintString("Blend: Yes"); + else + PrintString("Blend: No"); + glPopMatrix(); + glutSwapBuffers(); } @@ -288,6 +317,9 @@ Key(unsigned char key, int x, int y) (void) x; (void) y; switch (key) { + case 'b': + Blend = !Blend; + break; case 'F': if (CurFormat == 0) CurFormat = NUM_INT_FORMATS - 1; @@ -323,6 +355,7 @@ Init(void) glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } diff --git a/progs/tests/prog_parameter.c b/progs/tests/prog_parameter.c index 6dd956c4023..2de7e2994af 100644 --- a/progs/tests/prog_parameter.c +++ b/progs/tests/prog_parameter.c @@ -116,7 +116,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param, for ( i = 0 ; i < (4 * count) ; i++ ) { - param[i] = (GLfloat) random() / (GLfloat) random(); + param[i] = (GLfloat) rand() / (GLfloat) rand(); } /* Try using the "classic" interface. @@ -153,7 +153,7 @@ static int set_parameter_batch( GLsizei count, GLfloat * param, for ( i = 0 ; i < (4 * count) ; i++ ) { - param[i] = (GLfloat) random() / (GLfloat) random(); + param[i] = (GLfloat) rand() / (GLfloat) rand(); } printf("Testing glProgram%sParameters4fvEXT (count = %u)...\n", name, count); @@ -192,6 +192,7 @@ static void Init( void ) GLfloat * params; GLint max_program_env_parameters; GLint max_program_local_parameters; + int i; printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); @@ -203,20 +204,20 @@ static void Init( void ) } - program_local_parameter4fv = glutGetProcAddress( "glProgramLocalParameter4fvARB" ); - program_env_parameter4fv = glutGetProcAddress( "glProgramEnvParameter4fvARB" ); + program_local_parameter4fv = (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramLocalParameter4fvARB" ); + program_env_parameter4fv = (PFNGLPROGRAMENVPARAMETER4FVARBPROC) glutGetProcAddress( "glProgramEnvParameter4fvARB" ); - get_program_local_parameterfv = glutGetProcAddress( "glGetProgramLocalParameterfvARB" ); - get_program_env_parameterfv = glutGetProcAddress( "glGetProgramEnvParameterfvARB" ); + get_program_local_parameterfv = (PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramLocalParameterfvARB" ); + get_program_env_parameterfv = (PFNGLGETPROGRAMENVPARAMETERFVARBPROC) glutGetProcAddress( "glGetProgramEnvParameterfvARB" ); - bind_program = glutGetProcAddress( "glBindProgramARB" ); - get_program = glutGetProcAddress( "glGetProgramivARB" ); + bind_program = (PFNGLBINDPROGRAMARBPROC) glutGetProcAddress( "glBindProgramARB" ); + get_program = (PFNGLGETPROGRAMIVARBPROC) glutGetProcAddress( "glGetProgramivARB" ); if ( glutExtensionSupported("GL_EXT_gpu_program_parameters") ) { printf("GL_EXT_gpu_program_parameters available, testing that path.\n"); - program_local_parameters4fv = glutGetProcAddress( "glProgramLocalParameters4fvEXT" ); - program_env_parameters4fv = glutGetProcAddress( "glProgramEnvParameters4fvEXT" ); + program_local_parameters4fv = (PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramLocalParameters4fvEXT" ); + program_env_parameters4fv = (PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) glutGetProcAddress( "glProgramEnvParameters4fvEXT" ); } else { printf("GL_EXT_gpu_program_parameters not available.\n"); @@ -238,6 +239,10 @@ static void Init( void ) params = malloc(max_program_env_parameters * 4 * sizeof(GLfloat)); + for (i = 0; i < max_program_env_parameters * 4; i++) { + params[i] = 0.0F; + } + pass &= set_parameter_batch(max_program_env_parameters, params, "Env", program_env_parameter4fv, program_env_parameters4fv, diff --git a/progs/tests/quads.c b/progs/tests/quads.c index 2098b51ccd2..e5b9920b66d 100644 --- a/progs/tests/quads.c +++ b/progs/tests/quads.c @@ -17,7 +17,10 @@ static GLfloat Xrot = 40, Yrot = 0, Zrot = 0; static GLboolean Anim = GL_TRUE; static GLuint Vbuffer = 0; +#if 1 +#else static GLfloat buf[NUM_QUADS * 6 * 4]; +#endif static GLboolean doSwapBuffers = GL_TRUE; diff --git a/progs/tests/scissor-viewport.c b/progs/tests/scissor-viewport.c index 582e65fb72b..4ef307b424e 100644 --- a/progs/tests/scissor-viewport.c +++ b/progs/tests/scissor-viewport.c @@ -104,7 +104,7 @@ static void draw(void) glDisable(GL_SCISSOR_TEST); - //glutSwapBuffers(); + /* glutSwapBuffers(); */ glFlush(); } @@ -120,7 +120,7 @@ int main(int argc, char **argv) glutInitWindowPosition(100, 0); glutInitWindowSize(prog.width, prog.height); - //type = GLUT_RGB | GLUT_DOUBLE; + /* type = GLUT_RGB | GLUT_DOUBLE; */ type = GLUT_RGB | GLUT_SINGLE; glutInitDisplayMode(type); diff --git a/progs/tests/scissor.c b/progs/tests/scissor.c index 2dfd2174e82..e5a68ffabd3 100644 --- a/progs/tests/scissor.c +++ b/progs/tests/scissor.c @@ -134,7 +134,7 @@ static void draw(void) glDisable(GL_SCISSOR_TEST); - //glutSwapBuffers(); + /* glutSwapBuffers(); */ glFlush(); } @@ -150,7 +150,7 @@ int main(int argc, char **argv) glutInitWindowPosition(100, 0); glutInitWindowSize(prog.width, prog.height); - //type = GLUT_RGB | GLUT_DOUBLE; + /* type = GLUT_RGB | GLUT_DOUBLE; */ type = GLUT_RGB | GLUT_SINGLE; glutInitDisplayMode(type); diff --git a/progs/tests/shader_api.c b/progs/tests/shader_api.c index 6453856345c..fa0a992540c 100644 --- a/progs/tests/shader_api.c +++ b/progs/tests/shader_api.c @@ -8,6 +8,10 @@ #include <GL/glew.h> #include <GL/glut.h> +#ifndef APIENTRY +#define APIENTRY +#endif + static void assert_test(const char *file, int line, int cond, const char *msg) { if (!cond) @@ -42,7 +46,7 @@ static void assert_error_test(const char *file, int line, GLenum expect) #define assert_error(err) assert_error_test(__FILE__, __LINE__, (err)) -static void check_status(GLuint id, GLenum pname, void (*query)(GLuint, GLenum, GLint *)) +static void check_status(GLuint id, GLenum pname, void (APIENTRY *query)(GLuint, GLenum, GLint *)) { GLint status; diff --git a/progs/tests/sharedtex.c b/progs/tests/sharedtex.c index c07ebd719c7..2337b88d3ff 100644 --- a/progs/tests/sharedtex.c +++ b/progs/tests/sharedtex.c @@ -424,13 +424,13 @@ main(int argc, char *argv[]) { const char *dpyName = XDisplayName(NULL); - struct window *h0, *h1, *h2, *h3; + struct window *h0; /* four windows and contexts sharing display lists and texture objects */ h0 = AddWindow(dpyName, 10, 10, NULL); - h1 = AddWindow(dpyName, 330, 10, h0); - h2 = AddWindow(dpyName, 10, 350, h0); - h3 = AddWindow(dpyName, 330, 350, h0); + (void) AddWindow(dpyName, 330, 10, h0); + (void) AddWindow(dpyName, 10, 350, h0); + (void) AddWindow(dpyName, 330, 350, h0); InitGLstuff(h0); diff --git a/progs/tests/stencil_twoside.c b/progs/tests/stencil_twoside.c index 1e18ca6b5ea..7d871e5877f 100644 --- a/progs/tests/stencil_twoside.c +++ b/progs/tests/stencil_twoside.c @@ -274,9 +274,9 @@ static void Init( void ) if (atof( ver_string ) < 2.0) { use20syntax = 0; } - stencil_func_separate = glutGetProcAddress( "glStencilFuncSeparate" ); - stencil_func_separate_ati = glutGetProcAddress( "glStencilFuncSeparateATI" ); - stencil_op_separate = glutGetProcAddress( "glStencilOpSeparate" ); + stencil_func_separate = (PFNGLSTENCILFUNCSEPARATEPROC) glutGetProcAddress( "glStencilFuncSeparate" ); + stencil_func_separate_ati = (PFNGLSTENCILFUNCSEPARATEATIPROC) glutGetProcAddress( "glStencilFuncSeparateATI" ); + stencil_op_separate = (PFNGLSTENCILOPSEPARATEPROC) glutGetProcAddress( "glStencilOpSeparate" ); printf("\nAll 5 squares should be the same color.\n"); } diff --git a/progs/tests/stencilwrap.c b/progs/tests/stencilwrap.c index 2e219fd8b50..d396fc2a533 100644 --- a/progs/tests/stencilwrap.c +++ b/progs/tests/stencilwrap.c @@ -257,7 +257,7 @@ static void Init( void ) * part of GL 1.4. */ - ver_str = glGetString( GL_VERSION ); + ver_str = (char *) glGetString( GL_VERSION ); version = (ver_str == NULL) ? 1.0 : atof( ver_str ); wrapping = (glutExtensionSupported("GL_EXT_stencil_wrap") || (version >= 1.4)); diff --git a/progs/tests/tex1d.c b/progs/tests/tex1d.c index 4abe1068c7b..7d67451c0da 100644 --- a/progs/tests/tex1d.c +++ b/progs/tests/tex1d.c @@ -39,11 +39,13 @@ static void draw( void ) +/* static void idle( void ) { Angle += 2.0; glutPostRedisplay(); } +*/ diff --git a/progs/tests/texcmp.c b/progs/tests/texcmp.c index d1e829d1b73..c5d352fdaed 100644 --- a/progs/tests/texcmp.c +++ b/progs/tests/texcmp.c @@ -106,6 +106,8 @@ static void Display( void ) glRotatef(Rot, 0, 0, 1); glEnable(GL_TEXTURE_2D); + glEnable(GL_BLEND); + glBegin(GL_POLYGON); glTexCoord2f(0, 1); glVertex2f(-1, -0.5); glTexCoord2f(1, 1); glVertex2f( 1, -0.5); @@ -115,7 +117,10 @@ static void Display( void ) glPopMatrix(); + glDisable(GL_TEXTURE_2D); + /* info */ + glDisable(GL_BLEND); glColor4f(1, 1, 1, 1); glRasterPos3f(-1.2, -0.7, 0); @@ -149,7 +154,7 @@ static void Reshape( int width, int height ) static void ReInit( GLenum TC, TEXTURE *Tx ) { - GLint rv; + GLint rv, v; if ((Tx->TC == TC) && (Tx->cData != NULL)) { glCompressedTexImage2DARB(GL_TEXTURE_2D, /* target */ @@ -170,6 +175,24 @@ static void ReInit( GLenum TC, TEXTURE *Tx ) GL_UNSIGNED_BYTE, /* texture type */ Tx->data); /* the texture */ + + v = 0; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, + GL_TEXTURE_INTERNAL_FORMAT, &v); + printf("Requested internal format = 0x%x, actual = 0x%x\n", TC, v); + + if (0) { + GLint r, g, b, a, l, i; + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_RED_SIZE, &r); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_GREEN_SIZE, &g); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_BLUE_SIZE, &b); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_ALPHA_SIZE, &a); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_LUMINANCE_SIZE, &l); + glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_INTENSITY_SIZE, &i); + printf("Compressed Bits per R: %d G: %d B: %d A: %d L: %d I: %d\n", + r, g, b, a, l, i); + } + /* okay, now cache the compressed texture */ Tx->TC = TC; if (Tx->cData != NULL) { diff --git a/progs/tests/texcomp_image.h b/progs/tests/texcomp_image.h index e63a56774f3..a3884d4d0df 100644 --- a/progs/tests/texcomp_image.h +++ b/progs/tests/texcomp_image.h @@ -1,4 +1,4 @@ -static int ImgSize = 131072; +#define ImgSize 131072 static unsigned char ImgData[131072] = { 0x4d, 0xbc, 0x0b, 0xb4, 0xda, 0x0a, 0x78, 0xa8, 0x8d, 0xbc, 0x0c, 0xac, 0x8b, 0x7f, 0xeb, 0xf7, 0x8d, 0xbc, 0xeb, 0xab, 0xba, 0xb7, 0x82, 0xa2, 0x8d, 0xbc, 0x2b, 0xb4, 0xa2, 0xfd, 0xee, 0x2f, diff --git a/progs/tests/texcompsub.c b/progs/tests/texcompsub.c index 50106bf1e22..215f5711d95 100644 --- a/progs/tests/texcompsub.c +++ b/progs/tests/texcompsub.c @@ -35,6 +35,8 @@ LoadCompressedImage(void) unsigned char ImgDataTemp[ImgSize / 4]; unsigned i; const GLenum filter = GL_LINEAR; + const int half = ImgSize / 2; + glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL); @@ -42,11 +44,11 @@ LoadCompressedImage(void) glCompressedTexSubImage2DARB(Target, 0, 0, 0, /* pos */ ImgWidth, ImgHeight / 2, - CompFormat, ImgSize / 2, ImgData + ImgSize / 2); + CompFormat, ImgSize / 2, ImgData /*+ ImgSize / 2*/); /* top left */ for (i = 0; i < ImgHeight / 8; i++) { - memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth], ImgWidth); + memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth], ImgWidth); } glCompressedTexSubImage2DARB(Target, 0, 0, ImgHeight / 2, /* pos */ @@ -55,7 +57,7 @@ LoadCompressedImage(void) /* top right */ for (i = 0; i < ImgHeight / 8; i++) { - memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth + ImgWidth], ImgWidth); + memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[half + i * 2 * ImgWidth + ImgWidth], ImgWidth); } glCompressedTexSubImage2DARB(Target, 0, ImgWidth / 2, ImgHeight / 2, /* pos */ diff --git a/progs/tests/texdown.c b/progs/tests/texdown.c index 7e460458325..92df01b83d2 100644 --- a/progs/tests/texdown.c +++ b/progs/tests/texdown.c @@ -162,7 +162,7 @@ MeasureDownloadRate(void) const int image_bytes = align(w * h * BytesPerTexel(Format), ALIGN); const int bytes = image_bytes * NR_TEXOBJ; GLubyte *orig_texImage, *orig_getImage; - GLubyte *texImage, *getImage; + GLubyte *texImage; GLdouble t0, t1, time; int count; int i; @@ -176,13 +176,14 @@ MeasureDownloadRate(void) orig_getImage = (GLubyte *) malloc(image_bytes + ALIGN); if (!orig_texImage || !orig_getImage) { DownloadRate = 0.0; + free(orig_texImage); + free(orig_getImage); return; } printf("alloc %p %p\n", orig_texImage, orig_getImage); texImage = (GLubyte *)align((unsigned long)orig_texImage, ALIGN); - getImage = (GLubyte *)align((unsigned long)orig_getImage, ALIGN); for (i = 1; !(((unsigned long)texImage) & i); i<<=1) ; diff --git a/progs/tests/texleak.c b/progs/tests/texleak.c new file mode 100644 index 00000000000..5cf4ff32393 --- /dev/null +++ b/progs/tests/texleak.c @@ -0,0 +1,140 @@ +/* + * 'Texture leak' test + * + * Allocates and uses an additional texture of the maximum supported size for + * each frame. This tests the system's ability to cope with using increasing + * amounts of texture memory. + * + * Michel Dänzer July 2009 This program is in the public domain. + */ + + +#include <math.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/time.h> +#include <unistd.h> +#include <GL/glew.h> +#include <GL/glut.h> + + +GLint size; +GLvoid *image; +static GLuint numTexObj; +static GLuint *texObj; + + +static void Idle( void ) +{ + glutPostRedisplay(); +} + + +static void DrawObject(void) +{ + static const GLfloat tex_coords[] = { 0.0, 0.0, 1.0, 1.0, 0.0 }; + static const GLfloat vtx_coords[] = { -1.0, -1.0, 1.0, 1.0, -1.0 }; + GLint i, j; + + glEnable(GL_TEXTURE_2D); + + for (i = 0; i < numTexObj; i++) { + glBindTexture(GL_TEXTURE_2D, texObj[i]); + glBegin(GL_QUADS); + for (j = 0; j < 4; j++ ) { + glTexCoord2f(tex_coords[j], tex_coords[j+1]); + glVertex2f( vtx_coords[j], vtx_coords[j+1] ); + } + glEnd(); + } +} + + +static void Display( void ) +{ + struct timeval start, end; + + texObj = realloc(texObj, ++numTexObj * sizeof(*texObj)); + + /* allocate a texture object */ + glGenTextures(1, texObj + (numTexObj - 1)); + + glBindTexture(GL_TEXTURE_2D, texObj[numTexObj - 1]); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + memset(image, (16 * numTexObj) & 0xff, 4 * size * size); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size, size, 0, + GL_RGBA, GL_UNSIGNED_BYTE, image); + + gettimeofday(&start, NULL); + + glClear( GL_COLOR_BUFFER_BIT ); + + glPushMatrix(); + glScalef(5.0, 5.0, 5.0); + DrawObject(); + glPopMatrix(); + + glutSwapBuffers(); + + glFinish(); + gettimeofday(&end, NULL); + printf("Rendering frame took %lu ms using %u MB of textures\n", + end.tv_sec * 1000 + end.tv_usec / 1000 - start.tv_sec * 1000 - + start.tv_usec / 1000, numTexObj * 4 * size / 1024 * size / 1024); + + sleep(1); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho( -6.0, 6.0, -6.0, 6.0, 10.0, 100.0 ); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + glTranslatef( 0.0, 0.0, -70.0 ); +} + + +static void Init( int argc, char *argv[] ) +{ + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &size); + printf("%d x %d max texture size\n", size, size); + + image = malloc(4 * size * size); + if (!image) { + fprintf(stderr, "Failed to allocate %u bytes of memory\n", 4 * size * size); + exit(1); + } + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glShadeModel(GL_FLAT); + glClearColor(0.3, 0.3, 0.4, 1.0); + + Idle(); +} + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowSize( 300, 300 ); + glutInitWindowPosition( 0, 0 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0] ); + glewInit(); + + Init( argc, argv ); + + glutReshapeFunc( Reshape ); + glutDisplayFunc( Display ); + glutIdleFunc(Idle); + + glutMainLoop(); + return 0; +} diff --git a/progs/tests/unfilledclip.c b/progs/tests/unfilledclip.c index db6fffa3e89..331cbf2f6b1 100644 --- a/progs/tests/unfilledclip.c +++ b/progs/tests/unfilledclip.c @@ -31,6 +31,7 @@ static int win_width, win_height; +#if 0 static void line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) { @@ -39,6 +40,7 @@ line(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2) glVertex2f(x2, y2); glEnd(); } +#endif static void line3(GLfloat x1, GLfloat y1, GLfloat z1, GLfloat x2, GLfloat y2, GLfloat z2) diff --git a/progs/tests/vao-01.c b/progs/tests/vao-01.c index 117fae8bd9e..e4a89cb19db 100644 --- a/progs/tests/vao-01.c +++ b/progs/tests/vao-01.c @@ -124,10 +124,10 @@ static void Init( void ) exit(2); } - bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" ); - gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" ); - delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); - is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" ); + bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" ); + gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" ); + delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); + is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" ); (*gen_vertex_arrays)( 1, & obj ); diff --git a/progs/tests/vao-02.c b/progs/tests/vao-02.c index 7764ed51061..9f7f5c27792 100644 --- a/progs/tests/vao-02.c +++ b/progs/tests/vao-02.c @@ -125,10 +125,10 @@ static void Init( void ) exit(2); } - bind_vertex_array = glutGetProcAddress( "glBindVertexArrayAPPLE" ); - gen_vertex_arrays = glutGetProcAddress( "glGenVertexArraysAPPLE" ); - delete_vertex_arrays = glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); - is_vertex_array = glutGetProcAddress( "glIsVertexArrayAPPLE" ); + bind_vertex_array = (PFNGLBINDVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glBindVertexArrayAPPLE" ); + gen_vertex_arrays = (PFNGLGENVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glGenVertexArraysAPPLE" ); + delete_vertex_arrays = (PFNGLDELETEVERTEXARRAYSAPPLEPROC) glutGetProcAddress( "glDeleteVertexArraysAPPLE" ); + is_vertex_array = (PFNGLISVERTEXARRAYAPPLEPROC) glutGetProcAddress( "glIsVertexArrayAPPLE" ); (*gen_vertex_arrays)( 1, & obj ); diff --git a/progs/tests/vparray.c b/progs/tests/vparray.c index af9b62d33e6..fe168c6cd56 100644 --- a/progs/tests/vparray.c +++ b/progs/tests/vparray.c @@ -37,13 +37,16 @@ static void read_surface( char *filename ) } numverts = 0; - while (!feof(f) && numverts < MAXVERTS) { - fscanf( f, "%f %f %f %f %f %f", - &data[numverts][0], &data[numverts][1], &data[numverts][2], - &data[numverts][3], &data[numverts][4], &data[numverts][5] ); + while (numverts < MAXVERTS) { + int result; + result = fscanf( f, "%f %f %f %f %f %f", + &data[numverts][0], &data[numverts][1], &data[numverts][2], + &data[numverts][3], &data[numverts][4], &data[numverts][5] ); + if (result == EOF) { + break; + } numverts++; } - numverts--; printf("%d vertices, %d triangles\n", numverts, numverts-2); printf("data = %p\n", (void *) data); diff --git a/progs/tests/vpeval.c b/progs/tests/vpeval.c index f07737f9736..3e8a732df59 100644 --- a/progs/tests/vpeval.c +++ b/progs/tests/vpeval.c @@ -94,16 +94,16 @@ GLfloat colorPoints[4][4][4] = }; -void +static void initlights(void) { +#if 0 /* no lighting for now */ GLfloat ambient[] = {0.2, 0.2, 0.2, 1.0}; GLfloat position[] = {0.0, 0.0, 2.0, 1.0}; GLfloat mat_diffuse[] = {0.6, 0.6, 0.6, 1.0}; GLfloat mat_specular[] = {1.0, 1.0, 1.0, 1.0}; GLfloat mat_shininess[] = {50.0}; -#if 0 /* no lighting for now */ glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); @@ -116,7 +116,7 @@ initlights(void) #endif } -void +static void display(void) { glClearColor(.3, .3, .3, 0); @@ -130,7 +130,7 @@ display(void) glFlush(); } -void +static void myinit(int argc, char *argv[]) { glClearColor(0.0, 0.0, 0.0, 1.0); @@ -186,7 +186,7 @@ myinit(int argc, char *argv[]) } } -void +static void myReshape(int w, int h) { glViewport(0, 0, w, h); diff --git a/progs/tests/zreaddraw.c b/progs/tests/zreaddraw.c index 7dfed20cfb9..7740695bb66 100644 --- a/progs/tests/zreaddraw.c +++ b/progs/tests/zreaddraw.c @@ -58,6 +58,10 @@ static void Display(void) printf("Depth value range: [%f, %f]\n", min, max); } + /* Draw the Z image as luminance above original rendering */ + glWindowPos2i(0, 100); + glDrawPixels(100, 100, GL_LUMINANCE, depthType, depth); + if (TestPacking) { glPixelStorei(GL_PACK_ROW_LENGTH, 0); glPixelStorei(GL_PACK_SKIP_PIXELS, 0); @@ -100,6 +104,7 @@ static void Display(void) glReadPixels(100, 0, 400, 400, GL_DEPTH_COMPONENT, GL_FLOAT, depth2); /* draw as luminance */ glPixelZoom(1.0, 1.0); + glWindowPos2i(100, 0); glDrawPixels(400, 400, GL_LUMINANCE, GL_FLOAT, depth2); glutSwapBuffers(); diff --git a/progs/trivial/.gitignore b/progs/trivial/.gitignore index 4d6e405c500..4317eb607fe 100644 --- a/progs/trivial/.gitignore +++ b/progs/trivial/.gitignore @@ -147,6 +147,7 @@ vbo-drawarrays vbo-drawelements vbo-drawrange vbo-noninterleaved +vbo-tri vp-array vp-array-int vp-clip diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile index a78837611c1..784715db162 100644 --- a/progs/trivial/Makefile +++ b/progs/trivial/Makefile @@ -155,6 +155,7 @@ SOURCES = \ tristrip-clip.c \ tristrip-flat.c \ tristrip.c \ + vbo-tri.c \ vbo-drawarrays.c \ vbo-noninterleaved.c \ vbo-drawelements.c \ diff --git a/progs/trivial/SConscript b/progs/trivial/SConscript index 37a53293bfc..29062564adc 100644 --- a/progs/trivial/SConscript +++ b/progs/trivial/SConscript @@ -1,11 +1,4 @@ -Import('env') - -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) +Import('*') progs = [ 'clear-fbo-tex', @@ -156,7 +149,7 @@ progs = [ ] for prog in progs: - prog = env.Program( + prog = progs_env.Program( target = prog, source = prog + '.c', ) diff --git a/progs/trivial/clear-fbo-tex.c b/progs/trivial/clear-fbo-tex.c index a206676e48e..ff31706fd1c 100644 --- a/progs/trivial/clear-fbo-tex.c +++ b/progs/trivial/clear-fbo-tex.c @@ -88,7 +88,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); @@ -102,8 +102,8 @@ static void Draw( void ) /* draw to texture image */ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, MyFB); -// glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); -// glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); + /* glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT); */ + /* glReadBuffer(GL_COLOR_ATTACHMENT1_EXT); */ glViewport(0, 0, TexWidth, TexHeight); diff --git a/progs/trivial/clear-fbo.c b/progs/trivial/clear-fbo.c index 0aeb45489f2..6435c901adc 100644 --- a/progs/trivial/clear-fbo.c +++ b/progs/trivial/clear-fbo.c @@ -73,7 +73,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/clear-random.c b/progs/trivial/clear-random.c index e3da23a8f55..ab67f84518d 100644 --- a/progs/trivial/clear-random.c +++ b/progs/trivial/clear-random.c @@ -61,7 +61,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(0); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/clear-scissor.c b/progs/trivial/clear-scissor.c index 01735327480..2b6dee77a96 100644 --- a/progs/trivial/clear-scissor.c +++ b/progs/trivial/clear-scissor.c @@ -38,7 +38,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); } diff --git a/progs/trivial/clear.c b/progs/trivial/clear.c index 03857b4b893..56c3ea52e6a 100644 --- a/progs/trivial/clear.c +++ b/progs/trivial/clear.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(0); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/createwin.c b/progs/trivial/createwin.c index f2cc6f1cffc..93da30ee294 100644 --- a/progs/trivial/createwin.c +++ b/progs/trivial/createwin.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); @@ -116,6 +116,6 @@ int main(int argc, char **argv) glutReshapeFunc(Reshape); glutKeyboardFunc(Key); glutDisplayFunc(Draw); -// glutMainLoop(); + /* glutMainLoop(); */ return 0; } diff --git a/progs/trivial/dlist-begin-call-end.c b/progs/trivial/dlist-begin-call-end.c index 0d0aed7c729..dbfaef3978f 100644 --- a/progs/trivial/dlist-begin-call-end.c +++ b/progs/trivial/dlist-begin-call-end.c @@ -49,7 +49,7 @@ static void Init(void) */ first_list = glGenLists(1); glNewList(first_list, GL_COMPILE); -// glColor3f(0,1,0); + /* glColor3f(0,1,0); */ glEndList(); @@ -87,7 +87,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-dangling.c b/progs/trivial/dlist-dangling.c index de106280092..756ab93f870 100644 --- a/progs/trivial/dlist-dangling.c +++ b/progs/trivial/dlist-dangling.c @@ -74,7 +74,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-edgeflag-dangling.c b/progs/trivial/dlist-edgeflag-dangling.c index 3d3aaeb6944..51504471e2c 100644 --- a/progs/trivial/dlist-edgeflag-dangling.c +++ b/progs/trivial/dlist-edgeflag-dangling.c @@ -76,7 +76,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-edgeflag.c b/progs/trivial/dlist-edgeflag.c index 8002129ed14..9456b964732 100644 --- a/progs/trivial/dlist-edgeflag.c +++ b/progs/trivial/dlist-edgeflag.c @@ -81,7 +81,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-flat-tri.c b/progs/trivial/dlist-flat-tri.c index c3dd7921e39..3ee9b283a44 100644 --- a/progs/trivial/dlist-flat-tri.c +++ b/progs/trivial/dlist-flat-tri.c @@ -93,7 +93,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-mat-tri.c b/progs/trivial/dlist-mat-tri.c index ed3a4c5981a..d17c4b913b8 100644 --- a/progs/trivial/dlist-mat-tri.c +++ b/progs/trivial/dlist-mat-tri.c @@ -103,7 +103,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-recursive-call.c b/progs/trivial/dlist-recursive-call.c index fe06b2bbd72..90224f63cb2 100644 --- a/progs/trivial/dlist-recursive-call.c +++ b/progs/trivial/dlist-recursive-call.c @@ -118,7 +118,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-tri-flat-tri.c b/progs/trivial/dlist-tri-flat-tri.c index 4dbb7884869..3265a4d6dcd 100644 --- a/progs/trivial/dlist-tri-flat-tri.c +++ b/progs/trivial/dlist-tri-flat-tri.c @@ -99,7 +99,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/dlist-tri-mat-tri.c b/progs/trivial/dlist-tri-mat-tri.c index f69854ae586..053bb124a23 100644 --- a/progs/trivial/dlist-tri-mat-tri.c +++ b/progs/trivial/dlist-tri-mat-tri.c @@ -102,7 +102,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/draw2arrays.c b/progs/trivial/draw2arrays.c index 95a89981d3a..2345ae9e9ed 100644 --- a/progs/trivial/draw2arrays.c +++ b/progs/trivial/draw2arrays.c @@ -66,7 +66,7 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ glDrawArrays( GL_TRIANGLES, 1, 3 ); glFlush(); diff --git a/progs/trivial/drawarrays.c b/progs/trivial/drawarrays.c index 27d86682f75..f5c0a50f9a9 100644 --- a/progs/trivial/drawarrays.c +++ b/progs/trivial/drawarrays.c @@ -77,7 +77,7 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ glDrawArrays( GL_TRIANGLES, 1, 3 ); glFlush(); diff --git a/progs/trivial/line-clip.c b/progs/trivial/line-clip.c index 5276baffd5d..e4e388ed5cd 100644 --- a/progs/trivial/line-clip.c +++ b/progs/trivial/line-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-cull.c b/progs/trivial/line-cull.c index 1e1b77a942c..c531ff132f5 100644 --- a/progs/trivial/line-cull.c +++ b/progs/trivial/line-cull.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-flat.c b/progs/trivial/line-flat.c index 14f0ac07825..e2ddb87b9ef 100644 --- a/progs/trivial/line-flat.c +++ b/progs/trivial/line-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-stipple-wide.c b/progs/trivial/line-stipple-wide.c index 1804ffad3f0..767583bbea5 100644 --- a/progs/trivial/line-stipple-wide.c +++ b/progs/trivial/line-stipple-wide.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-userclip-clip.c b/progs/trivial/line-userclip-clip.c index 8e030b47cea..3265b2c3bfe 100644 --- a/progs/trivial/line-userclip-clip.c +++ b/progs/trivial/line-userclip-clip.c @@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-userclip-nop-clip.c b/progs/trivial/line-userclip-nop-clip.c index 6fcd4bcfe73..0198e27807e 100644 --- a/progs/trivial/line-userclip-nop-clip.c +++ b/progs/trivial/line-userclip-nop-clip.c @@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-userclip-nop.c b/progs/trivial/line-userclip-nop.c index e59fd133a5f..6c863a3c82b 100644 --- a/progs/trivial/line-userclip-nop.c +++ b/progs/trivial/line-userclip-nop.c @@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-userclip.c b/progs/trivial/line-userclip.c index e30be5580bd..6cfcb6fc732 100644 --- a/progs/trivial/line-userclip.c +++ b/progs/trivial/line-userclip.c @@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line-wide.c b/progs/trivial/line-wide.c index b74021dea73..1945712c5d0 100644 --- a/progs/trivial/line-wide.c +++ b/progs/trivial/line-wide.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/line.c b/progs/trivial/line.c index e1d73280bfc..58ab96836f8 100644 --- a/progs/trivial/line.c +++ b/progs/trivial/line.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/lineloop-clip.c b/progs/trivial/lineloop-clip.c index 45fa47491f8..5e6b6217a1a 100644 --- a/progs/trivial/lineloop-clip.c +++ b/progs/trivial/lineloop-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/lineloop.c b/progs/trivial/lineloop.c index c290dbd8cb3..82eccd24f8f 100644 --- a/progs/trivial/lineloop.c +++ b/progs/trivial/lineloop.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/linestrip-clip.c b/progs/trivial/linestrip-clip.c index f2528229218..5e90ea2eb05 100644 --- a/progs/trivial/linestrip-clip.c +++ b/progs/trivial/linestrip-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/linestrip-flat-stipple.c b/progs/trivial/linestrip-flat-stipple.c index 5caa7244235..bae5c3a1c3b 100644 --- a/progs/trivial/linestrip-flat-stipple.c +++ b/progs/trivial/linestrip-flat-stipple.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/linestrip-stipple-wide.c b/progs/trivial/linestrip-stipple-wide.c index 701c82c266a..0296941a0de 100644 --- a/progs/trivial/linestrip-stipple-wide.c +++ b/progs/trivial/linestrip-stipple-wide.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/linestrip-stipple.c b/progs/trivial/linestrip-stipple.c index df2eef96b5d..a847d47deeb 100644 --- a/progs/trivial/linestrip-stipple.c +++ b/progs/trivial/linestrip-stipple.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/linestrip.c b/progs/trivial/linestrip.c index 0219b1ab70e..b6d68821463 100644 --- a/progs/trivial/linestrip.c +++ b/progs/trivial/linestrip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/point-clip.c b/progs/trivial/point-clip.c index 4c89ba598d7..23cfd778637 100644 --- a/progs/trivial/point-clip.c +++ b/progs/trivial/point-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/point-param.c b/progs/trivial/point-param.c index 6f43720a892..46bd773265f 100644 --- a/progs/trivial/point-param.c +++ b/progs/trivial/point-param.c @@ -59,7 +59,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); } diff --git a/progs/trivial/point-sprite.c b/progs/trivial/point-sprite.c index 5d29a6a3cf9..16e6771514b 100644 --- a/progs/trivial/point-sprite.c +++ b/progs/trivial/point-sprite.c @@ -96,7 +96,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/point-wide-smooth.c b/progs/trivial/point-wide-smooth.c index f6e9b8df5f9..752cb8aee38 100644 --- a/progs/trivial/point-wide-smooth.c +++ b/progs/trivial/point-wide-smooth.c @@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/point-wide.c b/progs/trivial/point-wide.c index 8abd64c6a99..3b00ee9e500 100644 --- a/progs/trivial/point-wide.c +++ b/progs/trivial/point-wide.c @@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/point.c b/progs/trivial/point.c index 49959dcc487..8f5299cf6b5 100644 --- a/progs/trivial/point.c +++ b/progs/trivial/point.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/poly-flat-clip.c b/progs/trivial/poly-flat-clip.c index 5490068b08e..2a968bed40e 100644 --- a/progs/trivial/poly-flat-clip.c +++ b/progs/trivial/poly-flat-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/poly-flat-unfilled-clip.c b/progs/trivial/poly-flat-unfilled-clip.c index 26b90ef9645..89f4e0656ab 100644 --- a/progs/trivial/poly-flat-unfilled-clip.c +++ b/progs/trivial/poly-flat-unfilled-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/poly-flat.c b/progs/trivial/poly-flat.c index a4e3cdb6334..33c2e04e0f8 100644 --- a/progs/trivial/poly-flat.c +++ b/progs/trivial/poly-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/poly-unfilled.c b/progs/trivial/poly-unfilled.c index 2ad443dc159..c8c0d7a9e37 100644 --- a/progs/trivial/poly-unfilled.c +++ b/progs/trivial/poly-unfilled.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/poly.c b/progs/trivial/poly.c index e5b788ea5be..964eb42d789 100644 --- a/progs/trivial/poly.c +++ b/progs/trivial/poly.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/psb_context.c b/progs/trivial/psb_context.c deleted file mode 100644 index e69de29bb2d..00000000000 --- a/progs/trivial/psb_context.c +++ /dev/null diff --git a/progs/trivial/quad-clip-all-vertices.c b/progs/trivial/quad-clip-all-vertices.c index 60c87fc9ce1..7712d8ca5b7 100644 --- a/progs/trivial/quad-clip-all-vertices.c +++ b/progs/trivial/quad-clip-all-vertices.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-clip.c b/progs/trivial/quad-clip.c index 063de6106a6..2847c9f9608 100644 --- a/progs/trivial/quad-clip.c +++ b/progs/trivial/quad-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-degenerate.c b/progs/trivial/quad-degenerate.c index fdc142bcd61..85e129d4be2 100644 --- a/progs/trivial/quad-degenerate.c +++ b/progs/trivial/quad-degenerate.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-flat.c b/progs/trivial/quad-flat.c index e3147b3b3fe..bed98e31a4e 100644 --- a/progs/trivial/quad-flat.c +++ b/progs/trivial/quad-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-offset-factor.c b/progs/trivial/quad-offset-factor.c index dfe99bbae68..1fc57a54ae7 100644 --- a/progs/trivial/quad-offset-factor.c +++ b/progs/trivial/quad-offset-factor.c @@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-offset-unfilled.c b/progs/trivial/quad-offset-unfilled.c index 06590021fed..62f50fb98cc 100644 --- a/progs/trivial/quad-offset-unfilled.c +++ b/progs/trivial/quad-offset-unfilled.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-offset-units.c b/progs/trivial/quad-offset-units.c index 922529d977e..1ac2338692f 100644 --- a/progs/trivial/quad-offset-units.c +++ b/progs/trivial/quad-offset-units.c @@ -55,7 +55,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-tex-alpha.c b/progs/trivial/quad-tex-alpha.c index eebaf9170ec..9db6792fad3 100644 --- a/progs/trivial/quad-tex-alpha.c +++ b/progs/trivial/quad-tex-alpha.c @@ -88,7 +88,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-tex-pbo.c b/progs/trivial/quad-tex-pbo.c index ad41a9a22e5..b7aa1db4360 100644 --- a/progs/trivial/quad-tex-pbo.c +++ b/progs/trivial/quad-tex-pbo.c @@ -105,7 +105,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-unfilled-clip.c b/progs/trivial/quad-unfilled-clip.c index 761878bd4b6..d2e87187751 100644 --- a/progs/trivial/quad-unfilled-clip.c +++ b/progs/trivial/quad-unfilled-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-unfilled-stipple.c b/progs/trivial/quad-unfilled-stipple.c index cd7d2769284..8c1737e6756 100644 --- a/progs/trivial/quad-unfilled-stipple.c +++ b/progs/trivial/quad-unfilled-stipple.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad-unfilled.c b/progs/trivial/quad-unfilled.c index d64f17fdf95..b756449d7a8 100644 --- a/progs/trivial/quad-unfilled.c +++ b/progs/trivial/quad-unfilled.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quad.c b/progs/trivial/quad.c index d360e309d30..582de783d59 100644 --- a/progs/trivial/quad.c +++ b/progs/trivial/quad.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quads.c b/progs/trivial/quads.c index fe11fef207c..de7854a255e 100644 --- a/progs/trivial/quads.c +++ b/progs/trivial/quads.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quadstrip-cont.c b/progs/trivial/quadstrip-cont.c index 329523531aa..44412698dc5 100644 --- a/progs/trivial/quadstrip-cont.c +++ b/progs/trivial/quadstrip-cont.c @@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quadstrip-flat.c b/progs/trivial/quadstrip-flat.c index 228c6c255e5..0e0b3b49fa6 100644 --- a/progs/trivial/quadstrip-flat.c +++ b/progs/trivial/quadstrip-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/quadstrip.c b/progs/trivial/quadstrip.c index d49a9a53020..1be815fb8cd 100644 --- a/progs/trivial/quadstrip.c +++ b/progs/trivial/quadstrip.c @@ -57,7 +57,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/readpixels.c b/progs/trivial/readpixels.c index 5671618446a..b063f179569 100644 --- a/progs/trivial/readpixels.c +++ b/progs/trivial/readpixels.c @@ -39,7 +39,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(0); default: - return; + break; } glutPostRedisplay(); } diff --git a/progs/trivial/tri-alpha-tex.c b/progs/trivial/tri-alpha-tex.c index 780ebe6be5b..853d564ae7b 100644 --- a/progs/trivial/tri-alpha-tex.c +++ b/progs/trivial/tri-alpha-tex.c @@ -88,7 +88,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-alpha.c b/progs/trivial/tri-alpha.c index aec1cbb3772..bd1c88ecf8e 100644 --- a/progs/trivial/tri-alpha.c +++ b/progs/trivial/tri-alpha.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-blend-color.c b/progs/trivial/tri-blend-color.c index 92f019259ec..629b35c4abb 100644 --- a/progs/trivial/tri-blend-color.c +++ b/progs/trivial/tri-blend-color.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-blend-max.c b/progs/trivial/tri-blend-max.c index b39f8f3f12a..b173dab8ec1 100644 --- a/progs/trivial/tri-blend-max.c +++ b/progs/trivial/tri-blend-max.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend-min.c b/progs/trivial/tri-blend-min.c index 656297c0ce0..629139acae7 100644 --- a/progs/trivial/tri-blend-min.c +++ b/progs/trivial/tri-blend-min.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend-revsub.c b/progs/trivial/tri-blend-revsub.c index fe225f1f4e0..ef1e92c85dc 100644 --- a/progs/trivial/tri-blend-revsub.c +++ b/progs/trivial/tri-blend-revsub.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend-sub.c b/progs/trivial/tri-blend-sub.c index cc1aeaf4a48..3c560ae6ef7 100644 --- a/progs/trivial/tri-blend-sub.c +++ b/progs/trivial/tri-blend-sub.c @@ -83,7 +83,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -99,7 +99,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -111,7 +111,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-blend.c b/progs/trivial/tri-blend.c index 58c451c9769..f41be89b097 100644 --- a/progs/trivial/tri-blend.c +++ b/progs/trivial/tri-blend.c @@ -81,7 +81,7 @@ static void drawRightTriangle(void) glDisable (GL_BLEND); } -void display(void) +static void display(void) { glClear(GL_COLOR_BUFFER_BIT); @@ -97,7 +97,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -109,7 +109,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 't': diff --git a/progs/trivial/tri-clear.c b/progs/trivial/tri-clear.c index f49186bd8ae..e52ed81bf44 100644 --- a/progs/trivial/tri-clear.c +++ b/progs/trivial/tri-clear.c @@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-clip.c b/progs/trivial/tri-clip.c index e1deca1bdcf..3e3879c9859 100644 --- a/progs/trivial/tri-clip.c +++ b/progs/trivial/tri-clip.c @@ -56,7 +56,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); } diff --git a/progs/trivial/tri-cull-both.c b/progs/trivial/tri-cull-both.c index 864be710c2a..809599d4a6d 100644 --- a/progs/trivial/tri-cull-both.c +++ b/progs/trivial/tri-cull-both.c @@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-dlist.c b/progs/trivial/tri-dlist.c index c410be221a7..62d0a965d82 100644 --- a/progs/trivial/tri-dlist.c +++ b/progs/trivial/tri-dlist.c @@ -75,7 +75,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-fbo-tex.c b/progs/trivial/tri-fbo-tex.c index 72b4cf3683d..8d1f871328d 100644 --- a/progs/trivial/tri-fbo-tex.c +++ b/progs/trivial/tri-fbo-tex.c @@ -189,9 +189,6 @@ Key(unsigned char key, int x, int y) static void Init(int argc, char *argv[]) { - static const GLfloat mat[4] = { 1.0, 0.5, 0.5, 1.0 }; - GLint i; - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { printf("GL_EXT_framebuffer_object not found!\n"); exit(0); diff --git a/progs/trivial/tri-fbo.c b/progs/trivial/tri-fbo.c index 1ed177ffdfb..089180f97ad 100644 --- a/progs/trivial/tri-fbo.c +++ b/progs/trivial/tri-fbo.c @@ -75,7 +75,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-flat-clip.c b/progs/trivial/tri-flat-clip.c index 2aab5ba00a5..a23f8a382b0 100644 --- a/progs/trivial/tri-flat-clip.c +++ b/progs/trivial/tri-flat-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-flat.c b/progs/trivial/tri-flat.c index ea703ec6f3f..0614321844e 100644 --- a/progs/trivial/tri-flat.c +++ b/progs/trivial/tri-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-fog.c b/progs/trivial/tri-fog.c index 0cea3d32582..7fc254a4675 100644 --- a/progs/trivial/tri-fog.c +++ b/progs/trivial/tri-fog.c @@ -72,7 +72,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-fp-const-imm.c b/progs/trivial/tri-fp-const-imm.c index d2df442abfc..accea62042d 100644 --- a/progs/trivial/tri-fp-const-imm.c +++ b/progs/trivial/tri-fp-const-imm.c @@ -92,7 +92,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-fp.c b/progs/trivial/tri-fp.c index 4d1508120ea..6ecfef4d2ac 100644 --- a/progs/trivial/tri-fp.c +++ b/progs/trivial/tri-fp.c @@ -42,7 +42,7 @@ static void Init(void) static const char *prog1 = "!!ARBfp1.0\n" "MOV result.color, fragment.texcoord[1];\n" -// "MOV result.color, fragment.color;\n" + /* "MOV result.color, fragment.color;\n" */ "END\n"; @@ -90,7 +90,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-lit-material.c b/progs/trivial/tri-lit-material.c index ff9fb2c4dd6..16cebb2b984 100644 --- a/progs/trivial/tri-lit-material.c +++ b/progs/trivial/tri-lit-material.c @@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-lit.c b/progs/trivial/tri-lit.c index 15a7ad24c51..26ebd99d917 100644 --- a/progs/trivial/tri-lit.c +++ b/progs/trivial/tri-lit.c @@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-logicop-none.c b/progs/trivial/tri-logicop-none.c index 53c2614ac32..2b6a3d6f5c8 100644 --- a/progs/trivial/tri-logicop-none.c +++ b/progs/trivial/tri-logicop-none.c @@ -101,7 +101,7 @@ static void Draw(void) glVertex3f( 0.5, -0.5, -30.0); glEnd(); -// glLineWidth(12.0); + /* glLineWidth(12.0); */ /* Redraw parts of the lines: */ diff --git a/progs/trivial/tri-logicop-xor.c b/progs/trivial/tri-logicop-xor.c index f018a851ace..b8207cd6d8a 100644 --- a/progs/trivial/tri-logicop-xor.c +++ b/progs/trivial/tri-logicop-xor.c @@ -105,7 +105,7 @@ static void Draw(void) glVertex3f( 0.5, -0.5, -30.0); glEnd(); -// glLineWidth(12.0); + /* glLineWidth(12.0); */ /* Redraw parts of the lines to remove them: */ diff --git a/progs/trivial/tri-multitex-vbo.c b/progs/trivial/tri-multitex-vbo.c index e319447ac15..ca4edaa5ddc 100644 --- a/progs/trivial/tri-multitex-vbo.c +++ b/progs/trivial/tri-multitex-vbo.c @@ -192,7 +192,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-orig.c b/progs/trivial/tri-orig.c index e7cfee3a367..f86ac52a026 100644 --- a/progs/trivial/tri-orig.c +++ b/progs/trivial/tri-orig.c @@ -51,7 +51,7 @@ static void Reshape(int width, int height) glMatrixMode(GL_PROJECTION); glLoadIdentity(); -/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */ + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); glMatrixMode(GL_MODELVIEW); } @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); @@ -74,11 +74,11 @@ static void Draw(void) glBegin(GL_TRIANGLES); glColor3f(0,0,.7); - glVertex3f( 0.9, -0.9, -0.0); + glVertex3f( 0.9, -0.9, -30.0); glColor3f(.8,0,0); - glVertex3f( 0.9, 0.9, -0.0); + glVertex3f( 0.9, 0.9, -30.0); glColor3f(0,.9,0); - glVertex3f(-0.9, 0.0, -0.0); + glVertex3f(-0.9, 0.0, -30.0); glEnd(); glFlush(); @@ -119,7 +119,7 @@ int main(int argc, char **argv) glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250); - type = GLUT_RGB | GLUT_ALPHA; + type = GLUT_RGB; type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE; glutInitDisplayMode(type); diff --git a/progs/trivial/tri-query.c b/progs/trivial/tri-query.c index 85e39df2dfa..8898f182c78 100644 --- a/progs/trivial/tri-query.c +++ b/progs/trivial/tri-query.c @@ -39,6 +39,11 @@ GLenum doubleBuffer; static void Init(void) { + if (!glutExtensionSupported("GL_ARB_occlusion_query")) { + fprintf(stderr, "Sorry, this program requires GL_ARB_occlusion_query\n"); + exit(1); + } + fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER)); fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION)); fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR)); @@ -67,7 +72,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-scissor-tri.c b/progs/trivial/tri-scissor-tri.c index 608ebf29cff..d65502d91b9 100644 --- a/progs/trivial/tri-scissor-tri.c +++ b/progs/trivial/tri-scissor-tri.c @@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-square.c b/progs/trivial/tri-square.c index 0b82a1dd8e3..2014bd489c3 100644 --- a/progs/trivial/tri-square.c +++ b/progs/trivial/tri-square.c @@ -63,7 +63,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-stipple.c b/progs/trivial/tri-stipple.c index aa94fa224b7..15a08fec7c8 100644 --- a/progs/trivial/tri-stipple.c +++ b/progs/trivial/tri-stipple.c @@ -77,7 +77,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-tex-3d.c b/progs/trivial/tri-tex-3d.c index 3ccbe125105..073a080d7a7 100644 --- a/progs/trivial/tri-tex-3d.c +++ b/progs/trivial/tri-tex-3d.c @@ -97,7 +97,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-tex.c b/progs/trivial/tri-tex.c index 56afb4748d7..244e1545042 100644 --- a/progs/trivial/tri-tex.c +++ b/progs/trivial/tri-tex.c @@ -94,7 +94,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-tri.c b/progs/trivial/tri-tri.c index f996bd01a16..7bf400793ea 100644 --- a/progs/trivial/tri-tri.c +++ b/progs/trivial/tri-tri.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-clip.c b/progs/trivial/tri-unfilled-clip.c index 2fd894a49a8..585919e16d1 100644 --- a/progs/trivial/tri-unfilled-clip.c +++ b/progs/trivial/tri-unfilled-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-edgeflag.c b/progs/trivial/tri-unfilled-edgeflag.c index 11c21d1bf68..f536f642296 100644 --- a/progs/trivial/tri-unfilled-edgeflag.c +++ b/progs/trivial/tri-unfilled-edgeflag.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-point.c b/progs/trivial/tri-unfilled-point.c index 750a254669a..11e276e1a5b 100644 --- a/progs/trivial/tri-unfilled-point.c +++ b/progs/trivial/tri-unfilled-point.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-smooth.c b/progs/trivial/tri-unfilled-smooth.c index eddae176e5f..fa31667e658 100644 --- a/progs/trivial/tri-unfilled-smooth.c +++ b/progs/trivial/tri-unfilled-smooth.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-tri-lit.c b/progs/trivial/tri-unfilled-tri-lit.c index 1d42b40b713..d6baeb46978 100644 --- a/progs/trivial/tri-unfilled-tri-lit.c +++ b/progs/trivial/tri-unfilled-tri-lit.c @@ -65,7 +65,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-tri.c b/progs/trivial/tri-unfilled-tri.c index 695cc890955..75a70b8a412 100644 --- a/progs/trivial/tri-unfilled-tri.c +++ b/progs/trivial/tri-unfilled-tri.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-userclip-stip.c b/progs/trivial/tri-unfilled-userclip-stip.c index ddc0dffd4f4..02bfa92f835 100644 --- a/progs/trivial/tri-unfilled-userclip-stip.c +++ b/progs/trivial/tri-unfilled-userclip-stip.c @@ -67,7 +67,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled-userclip.c b/progs/trivial/tri-unfilled-userclip.c index 0dec0bfc9b4..11e53fc7cc9 100644 --- a/progs/trivial/tri-unfilled-userclip.c +++ b/progs/trivial/tri-unfilled-userclip.c @@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-unfilled.c b/progs/trivial/tri-unfilled.c index b98cb9a842a..afa1058dad4 100644 --- a/progs/trivial/tri-unfilled.c +++ b/progs/trivial/tri-unfilled.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-userclip.c b/progs/trivial/tri-userclip.c index 8f37e0fae20..5651c738325 100644 --- a/progs/trivial/tri-userclip.c +++ b/progs/trivial/tri-userclip.c @@ -66,7 +66,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-z-9.c b/progs/trivial/tri-z-9.c index 099e89f6f4a..37b9e2f8732 100644 --- a/progs/trivial/tri-z-9.c +++ b/progs/trivial/tri-z-9.c @@ -61,7 +61,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-z-eq.c b/progs/trivial/tri-z-eq.c index 195e8a26f6d..c04ffae7f1a 100644 --- a/progs/trivial/tri-z-eq.c +++ b/progs/trivial/tri-z-eq.c @@ -61,7 +61,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tri-z.c b/progs/trivial/tri-z.c index 014aaa071a5..092249dd765 100644 --- a/progs/trivial/tri-z.c +++ b/progs/trivial/tri-z.c @@ -101,7 +101,7 @@ static void drawRightTriangle(void) glEnd(); } -void display(void) +static void display(void) { printf("GL_CLEAR_DEPTH = %.2f, GL_DEPTH_FUNC = %s, DepthRange(%.1f, %.1f)\n", clearVal, funcs[curFunc].str, minZ, maxZ); @@ -124,7 +124,7 @@ void display(void) glFlush(); } -void reshape(int w, int h) +static void reshape(int w, int h) { glViewport(0, 0, (GLsizei) w, (GLsizei) h); glMatrixMode(GL_PROJECTION); @@ -136,7 +136,7 @@ void reshape(int w, int h) } /* ARGSUSED1 */ -void keyboard(unsigned char key, int x, int y) +static void keyboard(unsigned char key, int x, int y) { switch (key) { case 'n': diff --git a/progs/trivial/trifan-flat-clip.c b/progs/trivial/trifan-flat-clip.c index 199f91a637e..89bc471191e 100644 --- a/progs/trivial/trifan-flat-clip.c +++ b/progs/trivial/trifan-flat-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/trifan-flat-unfilled-clip.c b/progs/trivial/trifan-flat-unfilled-clip.c index ea3e1553872..3a1a226e546 100644 --- a/progs/trivial/trifan-flat-unfilled-clip.c +++ b/progs/trivial/trifan-flat-unfilled-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/trifan-flat.c b/progs/trivial/trifan-flat.c index d69b4887e39..d25abdf49eb 100644 --- a/progs/trivial/trifan-flat.c +++ b/progs/trivial/trifan-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/trifan-unfilled.c b/progs/trivial/trifan-unfilled.c index 91447e4e44d..2e3ff8218f0 100644 --- a/progs/trivial/trifan-unfilled.c +++ b/progs/trivial/trifan-unfilled.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/trifan.c b/progs/trivial/trifan.c index 84eb4172de1..b8a76151148 100644 --- a/progs/trivial/trifan.c +++ b/progs/trivial/trifan.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tristrip-clip.c b/progs/trivial/tristrip-clip.c index 343e2938049..4e6ee1fbca2 100644 --- a/progs/trivial/tristrip-clip.c +++ b/progs/trivial/tristrip-clip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tristrip-flat.c b/progs/trivial/tristrip-flat.c index 02da97efcea..a90b8b6cb68 100644 --- a/progs/trivial/tristrip-flat.c +++ b/progs/trivial/tristrip-flat.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/tristrip.c b/progs/trivial/tristrip.c index 77bf2fad282..29915ff111d 100644 --- a/progs/trivial/tristrip.c +++ b/progs/trivial/tristrip.c @@ -62,7 +62,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/vbo-drawarrays.c b/progs/trivial/vbo-drawarrays.c index c29954b9033..cb26e841156 100644 --- a/progs/trivial/vbo-drawarrays.c +++ b/progs/trivial/vbo-drawarrays.c @@ -83,7 +83,7 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ glDrawArrays( GL_TRIANGLES, 1, 3 ); glFlush(); diff --git a/progs/trivial/vbo-noninterleaved.c b/progs/trivial/vbo-noninterleaved.c index 0672ca50ff1..f7c42a89818 100644 --- a/progs/trivial/vbo-noninterleaved.c +++ b/progs/trivial/vbo-noninterleaved.c @@ -87,8 +87,8 @@ static void Display( void ) glEnable(GL_VERTEX_PROGRAM_ARB); -// glDrawArrays( GL_TRIANGLES, 0, 3 ); -// glDrawArrays( GL_TRIANGLES, 1, 3 ); + /* glDrawArrays( GL_TRIANGLES, 0, 3 ); */ + /* glDrawArrays( GL_TRIANGLES, 1, 3 ); */ glDrawArrays( GL_QUADS, 0, 4 ); glFlush(); diff --git a/progs/trivial/vbo-tri.c b/progs/trivial/vbo-tri.c new file mode 100644 index 00000000000..d4cba14414c --- /dev/null +++ b/progs/trivial/vbo-tri.c @@ -0,0 +1,131 @@ +/* Even simpler for many drivers than trivial/tri -- pass-through + * vertex shader and vertex data in a VBO. + */ + +#include <assert.h> +#include <string.h> +#include <stdio.h> +#include <stdlib.h> +#include <math.h> +#include <GL/glew.h> +#include <GL/glut.h> + + +struct { + GLfloat pos[4]; + GLfloat color[4]; +} verts[] = +{ + { { -0.9, -0.9, 0.0, 1.0 }, + {.8,0,0, 1}, + }, + + { { 0.9, -0.9, 0.0, 1.0 }, + { 0, .9, 0, 1 }, + }, + + { { 0, 0.9, 0.0, 1.0 }, + {0,0,.7, 1}, + }, +}; + +GLuint arrayObj; + +static void Init( void ) +{ + GLint errno; + GLuint prognum; + + static const char *prog1 = + "!!ARBvp1.0\n" + "MOV result.color, vertex.color;\n" + "MOV result.position, vertex.position;\n" + "END\n"; + + + glGenProgramsARB(1, &prognum); + + glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum); + glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, + strlen(prog1), (const GLubyte *) prog1); + + assert(glIsProgramARB(prognum)); + errno = glGetError(); + printf("glGetError = %d\n", errno); + if (errno != GL_NO_ERROR) + { + GLint errorpos; + + glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos); + printf("errorpos: %d\n", errorpos); + printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB)); + } + + + glEnableClientState( GL_VERTEX_ARRAY ); + glEnableClientState( GL_COLOR_ARRAY ); + + glGenBuffersARB(1, &arrayObj); + glBindBufferARB(GL_ARRAY_BUFFER_ARB, arrayObj); + glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(verts), verts, GL_STATIC_DRAW_ARB); + + glVertexPointer( 4, GL_FLOAT, sizeof(verts[0]), 0 ); + glColorPointer( 4, GL_FLOAT, sizeof(verts[0]), (void *)(4*sizeof(float)) ); +} + + + +static void Display( void ) +{ + glClearColor(0.3, 0.3, 0.3, 1); + glClear( GL_COLOR_BUFFER_BIT ); + + glEnable(GL_VERTEX_PROGRAM_NV); + glDrawArrays( GL_TRIANGLES, 0, 3 ); + + glutSwapBuffers(); +} + + +static void Reshape( int width, int height ) +{ + glViewport( 0, 0, width, height ); + glMatrixMode( GL_PROJECTION ); + glLoadIdentity(); + glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); + glMatrixMode( GL_MODELVIEW ); + glLoadIdentity(); + /*glTranslatef( 0.0, 0.0, -15.0 );*/ +} + + +static void Key( unsigned char key, int x, int y ) +{ + (void) x; + (void) y; + switch (key) { + case 27: + exit(0); + break; + } + glutPostRedisplay(); +} + + + + +int main( int argc, char *argv[] ) +{ + glutInit( &argc, argv ); + glutInitWindowPosition( 0, 0 ); + glutInitWindowSize( 250, 250 ); + glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE ); + glutCreateWindow(argv[0]); + glewInit(); + glutReshapeFunc( Reshape ); + glutKeyboardFunc( Key ); + glutDisplayFunc( Display ); + Init(); + glutMainLoop(); + return 0; +} diff --git a/progs/trivial/vp-tri-cb-pos.c b/progs/trivial/vp-tri-cb-pos.c index 42bf9806b19..9cbc4d1193a 100644 --- a/progs/trivial/vp-tri-cb-pos.c +++ b/progs/trivial/vp-tri-cb-pos.c @@ -81,7 +81,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/vp-tri-cb-tex.c b/progs/trivial/vp-tri-cb-tex.c index 8290226675e..e543e2ec3fd 100644 --- a/progs/trivial/vp-tri-cb-tex.c +++ b/progs/trivial/vp-tri-cb-tex.c @@ -114,7 +114,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/trivial/vp-tri-invariant.c b/progs/trivial/vp-tri-invariant.c index ff241393659..4dbe95eb9a1 100644 --- a/progs/trivial/vp-tri-invariant.c +++ b/progs/trivial/vp-tri-invariant.c @@ -69,7 +69,7 @@ static void Key(unsigned char key, int x, int y) case 27: exit(1); default: - return; + break; } glutPostRedisplay(); diff --git a/progs/util/readtex.c b/progs/util/readtex.c index 8e923b6eb47..f6f511481ca 100644 --- a/progs/util/readtex.c +++ b/progs/util/readtex.c @@ -9,6 +9,7 @@ #include <GL/gl.h> #include <GL/glu.h> +#include <assert.h> #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -89,6 +90,7 @@ static rawImageRec *RawImageOpen(const char *fileName) rawImageRec *raw; GLenum swapFlag; int x; + size_t result; endianTest.testWord = 1; if (endianTest.testByte[0] == 1) { @@ -109,14 +111,21 @@ static rawImageRec *RawImageOpen(const char *fileName) raw->file = fopen(baseName + 1, "rb"); if(raw->file == NULL) { perror(fileName); + free(raw); return NULL; } } - fread(raw, 1, 12, raw->file); + result = fread(raw, 1, 12, raw->file); + assert(result == 12); if (swapFlag) { - ConvertShort(&raw->imagic, 6); + ConvertShort(&raw->imagic, 1); + ConvertShort(&raw->type, 1); + ConvertShort(&raw->dim, 1); + ConvertShort(&raw->sizeX, 1); + ConvertShort(&raw->sizeY, 1); + ConvertShort(&raw->sizeZ, 1); } raw->tmp = (unsigned char *)malloc(raw->sizeX*256); @@ -129,6 +138,12 @@ static rawImageRec *RawImageOpen(const char *fileName) if (raw->tmp == NULL || raw->tmpR == NULL || raw->tmpG == NULL || raw->tmpB == NULL) { fprintf(stderr, "Out of memory!\n"); + free(raw->tmp); + free(raw->tmpR); + free(raw->tmpG); + free(raw->tmpB); + free(raw->tmpA); + free(raw); return NULL; } @@ -138,12 +153,22 @@ static rawImageRec *RawImageOpen(const char *fileName) raw->rowSize = (GLint *)malloc(x); if (raw->rowStart == NULL || raw->rowSize == NULL) { fprintf(stderr, "Out of memory!\n"); + free(raw->tmp); + free(raw->tmpR); + free(raw->tmpG); + free(raw->tmpB); + free(raw->tmpA); + free(raw->rowStart); + free(raw->rowSize); + free(raw); return NULL; } raw->rleEnd = 512 + (2 * x); fseek(raw->file, 512, SEEK_SET); - fread(raw->rowStart, 1, x, raw->file); - fread(raw->rowSize, 1, x, raw->file); + result = fread(raw->rowStart, 1, x, raw->file); + assert(result == x); + result = fread(raw->rowSize, 1, x, raw->file); + assert(result == x); if (swapFlag) { ConvertLong(raw->rowStart, (long) (x/sizeof(GLuint))); ConvertLong((GLuint *)raw->rowSize, (long) (x/sizeof(GLint))); @@ -173,11 +198,13 @@ static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z) { unsigned char *iPtr, *oPtr, pixel; int count, done = 0; + size_t result; if ((raw->type & 0xFF00) == 0x0100) { fseek(raw->file, (long) raw->rowStart[y+z*raw->sizeY], SEEK_SET); - fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY], - raw->file); + result = fread(raw->tmp, 1, (unsigned int)raw->rowSize[y+z*raw->sizeY], + raw->file); + assert(result == (unsigned int)raw->rowSize[y+z*raw->sizeY]); iPtr = raw->tmp; oPtr = buf; @@ -202,7 +229,8 @@ static void RawImageGetRow(rawImageRec *raw, unsigned char *buf, int y, int z) } else { fseek(raw->file, 512+(y*raw->sizeX)+(z*raw->sizeX*raw->sizeY), SEEK_SET); - fread(buf, 1, raw->sizeX, raw->file); + result = fread(buf, 1, raw->sizeX, raw->file); + assert(result == raw->sizeX); } } @@ -215,6 +243,7 @@ static void RawImageGetData(rawImageRec *raw, TK_RGBImageRec *final) final->data = (unsigned char *)malloc((raw->sizeX+1)*(raw->sizeY+1)*4); if (final->data == NULL) { fprintf(stderr, "Out of memory!\n"); + return; } ptr = final->data; @@ -250,6 +279,7 @@ static TK_RGBImageRec *tkRGBImageLoad(const char *fileName) final = (TK_RGBImageRec *)malloc(sizeof(TK_RGBImageRec)); if (final == NULL) { fprintf(stderr, "Out of memory!\n"); + RawImageClose(raw); return NULL; } final->sizeX = raw->sizeX; @@ -305,6 +335,7 @@ GLboolean LoadRGBMipmaps2( const char *imageFile, GLenum target, fprintf(stderr, "Error in LoadRGBMipmaps %d-component images not implemented\n", image->components ); + FreeImage(image); return GL_FALSE; } @@ -356,6 +387,7 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height, fprintf(stderr, "Error in LoadRGBImage %d-component images not implemented\n", image->components ); + FreeImage(image); return NULL; } @@ -364,8 +396,10 @@ GLubyte *LoadRGBImage( const char *imageFile, GLint *width, GLint *height, bytes = image->sizeX * image->sizeY * image->components; buffer = (GLubyte *) malloc(bytes); - if (!buffer) + if (!buffer) { + FreeImage(image); return NULL; + } memcpy( (void *) buffer, (void *) image->data, bytes ); @@ -438,6 +472,7 @@ GLushort *LoadYUVImage( const char *imageFile, GLint *width, GLint *height ) fprintf(stderr, "Error in LoadYUVImage %d-component images not implemented\n", image->components ); + FreeImage(image); return NULL; } diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index 4db950016b8..2f44c388d8a 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -25,7 +25,11 @@ GLboolean ShadersSupported(void) { const char *version = (const char *) glGetString(GL_VERSION); - if (version[0] == '2' && version[1] == '.') { + + /* NVIDIA binary drivers will return "3.0.0", and they clearly support + * shaders. + */ + if (version[0] >= '2' && version[1] == '.') { return GL_TRUE; } else if (glutExtensionSupported("GL_ARB_vertex_shader") @@ -34,7 +38,8 @@ ShadersSupported(void) fprintf(stderr, "Warning: Trying ARB GLSL instead of OpenGL 2.x. This may not work.\n"); return GL_TRUE; } - return GL_TRUE; + fprintf(stderr, "Sorry, GLSL not supported with this OpenGL.\n"); + return GL_FALSE; } @@ -84,6 +89,7 @@ CompileShaderFile(GLenum shaderType, const char *filename) f = fopen(filename, "r"); if (!f) { fprintf(stderr, "Unable to open shader file %s\n", filename); + free(buffer); return 0; } @@ -94,6 +100,8 @@ CompileShaderFile(GLenum shaderType, const char *filename) shader = CompileShaderText(shaderType, buffer); } else { + fclose(f); + free(buffer); return 0; } diff --git a/progs/vp/SConscript b/progs/vp/SConscript index 640c5dd8470..787cb793af2 100644 --- a/progs/vp/SConscript +++ b/progs/vp/SConscript @@ -1,13 +1,6 @@ -Import('env') +Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -env.Program( +progs_env.Program( target = 'vp-tris', source = ['vp-tris.c'], ) diff --git a/progs/vp/add-param-imm.txt b/progs/vp/add-param-imm.txt new file mode 100644 index 00000000000..90bcf96528f --- /dev/null +++ b/progs/vp/add-param-imm.txt @@ -0,0 +1,7 @@ +!!ARBvp1.0 +TEMP R0; +PARAM Emission = state.material.emission; +ADD R0, vertex.color, {-0.5}.x; +ADD result.color, R0, Emission.w; +MOV result.position, vertex.position; +END diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c index 1356242d971..09236c296f7 100644 --- a/progs/vp/vp-tris.c +++ b/progs/vp/vp-tris.c @@ -96,12 +96,15 @@ static void Init( void ) exit(1); } - sz = (GLuint) fread(buf, 1, sizeof(buf), f); + sz = (GLuint) fread(buf, 1, sizeof(buf) - 1, f); + buf[sizeof(buf) - 1] = '\0'; if (!feof(f)) { fprintf(stderr, "file too long\n"); + fclose(f); exit(1); } + fclose(f); fprintf(stderr, "%.*s\n", sz, buf); if (strncmp( buf, "!!VP", 4 ) == 0) { diff --git a/progs/vpglsl/SConscript b/progs/vpglsl/SConscript index 640c5dd8470..787cb793af2 100644 --- a/progs/vpglsl/SConscript +++ b/progs/vpglsl/SConscript @@ -1,13 +1,6 @@ -Import('env') +Import('*') -if not env['GLUT']: - Return() - -env = env.Clone() - -env.Prepend(LIBS = ['$GLUT_LIB']) - -env.Program( +progs_env.Program( target = 'vp-tris', source = ['vp-tris.c'], ) diff --git a/progs/vpglsl/psiz-mul.glsl b/progs/vpglsl/psiz-mul.glsl index 77f4a46b520..d2a90d8578e 100644 --- a/progs/vpglsl/psiz-mul.glsl +++ b/progs/vpglsl/psiz-mul.glsl @@ -1,6 +1,6 @@ void main() { gl_FrontColor = gl_Color; - gl_PointSize = 10 * gl_Color.x; + gl_PointSize = 10.0 * gl_Color.x; gl_Position = gl_Vertex; } diff --git a/progs/vpglsl/vp-tris.c b/progs/vpglsl/vp-tris.c index b2b05080910..6a1fa3d3bf0 100644 --- a/progs/vpglsl/vp-tris.c +++ b/progs/vpglsl/vp-tris.c @@ -84,9 +84,9 @@ static void check_link(GLuint prog) static void setup_uniforms() { { - GLuint loc1f = glGetUniformLocationARB(program, "Offset1f"); - GLuint loc2f = glGetUniformLocationARB(program, "Offset2f"); - GLuint loc4f = glGetUniformLocationARB(program, "Offset4f"); + GLint loc1f = glGetUniformLocationARB(program, "Offset1f"); + GLint loc2f = glGetUniformLocationARB(program, "Offset2f"); + GLint loc4f = glGetUniformLocationARB(program, "Offset4f"); GLfloat vecKer[] = { 1.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, @@ -105,9 +105,9 @@ static void setup_uniforms() } { - GLuint loc1f = glGetUniformLocationARB(program, "KernelValue1f"); - GLuint loc2f = glGetUniformLocationARB(program, "KernelValue2f"); - GLuint loc4f = glGetUniformLocationARB(program, "KernelValue4f"); + GLint loc1f = glGetUniformLocationARB(program, "KernelValue1f"); + GLint loc2f = glGetUniformLocationARB(program, "KernelValue2f"); + GLint loc4f = glGetUniformLocationARB(program, "KernelValue4f"); GLfloat vecKer[] = { 1.0, 0.0, 0.0, 0.25, 0.0, 1.0, 0.0, 0.25, diff --git a/progs/wgl/SConscript b/progs/wgl/SConscript index 31f61676dec..248cc53a8d7 100644 --- a/progs/wgl/SConscript +++ b/progs/wgl/SConscript @@ -1,25 +1,17 @@ Import('*') -if env['platform'] != 'windows': +if progs_env['platform'] != 'windows': Return() -env = env.Clone() - -env.Append(LIBS = [ - 'kernel32', - 'user32', - 'gdi32', -]) - progs = [ 'sharedtex_mt', 'wglthreads', ] for prog in progs: - env.Program( + progs_env.Program( target = prog, source = prog + '/' + prog + '.c', ) -env.Program('wglinfo', ['wglinfo.c']) +progs_env.Program('wglinfo', ['wglinfo.c']) diff --git a/progs/xdemos/Makefile b/progs/xdemos/Makefile index 53e1c54ef3c..77f667978ce 100644 --- a/progs/xdemos/Makefile +++ b/progs/xdemos/Makefile @@ -8,6 +8,9 @@ INCDIR = $(TOP)/include LIB_DEP = $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) +# Add X11 and pthread libs to satisfy GNU gold. +APP_LIB_DEPS += -lX11 -lpthread + LIBS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(APP_LIB_DEPS) PROGS = \ diff --git a/progs/xdemos/corender.c b/progs/xdemos/corender.c index f2b8145e52b..640c902c136 100644 --- a/progs/xdemos/corender.c +++ b/progs/xdemos/corender.c @@ -55,6 +55,7 @@ setup_ipc(void) printf("Waiting for connection from another 'corender'\n"); Sock = AcceptConnection(k); + assert(Sock != -1); printf("Got connection, sending windowID\n"); @@ -186,7 +187,7 @@ redraw(Display *dpy) * Without this glClear(), depth buffer for the second process * is pretty much broken. */ - //glClear(GL_DEPTH_BUFFER_BIT); + /* glClear(GL_DEPTH_BUFFER_BIT); */ glPushMatrix(); glTranslatef(1, 0, 0); diff --git a/progs/xdemos/glsync.c b/progs/xdemos/glsync.c index 34167d339f3..da87306cf2a 100644 --- a/progs/xdemos/glsync.c +++ b/progs/xdemos/glsync.c @@ -95,7 +95,7 @@ enum sync_type { static void usage(char *name) { printf("usage: %s [-w <width>] [-h <height>] [-s<sync method>] " - "[-vc]\n", name); + "[-v]\n", name); printf("\t-s<sync method>:\n"); printf("\t\tn: none\n"); printf("\t\ts: SGI video sync extension\n"); diff --git a/progs/xdemos/glxinfo.c b/progs/xdemos/glxinfo.c index 445d3ea94b6..30cd5680642 100644 --- a/progs/xdemos/glxinfo.c +++ b/progs/xdemos/glxinfo.c @@ -116,7 +116,7 @@ print_extension_list(const char *ext) return; width = indent; - printf(indentString); + printf("%s", indentString); i = j = 0; while (1) { if (ext[j] == ' ' || ext[j] == 0) { @@ -126,7 +126,7 @@ print_extension_list(const char *ext) /* start a new line */ printf("\n"); width = indent; - printf(indentString); + printf("%s", indentString); } /* print the extension name between ext[i] and ext[j] */ while (i < j) { @@ -401,6 +401,10 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) root = RootWindow(dpy, scrnum); + /* + * Find a basic GLX visual. We'll then create a rendering context and + * query various info strings. + */ visinfo = glXChooseVisual(dpy, scrnum, attribSingle); if (!visinfo) visinfo = glXChooseVisual(dpy, scrnum, attribDouble); @@ -409,26 +413,29 @@ print_screen_info(Display *dpy, int scrnum, Bool allowDirect, GLboolean limits) ctx = glXCreateContext( dpy, visinfo, NULL, allowDirect ); #ifdef GLX_VERSION_1_3 - { + /* Try glXChooseFBConfig() if glXChooseVisual didn't work. + * XXX when would that happen? + */ + if (!visinfo) { int fbAttribSingle[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, - GLX_DOUBLEBUFFER, GL_TRUE, + GLX_DOUBLEBUFFER, GL_FALSE, None }; int fbAttribDouble[] = { GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_RED_SIZE, 1, GLX_GREEN_SIZE, 1, GLX_BLUE_SIZE, 1, + GLX_DOUBLEBUFFER, GL_TRUE, None }; GLXFBConfig *configs = NULL; int nConfigs; - if (!visinfo) - configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs); - if (!visinfo) + configs = glXChooseFBConfig(dpy, scrnum, fbAttribSingle, &nConfigs); + if (!configs) configs = glXChooseFBConfig(dpy, scrnum, fbAttribDouble, &nConfigs); if (configs) { @@ -964,8 +971,10 @@ print_fbconfig_info(Display *dpy, int scrnum, InfoMode mode) /* get list of all fbconfigs on this screen */ fbconfigs = glXGetFBConfigs(dpy, scrnum, &numFBConfigs); - if (numFBConfigs == 0) + if (numFBConfigs == 0) { + XFree(fbconfigs); return; + } printf("%d GLXFBConfigs:\n", numFBConfigs); if (mode == Normal) diff --git a/progs/xdemos/glxpbdemo.c b/progs/xdemos/glxpbdemo.c index 91fd30dcaa6..ecf318ec6a7 100644 --- a/progs/xdemos/glxpbdemo.c +++ b/progs/xdemos/glxpbdemo.c @@ -106,6 +106,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height ) if (0 == nConfigs || !fbConfigs) { printf("Error: glxChooseFBConfig failed\n"); + XFree(fbConfigs); XCloseDisplay(dpy); return 0; } diff --git a/progs/xdemos/offset.c b/progs/xdemos/offset.c index 6c5abf383be..314a4fcdd17 100644 --- a/progs/xdemos/offset.c +++ b/progs/xdemos/offset.c @@ -294,6 +294,7 @@ process_input(Display *dpy, Window win) { default: break; } + break; case ButtonPress: prevx = event.xbutton.x; prevy = event.xbutton.y; diff --git a/progs/xdemos/pbdemo.c b/progs/xdemos/pbdemo.c index 2573209336c..277df729246 100644 --- a/progs/xdemos/pbdemo.c +++ b/progs/xdemos/pbdemo.c @@ -131,6 +131,7 @@ MakePbuffer( Display *dpy, int screen, int width, int height ) fbConfigs = ChooseFBConfig(dpy, screen, fbAttribs[attempt], &nConfigs); if (nConfigs==0 || !fbConfigs) { printf("Note: glXChooseFBConfig(%s) failed\n", fbString[attempt]); + XFree(fbConfigs); continue; } diff --git a/progs/xdemos/pbinfo.c b/progs/xdemos/pbinfo.c index b43adf1bb70..edfa9c1f3b0 100644 --- a/progs/xdemos/pbinfo.c +++ b/progs/xdemos/pbinfo.c @@ -27,6 +27,7 @@ PrintConfigs(Display *dpy, int screen, Bool horizFormat) fbConfigs = GetAllFBConfigs(dpy, screen, &nConfigs); if (!nConfigs || !fbConfigs) { printf("Error: glxGetFBConfigs failed\n"); + XFree(fbConfigs); return; } diff --git a/progs/xdemos/sharedtex_mt.c b/progs/xdemos/sharedtex_mt.c index 07c1bfcc388..f924448cc43 100644 --- a/progs/xdemos/sharedtex_mt.c +++ b/progs/xdemos/sharedtex_mt.c @@ -447,7 +447,7 @@ main(int argc, char *argv[]) const char *dpyName = XDisplayName(NULL); pthread_t t0, t1, t2, t3; struct thread_init_arg tia0, tia1, tia2, tia3; - struct window *h0, *h1, *h2, *h3; + struct window *h0; XInitThreads(); @@ -462,9 +462,9 @@ main(int argc, char *argv[]) /* four windows and contexts sharing display lists and texture objects */ h0 = AddWindow(gDpy, dpyName, 10, 10, gCtx); - h1 = AddWindow(gDpy, dpyName, 330, 10, gCtx); - h2 = AddWindow(gDpy, dpyName, 10, 350, gCtx); - h3 = AddWindow(gDpy, dpyName, 330, 350, gCtx); + (void) AddWindow(gDpy, dpyName, 330, 10, gCtx); + (void) AddWindow(gDpy, dpyName, 10, 350, gCtx); + (void) AddWindow(gDpy, dpyName, 330, 350, gCtx); if (!glXMakeCurrent(gDpy, h0->Win, gCtx)) { Error(dpyName, "glXMakeCurrent failed for init thread."); |