Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11gl.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 | 0f2029a70548 |
children | 864e2d2a9a55 |
comparison
equal
deleted
inserted
replaced
654:e92bcf2573cb | 655:9c42ee1b7d77 |
---|---|
120 | 120 |
121 if( this->gl_config.stereo ) { | 121 if( this->gl_config.stereo ) { |
122 attribs[i++] = GLX_STEREO; | 122 attribs[i++] = GLX_STEREO; |
123 attribs[i++] = this->gl_config.stereo; | 123 attribs[i++] = this->gl_config.stereo; |
124 } | 124 } |
125 | |
126 if( this->gl_config.sample_buffers ) { | |
127 attribs[i++] = GLX_SAMPLE_BUFFERS_ARB; | |
128 attribs[i++] = this->gl_config.sample_buffers; | |
129 } | |
130 | |
131 if( this->gl_config.samples ) { | |
132 attribs[i++] = GLX_SAMPLES_ARB; | |
133 attribs[i++] = this->gl_config.samples; | |
134 } | |
125 | 135 |
126 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ | 136 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ |
127 attribs[i++] = GLX_X_VISUAL_TYPE; | 137 attribs[i++] = GLX_X_VISUAL_TYPE; |
128 attribs[i++] = GLX_DIRECT_COLOR; | 138 attribs[i++] = GLX_DIRECT_COLOR; |
129 #endif | 139 #endif |
227 #endif /* HAVE_OPENGL */ | 237 #endif /* HAVE_OPENGL */ |
228 } | 238 } |
229 | 239 |
230 #ifdef HAVE_OPENGL | 240 #ifdef HAVE_OPENGL |
231 | 241 |
232 static int ExtensionSupported(const char *extension, const char *all_extensions) | 242 static int ExtensionSupported(const char *extension) |
233 { | 243 { |
234 const GLubyte *extensions = NULL; | 244 const GLubyte *extensions = NULL; |
235 const GLubyte *start; | 245 const GLubyte *start; |
236 GLubyte *where, *terminator; | 246 GLubyte *where, *terminator; |
237 | 247 |
264 | 274 |
265 /* Make the current context active */ | 275 /* Make the current context active */ |
266 int X11_GL_MakeCurrent(_THIS) | 276 int X11_GL_MakeCurrent(_THIS) |
267 { | 277 { |
268 int retval; | 278 int retval; |
269 const char *glx_extensions; | |
270 | 279 |
271 retval = 0; | 280 retval = 0; |
272 if ( ! this->gl_data->glXMakeCurrent(GFX_Display, | 281 if ( ! this->gl_data->glXMakeCurrent(GFX_Display, |
273 SDL_Window, glx_context) ) { | 282 SDL_Window, glx_context) ) { |
274 SDL_SetError("Unable to make GL context current"); | 283 SDL_SetError("Unable to make GL context current"); |
275 retval = -1; | 284 retval = -1; |
276 } | 285 } |
277 XSync( GFX_Display, False ); | 286 XSync( GFX_Display, False ); |
278 | 287 |
279 | |
280 /* | 288 /* |
281 * The context is now current, check for glXReleaseBuffersMESA() | 289 * The context is now current, check for glXReleaseBuffersMESA() |
282 * extension. If extension is _not_ supported, destroy the pointer | 290 * extension. If extension is _not_ supported, destroy the pointer |
283 * (to make sure it will not be called in X11_GL_Shutdown() ). | 291 * (to make sure it will not be called in X11_GL_Shutdown() ). |
284 * | 292 * |
294 * driver doesn't support this extension. So blindly calling it will | 302 * driver doesn't support this extension. So blindly calling it will |
295 * cause segfault with DRI/Mesa drivers! | 303 * cause segfault with DRI/Mesa drivers! |
296 * | 304 * |
297 */ | 305 */ |
298 | 306 |
299 glx_extensions = this->gl_data->glXQueryExtensionsString(GFX_Display, SDL_Screen); | 307 if ( ! ExtensionSupported("glXReleaseBuffersMESA") ) { |
300 if (!ExtensionSupported("glXReleaseBuffersMESA", glx_extensions)) this->gl_data->glXReleaseBuffersMESA = NULL; | 308 this->gl_data->glXReleaseBuffersMESA = NULL; |
301 | 309 } |
302 | 310 |
303 /* More Voodoo X server workarounds... Grr... */ | 311 /* More Voodoo X server workarounds... Grr... */ |
304 SDL_Lock_EventThread(); | 312 SDL_Lock_EventThread(); |
305 X11_CheckDGAMouse(this); | 313 X11_CheckDGAMouse(this); |
306 SDL_Unlock_EventThread(); | 314 SDL_Unlock_EventThread(); |
307 | 315 |
352 glx_attrib = GLX_ACCUM_ALPHA_SIZE; | 360 glx_attrib = GLX_ACCUM_ALPHA_SIZE; |
353 break; | 361 break; |
354 case SDL_GL_STEREO: | 362 case SDL_GL_STEREO: |
355 glx_attrib = GLX_STEREO; | 363 glx_attrib = GLX_STEREO; |
356 break; | 364 break; |
365 case SDL_GL_SAMPLE_BUFFERS: | |
366 glx_attrib = GLX_SAMPLE_BUFFERS_ARB; | |
367 break; | |
368 case SDL_GL_SAMPLES: | |
369 glx_attrib = GLX_SAMPLES_ARB; | |
370 break; | |
357 default: | 371 default: |
358 return(-1); | 372 return(-1); |
359 } | 373 } |
360 | 374 |
361 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value); | 375 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value); |