From 9316bc9d427c6174b0018b34ecec8a8b08dcc327 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 22 Jul 2003 15:33:28 +0000 Subject: [PATCH] Merged in Ryan's multisample code for MacOS, and changed the constants to match. --- WhatsNew | 2 +- include/SDL_video.h | 4 ++-- src/video/SDL_sysvideo.h | 4 ++-- src/video/SDL_video.c | 12 ++++++------ src/video/maccommon/SDL_macgl.c | 8 ++++++++ src/video/quartz/SDL_QuartzVideo.h | 2 ++ src/video/quartz/SDL_QuartzVideo.m | 12 ++++++++++++ src/video/wincommon/SDL_wingl.c | 12 ++++++------ src/video/x11/SDL_x11gl.c | 12 ++++++------ test/testgl.c | 12 ++++++------ 10 files changed, 51 insertions(+), 29 deletions(-) diff --git a/WhatsNew b/WhatsNew index 25d63c41c..6caef02c1 100644 --- a/WhatsNew +++ b/WhatsNew @@ -6,7 +6,7 @@ Version 1.0: 1.2.6: Added SDL_LoadObject(), SDL_LoadFunction(), and SDL_UnloadObject() - Added SDL_GL_SAMPLE_BUFFERS and SDL_GL_SAMPLES for FSAA support + Added SDL_GL_MULTISAMPLEBUFFERS and SDL_GL_MULTISAMPLESAMPLES for FSAA 1.2.5: Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5) diff --git a/include/SDL_video.h b/include/SDL_video.h index 642dabdc0..95686dc20 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -218,8 +218,8 @@ typedef enum { SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_STEREO, - SDL_GL_SAMPLE_BUFFERS, - SDL_GL_SAMPLES + SDL_GL_MULTISAMPLEBUFFERS, + SDL_GL_MULTISAMPLESAMPLES } SDL_GLattr; /* flags for SDL_SetPalette() */ diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index ea00f8971..98c60d952 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -304,8 +304,8 @@ struct SDL_VideoDevice { int accum_blue_size; int accum_alpha_size; int stereo; - int sample_buffers; - int samples; + int multisamplebuffers; + int multisamplesamples; int driver_loaded; char driver_path[256]; void* dll_handle; diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 9bee7a787..1cb9a0208 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -233,8 +233,8 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) video->gl_config.accum_blue_size = 0; video->gl_config.accum_alpha_size = 0; video->gl_config.stereo = 0; - video->gl_config.sample_buffers = 0; - video->gl_config.samples = 0; + video->gl_config.multisamplebuffers = 0; + video->gl_config.multisamplesamples = 0; /* Initialize the video subsystem */ memset(&vformat, 0, sizeof(vformat)); @@ -1422,11 +1422,11 @@ int SDL_GL_SetAttribute( SDL_GLattr attr, int value ) case SDL_GL_STEREO: video->gl_config.stereo = value; break; - case SDL_GL_SAMPLE_BUFFERS: - video->gl_config.sample_buffers = value; + case SDL_GL_MULTISAMPLEBUFFERS: + video->gl_config.multisamplebuffers = value; break; - case SDL_GL_SAMPLES: - video->gl_config.samples = value; + case SDL_GL_MULTISAMPLESAMPLES: + video->gl_config.multisamplesamples = value; break; default: SDL_SetError("Unknown OpenGL attribute"); diff --git a/src/video/maccommon/SDL_macgl.c b/src/video/maccommon/SDL_macgl.c index ac59a906f..5deaf6455 100644 --- a/src/video/maccommon/SDL_macgl.c +++ b/src/video/maccommon/SDL_macgl.c @@ -49,6 +49,14 @@ int Mac_GL_Init(_THIS) if ( this->gl_config.stereo ) { attributes[i++] = AGL_STEREO; } + if ( this->gl_config.multisamplebuffers != 0 ) { + attributes[i++] = AGL_SAMPLE_BUFFERS_ARB; + attributes[i++] = this->gl_config.multisamplebuffers; + } + if ( this->gl_config.multisamplesamples != 0 ) { + attributes[i++] = AGL_SAMPLES_ARB; + attributes[i++] = this->gl_config.multisamplesamples; + } if ( this->gl_config.depth_size != 0 ) { attributes[i++] = AGL_DEPTH_SIZE; attributes[i++] = this->gl_config.depth_size; diff --git a/src/video/quartz/SDL_QuartzVideo.h b/src/video/quartz/SDL_QuartzVideo.h index a53515b41..4d9a106cc 100644 --- a/src/video/quartz/SDL_QuartzVideo.h +++ b/src/video/quartz/SDL_QuartzVideo.h @@ -50,6 +50,8 @@ #include #include +#include +#include #include #include #include /* For powersave handling */ diff --git a/src/video/quartz/SDL_QuartzVideo.m b/src/video/quartz/SDL_QuartzVideo.m index af75e6cb2..9f6654432 100644 --- a/src/video/quartz/SDL_QuartzVideo.m +++ b/src/video/quartz/SDL_QuartzVideo.m @@ -1419,6 +1419,16 @@ static int QZ_SetupOpenGL (_THIS, int bpp, Uint32 flags) { attr[i++] = this->gl_config.stencil_size; } + if ( this->gl_config.multisamplebuffers != 0 ) { + attr[i++] = NSOpenGLPFASampleBuffers; + attr[i++] = this->gl_config.multisamplebuffers; + } + + if ( this->gl_config.multisamplesamples != 0 ) { + attr[i++] = NSOpenGLPFASamples; + attr[i++] = this->gl_config.multisamplesamples; + } + attr[i++] = NSOpenGLPFAScreenMask; attr[i++] = CGDisplayIDToOpenGLDisplayMask (display_id); attr[i] = 0; @@ -1503,6 +1513,8 @@ static int QZ_GL_GetAttribute (_THIS, SDL_GLattr attrib, int* value) { case SDL_GL_ACCUM_BLUE_SIZE: attr = GL_ACCUM_BLUE_BITS; break; case SDL_GL_ACCUM_ALPHA_SIZE: attr = GL_ACCUM_ALPHA_BITS; break; case SDL_GL_STEREO: attr = GL_STEREO; break; + case SDL_GL_MULTISAMPLEBUFFERS: attr = GL_SAMPLE_BUFFERS_ARB; break; + case SDL_GL_MULTISAMPLESAMPLES: attr = GL_SAMPLES_ARB; break; case SDL_GL_BUFFER_SIZE: { GLint bits = 0; diff --git a/src/video/wincommon/SDL_wingl.c b/src/video/wincommon/SDL_wingl.c index 134365333..a09445487 100644 --- a/src/video/wincommon/SDL_wingl.c +++ b/src/video/wincommon/SDL_wingl.c @@ -237,14 +237,14 @@ int WIN_GL_SetupWindow(_THIS) *iAttr++ = this->gl_config.stereo; } - if ( this->gl_config.sample_buffers ) { + if ( this->gl_config.multisamplebuffers ) { *iAttr++ = WGL_SAMPLE_BUFFERS_ARB; - *iAttr++ = this->gl_config.sample_buffers; + *iAttr++ = this->gl_config.multisamplebuffers; } - if ( this->gl_config.samples ) { + if ( this->gl_config.multisamplesamples ) { *iAttr++ = WGL_SAMPLES_ARB; - *iAttr++ = this->gl_config.samples; + *iAttr++ = this->gl_config.multisamplesamples; } *iAttr = 0; @@ -375,10 +375,10 @@ int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) case SDL_GL_STEREO: wgl_attrib = WGL_STEREO_ARB; break; - case SDL_GL_SAMPLE_BUFFERS: + case SDL_GL_MULTISAMPLEBUFFERS: wgl_attrib = WGL_SAMPLE_BUFFERS_ARB; break; - case SDL_GL_SAMPLES: + case SDL_GL_MULTISAMPLESAMPLES: wgl_attrib = WGL_SAMPLES_ARB; break; default: diff --git a/src/video/x11/SDL_x11gl.c b/src/video/x11/SDL_x11gl.c index 2c5372cd1..3ae992f68 100644 --- a/src/video/x11/SDL_x11gl.c +++ b/src/video/x11/SDL_x11gl.c @@ -123,14 +123,14 @@ XVisualInfo *X11_GL_GetVisual(_THIS) attribs[i++] = this->gl_config.stereo; } - if( this->gl_config.sample_buffers ) { + if( this->gl_config.multisamplebuffers ) { attribs[i++] = GLX_SAMPLE_BUFFERS_ARB; - attribs[i++] = this->gl_config.sample_buffers; + attribs[i++] = this->gl_config.multisamplebuffers; } - if( this->gl_config.samples ) { + if( this->gl_config.multisamplesamples ) { attribs[i++] = GLX_SAMPLES_ARB; - attribs[i++] = this->gl_config.samples; + attribs[i++] = this->gl_config.multisamplesamples; } #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ @@ -362,10 +362,10 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) case SDL_GL_STEREO: glx_attrib = GLX_STEREO; break; - case SDL_GL_SAMPLE_BUFFERS: + case SDL_GL_MULTISAMPLEBUFFERS: glx_attrib = GLX_SAMPLE_BUFFERS_ARB; break; - case SDL_GL_SAMPLES: + case SDL_GL_MULTISAMPLESAMPLES: glx_attrib = GLX_SAMPLES_ARB; break; default: diff --git a/test/testgl.c b/test/testgl.c index 0e9c64043..1a03afb5f 100644 --- a/test/testgl.c +++ b/test/testgl.c @@ -476,8 +476,8 @@ int RunGLTest( int argc, char* argv[], SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); if ( fsaa ) { - SDL_GL_SetAttribute( SDL_GL_SAMPLE_BUFFERS, 1 ); - SDL_GL_SetAttribute( SDL_GL_SAMPLES, fsaa ); + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, 1 ); + SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, fsaa ); } if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) { fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); @@ -504,10 +504,10 @@ int RunGLTest( int argc, char* argv[], SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ); printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value ); if ( fsaa ) { - SDL_GL_GetAttribute( SDL_GL_SAMPLE_BUFFERS, &value ); - printf( "SDL_GL_SAMPLE_BUFFERS: requested 1, got %d\n", value ); - SDL_GL_GetAttribute( SDL_GL_SAMPLES, &value ); - printf( "SDL_GL_SAMPLES: requested %d, got %d\n", fsaa, value ); + SDL_GL_GetAttribute( SDL_GL_MULTISAMPLEBUFFERS, &value ); + printf( "SDL_GL_MULTISAMPLEBUFFERS: requested 1, got %d\n", value ); + SDL_GL_GetAttribute( SDL_GL_MULTISAMPLESAMPLES, &value ); + printf( "SDL_GL_MULTISAMPLESAMPLES: requested %d, got %d\n", fsaa, value ); } /* Set the window manager title bar */