comparison test/testgl.c @ 655:9c42ee1b7d77

Date: Thu, 24 Apr 2003 15:13:47 -0400 From: Shawn Kirst Subject: SDL-1.2.5 patch to add ARB_multisample support Attached is a patch I have written for SDL-1.2.5 that adds ARB_multisample support. I only have the X11 and Win32 video patched. The Win32 patch also adds support for WGL_ARB_pixel_format, as it was required for getting a multisample capable pixel format. No additional GL header files are required to compile on either platform (though you need an up-to-date glx.h for X11). Requesting a multisample pixel format is made possible using SDL_GL_SetAttribute with the two new SDL_GLattr's I've added (SDL_GL_SAMPLE_BUFFERS and SDL_GL_SAMPLES). I've been using SDL in my projects for quite a while now, so I am happy to contribute back to the project. Now you can have and control FSAA in your SDL/GL apps at the application level!
author Sam Lantinga <slouken@libsdl.org>
date Tue, 22 Jul 2003 15:10:06 +0000
parents c59692dcdce0
children 864e2d2a9a55
comparison
equal deleted inserted replaced
654:e92bcf2573cb 655:9c42ee1b7d77
391 /* Show the image on the screen */ 391 /* Show the image on the screen */
392 SDL_UpdateRects(screen, 1, &dst); 392 SDL_UpdateRects(screen, 1, &dst);
393 } 393 }
394 394
395 int RunGLTest( int argc, char* argv[], 395 int RunGLTest( int argc, char* argv[],
396 int logo, int slowly, int bpp, float gamma, int noframe ) 396 int logo, int slowly, int bpp, float gamma, int noframe, int fsaa )
397 { 397 {
398 int i; 398 int i;
399 int rgb_size[3]; 399 int rgb_size[3];
400 int w = 640; 400 int w = 640;
401 int h = 480; 401 int h = 480;
473 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] ); 473 SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
474 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] ); 474 SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
475 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] ); 475 SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
476 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); 476 SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
477 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); 477 SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
478 if ( fsaa ) {
479 SDL_GL_SetAttribute( SDL_GL_SAMPLE_BUFFERS, 1 );
480 SDL_GL_SetAttribute( SDL_GL_SAMPLES, fsaa );
481 }
478 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) { 482 if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
479 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); 483 fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
480 SDL_Quit(); 484 SDL_Quit();
481 exit(1); 485 exit(1);
482 } 486 }
497 printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value); 501 printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
498 SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value ); 502 SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
499 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value ); 503 printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
500 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ); 504 SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
501 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value ); 505 printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
506 if ( fsaa ) {
507 SDL_GL_GetAttribute( SDL_GL_SAMPLE_BUFFERS, &value );
508 printf( "SDL_GL_SAMPLE_BUFFERS: requested 1, got %d\n", value );
509 SDL_GL_GetAttribute( SDL_GL_SAMPLES, &value );
510 printf( "SDL_GL_SAMPLES: requested %d, got %d\n", fsaa, value );
511 }
502 512
503 /* Set the window manager title bar */ 513 /* Set the window manager title bar */
504 SDL_WM_SetCaption( "SDL GL test", "testgl" ); 514 SDL_WM_SetCaption( "SDL GL test", "testgl" );
505 515
506 /* Set the gamma for the window */ 516 /* Set the gamma for the window */
698 int numtests; 708 int numtests;
699 int bpp = 0; 709 int bpp = 0;
700 int slowly; 710 int slowly;
701 float gamma = 0.0; 711 float gamma = 0.0;
702 int noframe = 0; 712 int noframe = 0;
713 int fsaa = 0;
703 714
704 logo = 0; 715 logo = 0;
705 slowly = 0; 716 slowly = 0;
706 numtests = 1; 717 numtests = 1;
707 for ( i=1; argv[i]; ++i ) { 718 for ( i=1; argv[i]; ++i ) {
726 gamma = (float)atof(argv[++i]); 737 gamma = (float)atof(argv[++i]);
727 } 738 }
728 if ( strcmp(argv[i], "-noframe") == 0 ) { 739 if ( strcmp(argv[i], "-noframe") == 0 ) {
729 noframe = 1; 740 noframe = 1;
730 } 741 }
742 if ( strcmp(argv[i], "-fsaa") == 0 ) {
743 ++fsaa;
744 }
731 if ( strncmp(argv[i], "-h", 2) == 0 ) { 745 if ( strncmp(argv[i], "-h", 2) == 0 ) {
732 printf( 746 printf(
733 "Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe]\n", 747 "Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa]\n",
734 argv[0]); 748 argv[0]);
735 exit(0); 749 exit(0);
736 } 750 }
737 } 751 }
738 for ( i=0; i<numtests; ++i ) { 752 for ( i=0; i<numtests; ++i ) {
739 RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe); 753 RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe, fsaa);
740 } 754 }
741 return 0; 755 return 0;
742 } 756 }
743 757
744 #else /* HAVE_OPENGL */ 758 #else /* HAVE_OPENGL */