use GLX_DOUBLEBUFFER if no attributes were specified with GLX >= 1.3 too

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53380 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-04-27 13:01:14 +00:00
parent 4aa59c3df6
commit 06e6496e0f

View File

@@ -129,26 +129,26 @@ wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n)
if ( !wxattrs ) if ( !wxattrs )
{ {
if ( GetGLXVersion() >= 13 ) size_t i = 0;
{
// leave GLX >= 1.3 choose the default attributes // use double-buffered true colour by default
glattrs[0] = None; glattrs[i++] = GLX_RGBA; glattrs[i++] = True;
} glattrs[i++] = GLX_DOUBLEBUFFER; glattrs[i++] = True;
else // GLX < 1.3
if ( GetGLXVersion() < 13 )
{ {
// default settings if attriblist = 0 // default settings if attriblist = 0
size_t i = 0;
glattrs[i++] = GLX_RGBA;
glattrs[i++] = GLX_DOUBLEBUFFER;
glattrs[i++] = GLX_DEPTH_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_DEPTH_SIZE; glattrs[i++] = 1;
glattrs[i++] = GLX_RED_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_RED_SIZE; glattrs[i++] = 1;
glattrs[i++] = GLX_GREEN_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_GREEN_SIZE; glattrs[i++] = 1;
glattrs[i++] = GLX_BLUE_SIZE; glattrs[i++] = 1; glattrs[i++] = GLX_BLUE_SIZE; glattrs[i++] = 1;
glattrs[i++] = GLX_ALPHA_SIZE; glattrs[i++] = 0; glattrs[i++] = GLX_ALPHA_SIZE; glattrs[i++] = 0;
glattrs[i++] = None;
wxASSERT_MSG( i < n, _T("GL attributes buffer too small") );
} }
//else: recent GLX can choose the defaults on its own just fine
glattrs[i] = None;
wxASSERT_MSG( i < n, _T("GL attributes buffer too small") );
} }
else // have non-default attributes else // have non-default attributes
{ {
@@ -158,25 +158,11 @@ wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n)
// check if we have any space left, knowing that we may insert 2 // check if we have any space left, knowing that we may insert 2
// more elements during this loop iteration and we always need to // more elements during this loop iteration and we always need to
// terminate the list with None (hence -3) // terminate the list with None (hence -3)
if ( p >= n - 2 ) if ( p > n - 3 )
return false; return false;
switch ( wxattrs[arg++] ) switch ( wxattrs[arg++] )
{ {
case WX_GL_RGBA:
// for GLX >= 1.3, GLX_RGBA is useless and apparently
// harmful for some implementations
//
// FIXME: is this true?
if ( GetGLXVersion() <= 12 )
{
glattrs[p++] = GLX_RGBA;
}
// use "continue" to skip the assignment of the attribute
// value at the end of the loop
continue;
case WX_GL_BUFFER_SIZE: case WX_GL_BUFFER_SIZE:
glattrs[p++] = GLX_BUFFER_SIZE; glattrs[p++] = GLX_BUFFER_SIZE;
break; break;
@@ -190,6 +176,11 @@ wxGLCanvasX11::ConvertWXAttrsToGL(const int *wxattrs, int *glattrs, size_t n)
// OpenGL, so do put them into glattrs and also skip the // OpenGL, so do put them into glattrs and also skip the
// copy of wx value after switch by using "continue" // copy of wx value after switch by using "continue"
// instead of "break" // instead of "break"
case WX_GL_RGBA:
glattrs[p++] = GLX_RGBA;
glattrs[p++] = True;
continue;
case WX_GL_DOUBLEBUFFER: case WX_GL_DOUBLEBUFFER:
glattrs[p++] = GLX_DOUBLEBUFFER; glattrs[p++] = GLX_DOUBLEBUFFER;
glattrs[p++] = True; glattrs[p++] = True;