Commit 800e2d5e authored by Sam Lantinga's avatar Sam Lantinga

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!

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%40656
parent 311d6a8f
...@@ -6,6 +6,8 @@ Version 1.0: ...@@ -6,6 +6,8 @@ Version 1.0:
1.2.6: 1.2.6:
Added SDL_LoadObject(), SDL_LoadFunction(), and SDL_UnloadObject() Added SDL_LoadObject(), SDL_LoadFunction(), and SDL_UnloadObject()
Added SDL_GL_SAMPLE_BUFFERS and SDL_GL_SAMPLES for FSAA support
1.2.5: 1.2.5:
Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5) Added SDL_BUTTON_WHEELUP (4) and SDL_BUTTON_WHEELDOWN (5)
......
...@@ -217,7 +217,9 @@ typedef enum { ...@@ -217,7 +217,9 @@ typedef enum {
SDL_GL_ACCUM_GREEN_SIZE, SDL_GL_ACCUM_GREEN_SIZE,
SDL_GL_ACCUM_BLUE_SIZE, SDL_GL_ACCUM_BLUE_SIZE,
SDL_GL_ACCUM_ALPHA_SIZE, SDL_GL_ACCUM_ALPHA_SIZE,
SDL_GL_STEREO SDL_GL_STEREO,
SDL_GL_SAMPLE_BUFFERS,
SDL_GL_SAMPLES
} SDL_GLattr; } SDL_GLattr;
/* flags for SDL_SetPalette() */ /* flags for SDL_SetPalette() */
......
...@@ -304,6 +304,8 @@ struct SDL_VideoDevice { ...@@ -304,6 +304,8 @@ struct SDL_VideoDevice {
int accum_blue_size; int accum_blue_size;
int accum_alpha_size; int accum_alpha_size;
int stereo; int stereo;
int sample_buffers;
int samples;
int driver_loaded; int driver_loaded;
char driver_path[256]; char driver_path[256];
void* dll_handle; void* dll_handle;
......
...@@ -233,6 +233,8 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) ...@@ -233,6 +233,8 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
video->gl_config.accum_blue_size = 0; video->gl_config.accum_blue_size = 0;
video->gl_config.accum_alpha_size = 0; video->gl_config.accum_alpha_size = 0;
video->gl_config.stereo = 0; video->gl_config.stereo = 0;
video->gl_config.sample_buffers = 0;
video->gl_config.samples = 0;
/* Initialize the video subsystem */ /* Initialize the video subsystem */
memset(&vformat, 0, sizeof(vformat)); memset(&vformat, 0, sizeof(vformat));
...@@ -1420,6 +1422,12 @@ int SDL_GL_SetAttribute( SDL_GLattr attr, int value ) ...@@ -1420,6 +1422,12 @@ int SDL_GL_SetAttribute( SDL_GLattr attr, int value )
case SDL_GL_STEREO: case SDL_GL_STEREO:
video->gl_config.stereo = value; video->gl_config.stereo = value;
break; break;
case SDL_GL_SAMPLE_BUFFERS:
video->gl_config.sample_buffers = value;
break;
case SDL_GL_SAMPLES:
video->gl_config.samples = value;
break;
default: default:
SDL_SetError("Unknown OpenGL attribute"); SDL_SetError("Unknown OpenGL attribute");
retval = -1; retval = -1;
......
...@@ -25,6 +25,8 @@ static char rcsid = ...@@ -25,6 +25,8 @@ static char rcsid =
"@(#) $Id$"; "@(#) $Id$";
#endif #endif
#include <string.h>
/* WGL implementation of SDL OpenGL support */ /* WGL implementation of SDL OpenGL support */
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
...@@ -77,12 +79,60 @@ static int WIN_GL_ResetWindow(_THIS) ...@@ -77,12 +79,60 @@ static int WIN_GL_ResetWindow(_THIS)
return(status); return(status);
} }
static int Init_WGL_ARB_extensions(_THIS)
{
HWND hwnd;
HDC hdc;
HGLRC hglrc;
int pformat;
const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0;
hwnd = CreateWindow(NULL, "PFormat", WS_POPUP | WS_DISABLED,
0, 0, 10, 10,
NULL, NULL, SDL_Instance,NULL);
hdc = GetDC(hwnd);
pformat = ChoosePixelFormat(hdc, &GL_pfd);
SetPixelFormat(hdc, pformat, &GL_pfd);
hglrc = this->gl_data->wglCreateContext(hdc);
this->gl_data->wglMakeCurrent(hdc, hglrc);
wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC))
this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB");
if(wglGetExtensionsStringARB && strstr(wglGetExtensionsStringARB(hdc),"WGL_ARB_pixel_format")) {
this->gl_data->wglChoosePixelFormatARB =
(BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *))
this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB");
this->gl_data->wglGetPixelFormatAttribivARB =
(BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *))
this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB");
if( (this->gl_data->wglChoosePixelFormatARB != NULL) &&
(this->gl_data->wglGetPixelFormatAttribivARB != NULL) )
this->gl_data->wgl_arb_pixel_format = 1;
else
this->gl_data->wgl_arb_pixel_format = 0;
} else {
this->gl_data->wgl_arb_pixel_format = 0;
}
this->gl_data->wglMakeCurrent(NULL, NULL);
this->gl_data->wglDeleteContext(hglrc);
ReleaseDC(hwnd, hdc);
DestroyWindow(hwnd);
}
int WIN_GL_SetupWindow(_THIS) int WIN_GL_SetupWindow(_THIS)
{ {
int retval; int retval;
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
int i; int i;
int pixel_format; unsigned int matching;
int iAttribs[64];
int *iAttr;
float fAttribs[1] = { 0 };
/* load the gl driver from a default path */ /* load the gl driver from a default path */
if ( ! this->gl_config.driver_loaded ) { if ( ! this->gl_config.driver_loaded ) {
...@@ -127,13 +177,90 @@ int WIN_GL_SetupWindow(_THIS) ...@@ -127,13 +177,90 @@ int WIN_GL_SetupWindow(_THIS)
GL_pfd.cDepthBits = this->gl_config.depth_size; GL_pfd.cDepthBits = this->gl_config.depth_size;
GL_pfd.cStencilBits = this->gl_config.stencil_size; GL_pfd.cStencilBits = this->gl_config.stencil_size;
/* initialize WGL_ARB_pixel_format */
Init_WGL_ARB_extensions(this);
/* setup WGL_ARB_pixel_format attribs */
iAttr = &iAttribs[0];
*iAttr++ = WGL_DRAW_TO_WINDOW_ARB;
*iAttr++ = GL_TRUE;
*iAttr++ = WGL_ACCELERATION_ARB;
*iAttr++ = WGL_FULL_ACCELERATION_ARB;
*iAttr++ = WGL_RED_BITS_ARB;
*iAttr++ = this->gl_config.red_size;
*iAttr++ = WGL_GREEN_BITS_ARB;
*iAttr++ = this->gl_config.green_size;
*iAttr++ = WGL_BLUE_BITS_ARB;
*iAttr++ = this->gl_config.blue_size;
if ( this->gl_config.alpha_size ) {
*iAttr++ = WGL_ALPHA_BITS_ARB;
*iAttr++ = this->gl_config.alpha_size;
}
if ( this->gl_config.double_buffer ) {
*iAttr ++ = WGL_DOUBLE_BUFFER_ARB;
*iAttr ++ = GL_TRUE;
}
*iAttr++ = WGL_DEPTH_BITS_ARB;
*iAttr++ = this->gl_config.depth_size;
if ( this->gl_config.stencil_size ) {
*iAttr++ = WGL_STENCIL_BITS_ARB;
*iAttr++ = this->gl_config.stencil_size;
}
if ( this->gl_config.accum_red_size ) {
*iAttr++ = WGL_ACCUM_RED_BITS_ARB;
*iAttr++ = this->gl_config.accum_red_size;
}
if ( this->gl_config.accum_green_size ) {
*iAttr++ = WGL_ACCUM_GREEN_BITS_ARB;
*iAttr++ = this->gl_config.accum_green_size;
}
if ( this->gl_config.accum_blue_size ) {
*iAttr++ = WGL_ACCUM_BLUE_BITS_ARB;
*iAttr++ = this->gl_config.accum_blue_size;
}
if ( this->gl_config.accum_alpha_size ) {
*iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB;
*iAttr++ = this->gl_config.accum_alpha_size;
}
if ( this->gl_config.stereo ) {
*iAttr++ = WGL_STEREO_ARB;
*iAttr++ = this->gl_config.stereo;
}
if ( this->gl_config.sample_buffers ) {
*iAttr++ = WGL_SAMPLE_BUFFERS_ARB;
*iAttr++ = this->gl_config.sample_buffers;
}
if ( this->gl_config.samples ) {
*iAttr++ = WGL_SAMPLES_ARB;
*iAttr++ = this->gl_config.samples;
}
*iAttr = 0;
/* Choose and set the closest available pixel format */ /* Choose and set the closest available pixel format */
if ( !this->gl_data->wgl_arb_pixel_format ||
!this->gl_data->wglChoosePixelFormatARB(GL_hdc, iAttribs, fAttribs, 1, &pixel_format, &matching) ||
!matching ) {
pixel_format = ChoosePixelFormat(GL_hdc, &GL_pfd); pixel_format = ChoosePixelFormat(GL_hdc, &GL_pfd);
this->gl_data->wgl_arb_pixel_format = 0;
}
if ( !pixel_format ) { if ( !pixel_format ) {
SDL_SetError("No matching GL pixel format available"); SDL_SetError("No matching GL pixel format available");
return(-1); return(-1);
} }
if( !SetPixelFormat(GL_hdc, pixel_format, &GL_pfd) ) { if ( !SetPixelFormat(GL_hdc, pixel_format, &GL_pfd) ) {
if ( i == 0 ) { if ( i == 0 ) {
/* First time through, try resetting the window */ /* First time through, try resetting the window */
if ( WIN_GL_ResetWindow(this) < 0 ) { if ( WIN_GL_ResetWindow(this) < 0 ) {
...@@ -150,7 +277,7 @@ int WIN_GL_SetupWindow(_THIS) ...@@ -150,7 +277,7 @@ int WIN_GL_SetupWindow(_THIS)
DescribePixelFormat(GL_hdc, pixel_format, sizeof(GL_pfd), &GL_pfd); DescribePixelFormat(GL_hdc, pixel_format, sizeof(GL_pfd), &GL_pfd);
GL_hrc = this->gl_data->wglCreateContext(GL_hdc); GL_hrc = this->gl_data->wglCreateContext(GL_hdc);
if( GL_hrc == NULL ) { if ( GL_hrc == NULL ) {
SDL_SetError("Unable to create GL context"); SDL_SetError("Unable to create GL context");
return(-1); return(-1);
} }
...@@ -205,8 +332,65 @@ int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) ...@@ -205,8 +332,65 @@ int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
{ {
int retval; int retval;
if ( this->gl_data->wgl_arb_pixel_format ) {
int wgl_attrib;
switch(attrib) {
case SDL_GL_RED_SIZE:
wgl_attrib = WGL_RED_BITS_ARB;
break;
case SDL_GL_GREEN_SIZE:
wgl_attrib = WGL_GREEN_BITS_ARB;
break;
case SDL_GL_BLUE_SIZE:
wgl_attrib = WGL_BLUE_BITS_ARB;
break;
case SDL_GL_ALPHA_SIZE:
wgl_attrib = WGL_ALPHA_BITS_ARB;
break;
case SDL_GL_DOUBLEBUFFER:
wgl_attrib = WGL_DOUBLE_BUFFER_ARB;
break;
case SDL_GL_BUFFER_SIZE:
wgl_attrib = WGL_COLOR_BITS_ARB;
break;
case SDL_GL_DEPTH_SIZE:
wgl_attrib = WGL_DEPTH_BITS_ARB;
break;
case SDL_GL_STENCIL_SIZE:
wgl_attrib = WGL_STENCIL_BITS_ARB;
break;
case SDL_GL_ACCUM_RED_SIZE:
wgl_attrib = WGL_ACCUM_RED_BITS_ARB;
break;
case SDL_GL_ACCUM_GREEN_SIZE:
wgl_attrib = WGL_ACCUM_GREEN_BITS_ARB;
break;
case SDL_GL_ACCUM_BLUE_SIZE:
wgl_attrib = WGL_ACCUM_BLUE_BITS_ARB;
break;
case SDL_GL_ACCUM_ALPHA_SIZE:
wgl_attrib = WGL_ACCUM_ALPHA_BITS_ARB;
break;
case SDL_GL_STEREO:
wgl_attrib = WGL_STEREO_ARB;
break;
case SDL_GL_SAMPLE_BUFFERS:
wgl_attrib = WGL_SAMPLE_BUFFERS_ARB;
break;
case SDL_GL_SAMPLES:
wgl_attrib = WGL_SAMPLES_ARB;
break;
default:
return(-1);
}
this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, 1, &wgl_attrib, value);
return 0;
}
retval = 0; retval = 0;
switch( attrib ) { switch ( attrib ) {
case SDL_GL_RED_SIZE: case SDL_GL_RED_SIZE:
*value = GL_pfd.cRedBits; *value = GL_pfd.cRedBits;
break; break;
...@@ -275,6 +459,8 @@ void WIN_GL_UnloadLibrary(_THIS) ...@@ -275,6 +459,8 @@ void WIN_GL_UnloadLibrary(_THIS)
this->gl_data->wglCreateContext = NULL; this->gl_data->wglCreateContext = NULL;
this->gl_data->wglDeleteContext = NULL; this->gl_data->wglDeleteContext = NULL;
this->gl_data->wglMakeCurrent = NULL; this->gl_data->wglMakeCurrent = NULL;
this->gl_data->wglChoosePixelFormatARB = NULL;
this->gl_data->wglGetPixelFormatAttribivARB = NULL;
this->gl_config.dll_handle = NULL; this->gl_config.dll_handle = NULL;
this->gl_config.driver_loaded = 0; this->gl_config.driver_loaded = 0;
...@@ -304,6 +490,7 @@ int WIN_GL_LoadLibrary(_THIS, const char* path) ...@@ -304,6 +490,7 @@ int WIN_GL_LoadLibrary(_THIS, const char* path)
WIN_GL_UnloadLibrary(this); WIN_GL_UnloadLibrary(this);
/* Load new function pointers */ /* Load new function pointers */
memset(this->gl_data, 0, sizeof(*this->gl_data));
this->gl_data->wglGetProcAddress = (void * (WINAPI *)(const char *)) this->gl_data->wglGetProcAddress = (void * (WINAPI *)(const char *))
GetProcAddress(handle, "wglGetProcAddress"); GetProcAddress(handle, "wglGetProcAddress");
this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC))
......
...@@ -37,6 +37,8 @@ struct SDL_PrivateGLData { ...@@ -37,6 +37,8 @@ struct SDL_PrivateGLData {
PIXELFORMATDESCRIPTOR GL_pfd; PIXELFORMATDESCRIPTOR GL_pfd;
HDC GL_hdc; HDC GL_hdc;
HGLRC GL_hrc; HGLRC GL_hrc;
int pixel_format;
int wgl_arb_pixel_format;
void * (WINAPI *wglGetProcAddress)(const char *proc); void * (WINAPI *wglGetProcAddress)(const char *proc);
...@@ -46,6 +48,15 @@ struct SDL_PrivateGLData { ...@@ -46,6 +48,15 @@ struct SDL_PrivateGLData {
BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc); BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc);
BOOL (WINAPI *wglChoosePixelFormatARB)(HDC hdc, const int *piAttribIList,
const FLOAT *pfAttribFList,
UINT nMaxFormats, int *piFormats,
UINT *nNumFormats);
BOOL (WINAPI *wglGetPixelFormatAttribivARB)(HDC hdc, int iPixelFormat,
int iLayerPlane,
UINT nAttributes,
const int *piAttributes,
int *piValues);
#endif /* HAVE_OPENGL */ #endif /* HAVE_OPENGL */
}; };
...@@ -54,6 +65,7 @@ struct SDL_PrivateGLData { ...@@ -54,6 +65,7 @@ struct SDL_PrivateGLData {
#define GL_pfd (this->gl_data->GL_pfd) #define GL_pfd (this->gl_data->GL_pfd)
#define GL_hdc (this->gl_data->GL_hdc) #define GL_hdc (this->gl_data->GL_hdc)
#define GL_hrc (this->gl_data->GL_hrc) #define GL_hrc (this->gl_data->GL_hrc)
#define pixel_format (this->gl_data->pixel_format)
/* OpenGL functions */ /* OpenGL functions */
extern int WIN_GL_SetupWindow(_THIS); extern int WIN_GL_SetupWindow(_THIS);
...@@ -67,3 +79,63 @@ extern int WIN_GL_LoadLibrary(_THIS, const char* path); ...@@ -67,3 +79,63 @@ extern int WIN_GL_LoadLibrary(_THIS, const char* path);
extern void *WIN_GL_GetProcAddress(_THIS, const char* proc); extern void *WIN_GL_GetProcAddress(_THIS, const char* proc);
#endif #endif
#ifdef HAVE_OPENGL
#ifndef WGL_ARB_pixel_format
#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_DRAW_TO_BITMAP_ARB 0x2002
#define WGL_ACCELERATION_ARB 0x2003
#define WGL_NEED_PALETTE_ARB 0x2004
#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005
#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006
#define WGL_SWAP_METHOD_ARB 0x2007
#define WGL_NUMBER_OVERLAYS_ARB 0x2008
#define WGL_NUMBER_UNDERLAYS_ARB 0x2009
#define WGL_TRANSPARENT_ARB 0x200A
#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037
#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038
#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039
#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A
#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B
#define WGL_SHARE_DEPTH_ARB 0x200C
#define WGL_SHARE_STENCIL_ARB 0x200D
#define WGL_SHARE_ACCUM_ARB 0x200E
#define WGL_SUPPORT_GDI_ARB 0x200F
#define WGL_SUPPORT_OPENGL_ARB 0x2010
#define WGL_DOUBLE_BUFFER_ARB 0x2011
#define WGL_STEREO_ARB 0x2012
#define WGL_PIXEL_TYPE_ARB 0x2013
#define WGL_COLOR_BITS_ARB 0x2014
#define WGL_RED_BITS_ARB 0x2015
#define WGL_RED_SHIFT_ARB 0x2016
#define WGL_GREEN_BITS_ARB 0x2017
#define WGL_GREEN_SHIFT_ARB 0x2018
#define WGL_BLUE_BITS_ARB 0x2019
#define WGL_BLUE_SHIFT_ARB 0x201A
#define WGL_ALPHA_BITS_ARB 0x201B
#define WGL_ALPHA_SHIFT_ARB 0x201C
#define WGL_ACCUM_BITS_ARB 0x201D
#define WGL_ACCUM_RED_BITS_ARB 0x201E
#define WGL_ACCUM_GREEN_BITS_ARB 0x201F
#define WGL_ACCUM_BLUE_BITS_ARB 0x2020
#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021
#define WGL_DEPTH_BITS_ARB 0x2022
#define WGL_STENCIL_BITS_ARB 0x2023
#define WGL_AUX_BUFFERS_ARB 0x2024
#define WGL_NO_ACCELERATION_ARB 0x2025
#define WGL_GENERIC_ACCELERATION_ARB 0x2026
#define WGL_FULL_ACCELERATION_ARB 0x2027
#define WGL_SWAP_EXCHANGE_ARB 0x2028
#define WGL_SWAP_COPY_ARB 0x2029
#define WGL_SWAP_UNDEFINED_ARB 0x202A
#define WGL_TYPE_RGBA_ARB 0x202B
#define WGL_TYPE_COLORINDEX_ARB 0x202C
#endif
#ifndef WGL_ARB_multisample
#define WGL_SAMPLE_BUFFERS_ARB 0x2041
#define WGL_SAMPLES_ARB 0x2042
#endif
#endif
...@@ -123,6 +123,16 @@ XVisualInfo *X11_GL_GetVisual(_THIS) ...@@ -123,6 +123,16 @@ XVisualInfo *X11_GL_GetVisual(_THIS)
attribs[i++] = this->gl_config.stereo; attribs[i++] = this->gl_config.stereo;
} }
if( this->gl_config.sample_buffers ) {
attribs[i++] = GLX_SAMPLE_BUFFERS_ARB;
attribs[i++] = this->gl_config.sample_buffers;
}
if( this->gl_config.samples ) {
attribs[i++] = GLX_SAMPLES_ARB;
attribs[i++] = this->gl_config.samples;
}
#ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */
attribs[i++] = GLX_X_VISUAL_TYPE; attribs[i++] = GLX_X_VISUAL_TYPE;
attribs[i++] = GLX_DIRECT_COLOR; attribs[i++] = GLX_DIRECT_COLOR;
...@@ -229,7 +239,7 @@ void X11_GL_Shutdown(_THIS) ...@@ -229,7 +239,7 @@ void X11_GL_Shutdown(_THIS)
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
static int ExtensionSupported(const char *extension, const char *all_extensions) static int ExtensionSupported(const char *extension)
{ {
const GLubyte *extensions = NULL; const GLubyte *extensions = NULL;
const GLubyte *start; const GLubyte *start;
...@@ -266,7 +276,6 @@ static int ExtensionSupported(const char *extension, const char *all_extensions) ...@@ -266,7 +276,6 @@ static int ExtensionSupported(const char *extension, const char *all_extensions)
int X11_GL_MakeCurrent(_THIS) int X11_GL_MakeCurrent(_THIS)
{ {
int retval; int retval;
const char *glx_extensions;
retval = 0; retval = 0;
if ( ! this->gl_data->glXMakeCurrent(GFX_Display, if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
...@@ -276,7 +285,6 @@ int X11_GL_MakeCurrent(_THIS) ...@@ -276,7 +285,6 @@ int X11_GL_MakeCurrent(_THIS)
} }
XSync( GFX_Display, False ); XSync( GFX_Display, False );
/* /*
* The context is now current, check for glXReleaseBuffersMESA() * The context is now current, check for glXReleaseBuffersMESA()
* extension. If extension is _not_ supported, destroy the pointer * extension. If extension is _not_ supported, destroy the pointer
...@@ -296,9 +304,9 @@ int X11_GL_MakeCurrent(_THIS) ...@@ -296,9 +304,9 @@ int X11_GL_MakeCurrent(_THIS)
* *
*/ */
glx_extensions = this->gl_data->glXQueryExtensionsString(GFX_Display, SDL_Screen); if ( ! ExtensionSupported("glXReleaseBuffersMESA") ) {
if (!ExtensionSupported("glXReleaseBuffersMESA", glx_extensions)) this->gl_data->glXReleaseBuffersMESA = NULL; this->gl_data->glXReleaseBuffersMESA = NULL;
}
/* More Voodoo X server workarounds... Grr... */ /* More Voodoo X server workarounds... Grr... */
SDL_Lock_EventThread(); SDL_Lock_EventThread();
...@@ -354,6 +362,12 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) ...@@ -354,6 +362,12 @@ int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
case SDL_GL_STEREO: case SDL_GL_STEREO:
glx_attrib = GLX_STEREO; glx_attrib = GLX_STEREO;
break; break;
case SDL_GL_SAMPLE_BUFFERS:
glx_attrib = GLX_SAMPLE_BUFFERS_ARB;
break;
case SDL_GL_SAMPLES:
glx_attrib = GLX_SAMPLES_ARB;
break;
default: default:
return(-1); return(-1);
} }
......
...@@ -393,7 +393,7 @@ void DrawLogoBlit(void) ...@@ -393,7 +393,7 @@ void DrawLogoBlit(void)
} }
int RunGLTest( int argc, char* argv[], int RunGLTest( int argc, char* argv[],
int logo, int slowly, int bpp, float gamma, int noframe ) int logo, int slowly, int bpp, float gamma, int noframe, int fsaa )
{ {
int i; int i;
int rgb_size[3]; int rgb_size[3];
...@@ -475,6 +475,10 @@ int RunGLTest( int argc, char* argv[], ...@@ -475,6 +475,10 @@ int RunGLTest( int argc, char* argv[],
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] ); SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 ); SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 ); SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
if ( fsaa ) {
SDL_GL_SetAttribute( SDL_GL_SAMPLE_BUFFERS, 1 );
SDL_GL_SetAttribute( SDL_GL_SAMPLES, fsaa );
}
if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) { if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError()); fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
SDL_Quit(); SDL_Quit();
...@@ -499,6 +503,12 @@ int RunGLTest( int argc, char* argv[], ...@@ -499,6 +503,12 @@ int RunGLTest( int argc, char* argv[],
printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value ); printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value ); SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", 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 );
}
/* Set the window manager title bar */ /* Set the window manager title bar */
SDL_WM_SetCaption( "SDL GL test", "testgl" ); SDL_WM_SetCaption( "SDL GL test", "testgl" );
...@@ -700,6 +710,7 @@ int main(int argc, char *argv[]) ...@@ -700,6 +710,7 @@ int main(int argc, char *argv[])
int slowly; int slowly;
float gamma = 0.0; float gamma = 0.0;
int noframe = 0; int noframe = 0;
int fsaa = 0;
logo = 0; logo = 0;
slowly = 0; slowly = 0;
...@@ -728,15 +739,18 @@ int main(int argc, char *argv[]) ...@@ -728,15 +739,18 @@ int main(int argc, char *argv[])
if ( strcmp(argv[i], "-noframe") == 0 ) { if ( strcmp(argv[i], "-noframe") == 0 ) {
noframe = 1; noframe = 1;
} }
if ( strcmp(argv[i], "-fsaa") == 0 ) {
++fsaa;
}
if ( strncmp(argv[i], "-h", 2) == 0 ) { if ( strncmp(argv[i], "-h", 2) == 0 ) {
printf( printf(
"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe]\n", "Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa]\n",
argv[0]); argv[0]);
exit(0); exit(0);
} }
} }
for ( i=0; i<numtests; ++i ) { for ( i=0; i<numtests; ++i ) {
RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe); RunGLTest(argc, argv, logo, slowly, bpp, gamma, noframe, fsaa);
} }
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment