comparison test/testgl.c @ 1736:3b2a92126f4d

Implemented bug #2, 117: Date: Mon, 21 Mar 2005 12:06:14 +0100 From: Per Inge Mathisen Subject: Re: [SDL] Outstanding patches? The patch adds support for setting SDL_GL_SWAP_CONTROL to Windows and X11. In Windows you can also query this enum to check that it is working, or see what the default is - such functionality does not exist in GLX. For more information on the standards implemented: http://oss.sgi.com/projects/ogl-sample/registry/SGI/swap_control.txt http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt
author Sam Lantinga <slouken@libsdl.org>
date Thu, 27 Apr 2006 07:59:16 +0000
parents 4d3bb026cd16
children eacc5bc01d1c
comparison
equal deleted inserted replaced
1652:dc219ba4cf45 1736:3b2a92126f4d
443 /* Show the image on the screen */ 443 /* Show the image on the screen */
444 SDL_UpdateRects(screen, 1, &dst); 444 SDL_UpdateRects(screen, 1, &dst);
445 } 445 }
446 446
447 int RunGLTest( int argc, char* argv[], 447 int RunGLTest( int argc, char* argv[],
448 int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa ) 448 int logo, int logocursor, int slowly, int bpp, float gamma, int noframe, int fsaa, int sync )
449 { 449 {
450 int i; 450 int i;
451 int rgb_size[3]; 451 int rgb_size[3];
452 int w = 640; 452 int w = 640;
453 int h = 480; 453 int h = 480;
529 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 529 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
530 if ( fsaa ) { 530 if ( fsaa ) {
531 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); 531 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 );
532 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa ); 532 SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa );
533 } 533 }
534 if ( sync ) {
535 SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 );
536 } else {
537 SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 0 );
538 }
534 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) { 539 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
535 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); 540 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
536 SDL_Quit(); 541 SDL_Quit();
537 exit(1); 542 exit(1);
538 } 543 }
555 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value ); 560 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
556 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ); 561 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
557 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value ); 562 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
558 if ( fsaa ) { 563 if ( fsaa ) {
559 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value ); 564 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value );
560 printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value ); 565 printf("SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value );
561 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ); 566 SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value );
562 printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value ); 567 printf("SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value );
568 }
569 if ( sync ) {
570 SDL_GL_GetAttribute( SDL_GL_SWAP_CONTROL, &value );
571 printf( "SDL_GL_SWAP_CONTROL: requested 1, got %d\n", value );
563 } 572 }
564 573
565 /* Set the window manager title bar */ 574 /* Set the window manager title bar */
566 SDL_WM_SetCaption( "SDL GL test", "testgl" ); 575 SDL_WM_SetCaption( "SDL GL test", "testgl" );
567 576
768 int bpp = 0; 777 int bpp = 0;
769 int slowly; 778 int slowly;
770 float gamma = 0.0; 779 float gamma = 0.0;
771 int noframe = 0; 780 int noframe = 0;
772 int fsaa = 0; 781 int fsaa = 0;
782 int sync = 0;
773 783
774 logo = 0; 784 logo = 0;
775 slowly = 0; 785 slowly = 0;
776 numtests = 1; 786 numtests = 1;
777 for ( i=1; argv[i]; ++i ) { 787 for ( i=1; argv[i]; ++i ) {
802 noframe = 1; 812 noframe = 1;
803 } 813 }
804 if ( strcmp(argv[i], "-fsaa") == 0 ) { 814 if ( strcmp(argv[i], "-fsaa") == 0 ) {
805 ++fsaa; 815 ++fsaa;
806 } 816 }
817 if ( strcmp(argv[i], "-sync") == 0 ) {
818 ++sync;
819 }
807 if ( strncmp(argv[i], "-h", 2) == 0 ) { 820 if ( strncmp(argv[i], "-h", 2) == 0 ) {
808 printf( 821 printf(
809 "Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n", 822 "Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n",
810 argv[0]); 823 argv[0]);
811 exit(0); 824 exit(0);
812 } 825 }
813 } 826 }
814 for ( i=0; i<numtests; ++i ) { 827 for ( i=0; i<numtests; ++i ) {
815 RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa); 828 RunGLTest(argc, argv, logo, logocursor, slowly, bpp, gamma, noframe, fsaa, sync);
816 } 829 }
817 return 0; 830 return 0;
818 } 831 }
819 832
820 #else /* HAVE_OPENGL */ 833 #else /* HAVE_OPENGL */