added multisampling (anti-aliasing) support to wxGLCanvas (#9145)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54022 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-06-08 00:12:12 +00:00
parent abbcf16d06
commit c39d2e0a38
10 changed files with 445 additions and 11 deletions

View File

@@ -122,6 +122,26 @@ wxGLCanvasX11::~wxGLCanvasX11()
// working with GL attributes
// ----------------------------------------------------------------------------
/* static */
bool wxGLCanvasBase::IsExtensionSupported(const char *extension)
{
Display * const dpy = wxGetX11Display();
return IsExtensionInList(glXQueryExtensionsString(dpy, DefaultScreen(dpy)),
extension);
}
/* static */
bool wxGLCanvasX11::IsGLXMultiSampleAvailable()
{
static int s_isMultiSampleAvailable = -1;
if ( s_isMultiSampleAvailable == -1 )
s_isMultiSampleAvailable = IsExtensionSupported("GLX_ARB_multisample");
return s_isMultiSampleAvailable != 0;
}
bool
wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n)
{
@@ -257,6 +277,32 @@ wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n)
glattrs[p++] = GLX_ACCUM_ALPHA_SIZE;
break;
case WX_GL_SAMPLE_BUFFERS:
if ( !IsGLXMultiSampleAvailable() )
{
// if it was specified just to disable it, no problem
if ( !wxattrs[arg++] )
continue;
// otherwise indicate that it's not supported
return false;
}
glattrs[p++] = GLX_SAMPLE_BUFFERS_ARB;
break;
case WX_GL_SAMPLES:
if ( !IsGLXMultiSampleAvailable() )
{
if ( !wxattrs[arg++] )
continue;
return false;
}
glattrs[p++] = GLX_SAMPLES_ARB;
break;
default:
wxLogDebug(_T("Unsupported OpenGL attribute %d"),
wxattrs[arg - 1]);