Request hardware accelerated GL under OS X only if it's available.
Otherwise wxGLCanvas creation just fails completely when it isn't, e.g. when running inside a VM. Closes #16555. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77701 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -81,28 +81,48 @@ void WXGLDestroyPixelFormat( WXGLPixelFormat pixelFormat )
|
|||||||
WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
|
WXGLPixelFormat WXGLChoosePixelFormat(const int *attribList)
|
||||||
{
|
{
|
||||||
NSOpenGLPixelFormatAttribute data[512];
|
NSOpenGLPixelFormatAttribute data[512];
|
||||||
const NSOpenGLPixelFormatAttribute defaultAttribs[] =
|
|
||||||
|
unsigned p = 0;
|
||||||
|
data[p++] = NSOpenGLPFAMinimumPolicy; // make _SIZE tags behave more like GLX
|
||||||
|
|
||||||
|
// Test if we support hardware acceleration, we always want to use it if it
|
||||||
|
// is available and, apparently, in spite of the Apple docs explicitly
|
||||||
|
// saying the contrary:
|
||||||
|
//
|
||||||
|
// If present, this attribute indicates that only hardware-accelerated
|
||||||
|
// renderers are considered. If not present, accelerated renderers are
|
||||||
|
// still preferred.
|
||||||
|
//
|
||||||
|
// hardware acceleration is not always used without it, so we do need to
|
||||||
|
// specify it. But we shouldn't do it if acceleration is really not
|
||||||
|
// available.
|
||||||
|
const NSOpenGLPixelFormatAttribute
|
||||||
|
attrsAccel[] = { NSOpenGLPFAAccelerated, 0 };
|
||||||
|
WXGLPixelFormat testFormat = [NSOpenGLPixelFormat alloc];
|
||||||
|
if ( [testFormat initWithAttributes: attrsAccel] )
|
||||||
{
|
{
|
||||||
NSOpenGLPFADoubleBuffer,
|
// Hardware acceleration is available, use it.
|
||||||
NSOpenGLPFAMinimumPolicy,
|
data[p++] = NSOpenGLPFAAccelerated;
|
||||||
NSOpenGLPFAColorSize,(NSOpenGLPixelFormatAttribute)8,
|
}
|
||||||
NSOpenGLPFAAlphaSize,(NSOpenGLPixelFormatAttribute)0,
|
|
||||||
NSOpenGLPFADepthSize,(NSOpenGLPixelFormatAttribute)8,
|
[testFormat release];
|
||||||
NSOpenGLPFAAccelerated, // use hardware accelerated context
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
const NSOpenGLPixelFormatAttribute *attribs;
|
const NSOpenGLPixelFormatAttribute *attribs;
|
||||||
if ( !attribList )
|
if ( !attribList )
|
||||||
{
|
{
|
||||||
attribs = defaultAttribs;
|
// Default attributes
|
||||||
|
data[p++] = NSOpenGLPFADoubleBuffer;
|
||||||
|
data[p++] = NSOpenGLPFAColorSize;
|
||||||
|
data[p++] = (NSOpenGLPixelFormatAttribute)8;
|
||||||
|
data[p++] = NSOpenGLPFAAlphaSize;
|
||||||
|
data[p++] = (NSOpenGLPixelFormatAttribute)0;
|
||||||
|
data[p++] = NSOpenGLPFADepthSize;
|
||||||
|
data[p++] = (NSOpenGLPixelFormatAttribute)8;
|
||||||
|
data[p] = 0;
|
||||||
|
attribs = data;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
unsigned p = 0;
|
|
||||||
data[p++] = NSOpenGLPFAMinimumPolicy; // make _SIZE tags behave more like GLX
|
|
||||||
data[p++] = NSOpenGLPFAAccelerated; // use hardware accelerated context
|
|
||||||
|
|
||||||
for ( unsigned arg = 0; attribList[arg] !=0 && p < WXSIZEOF(data); )
|
for ( unsigned arg = 0; attribList[arg] !=0 && p < WXSIZEOF(data); )
|
||||||
{
|
{
|
||||||
switch ( attribList[arg++] )
|
switch ( attribList[arg++] )
|
||||||
|
Reference in New Issue
Block a user