diff options
Diffstat (limited to 'progs')
52 files changed, 313 insertions, 131 deletions
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 b3f7e00e5af..17767a148f9 100644 --- a/progs/demos/fbo_firecube.c +++ b/progs/demos/fbo_firecube.c @@ -1051,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 7d5c11aabf3..336aa580755 100644 --- a/progs/demos/fogcoord.c +++ b/progs/demos/fogcoord.c @@ -404,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 acba3e9583f..395b7caa2c1 100644 --- a/progs/demos/fslight.c +++ b/progs/demos/fslight.c @@ -600,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..d2a195f39a2 100644 --- a/progs/demos/geartrain.c +++ b/progs/demos/geartrain.c @@ -1049,19 +1049,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 69694b23a09..578736b4e27 100644 --- a/progs/demos/gloss.c +++ b/progs/demos/gloss.c @@ -436,8 +436,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 ); 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 ed03673cb62..265378b90a9 100644 --- a/progs/demos/ipers.c +++ b/progs/demos/ipers.c @@ -682,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..56781f68189 100644 --- a/progs/demos/isosurf.c +++ b/progs/demos/isosurf.c @@ -1061,9 +1061,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 01a06aba0ff..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 ); diff --git a/progs/demos/multiarb.c b/progs/demos/multiarb.c index 3d89d3a13e9..82796a0c3f4 100644 --- a/progs/demos/multiarb.c +++ b/progs/demos/multiarb.c @@ -338,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 503cf5de088..d162568b9f0 100644 --- a/progs/demos/projtex.c +++ b/progs/demos/projtex.c @@ -998,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 e9211aa3399..9cc464d2390 100644 --- a/progs/demos/ray.c +++ b/progs/demos/ray.c @@ -856,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 182b01d7ffc..cc4e4902694 100644 --- a/progs/demos/readpix.c +++ b/progs/demos/readpix.c @@ -383,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..627c3bfb57a 100644 --- a/progs/demos/terrain.c +++ b/progs/demos/terrain.c @@ -623,7 +623,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 31e1bbb3db0..1415ef1c43c 100644 --- a/progs/demos/textures.c +++ b/progs/demos/textures.c @@ -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/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/bump.c b/progs/glsl/bump.c index 50a0900f1c7..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 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/deriv.c b/progs/glsl/deriv.c index 30f2b75fef7..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(); @@ -163,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 = @@ -181,6 +189,7 @@ Init(void) program = LinkShaders(vertShader, fragShader); glUseProgram(program); + WinSizeUniform = glGetUniformLocation(program, "WinSize"); /*assert(glGetError() == 0);*/ @@ -220,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/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/rbug/bin_to_bmp.c b/progs/rbug/bin_to_bmp.c index cdae3486ce0..03ff622fee7 100644 --- a/progs/rbug/bin_to_bmp.c +++ b/progs/rbug/bin_to_bmp.c @@ -25,6 +25,7 @@ #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_network.h" @@ -54,10 +55,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,14 +63,11 @@ 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); } diff --git a/progs/tests/Makefile b/progs/tests/Makefile index 197e14d5b00..3e2541186b1 100644 --- a/progs/tests/Makefile +++ b/progs/tests/Makefile @@ -98,6 +98,7 @@ SOURCES = \ texdown \ texfilt.c \ texgenmix.c \ + texleak.c \ texline.c \ texobj.c \ texobjshare.c \ 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; +} |