Cocoa Port:

- Fall back to using a legacy OpenGL context if the GPU driver rejects initializing a 3.2 Core Profile context.
This commit is contained in:
rogerman 2015-03-15 06:46:49 +00:00
parent d59ead2b51
commit 0ac489ade1
2 changed files with 23 additions and 4 deletions

View File

@ -405,6 +405,8 @@ public:
virtual void SetViewportSizeOGL(GLsizei w, GLsizei h); virtual void SetViewportSizeOGL(GLsizei w, GLsizei h);
}; };
OGLInfo* OGLInfoCreate_Legacy();
extern OGLInfo* (*OGLInfoCreate_Func)(); extern OGLInfo* (*OGLInfoCreate_Func)();
extern void (*glBindVertexArrayDESMUME)(GLuint id); extern void (*glBindVertexArrayDESMUME)(GLuint id);
extern void (*glDeleteVertexArraysDESMUME)(GLsizei n, const GLuint *ids); extern void (*glDeleteVertexArraysDESMUME)(GLsizei n, const GLuint *ids);

View File

@ -1316,19 +1316,36 @@ static std::unordered_map<NSScreen *, DisplayWindowController *> _screenMap; //
(NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0, (NSOpenGLPixelFormatAttribute)0,
(NSOpenGLPixelFormatAttribute)0 }; (NSOpenGLPixelFormatAttribute)0 };
NSOpenGLPixelFormat *format = nil;
#ifdef _OGLDISPLAYOUTPUT_3_2_H_ #ifdef _OGLDISPLAYOUTPUT_3_2_H_
// If we can support a 3.2 Core Profile context, then request that in our // If we can support a 3.2 Core Profile context, then request that in our
// pixel format attributes. // pixel format attributes.
if (IsOSXVersionSupported(10, 7, 0)) if (IsOSXVersionSupported(10, 7, 0))
{ {
attributes[9] = kCGLPFAOpenGLProfile; attributes[9] = NSOpenGLPFAOpenGLProfile;
attributes[10] = (CGLPixelFormatAttribute)kCGLOGLPVersion_3_2_Core; attributes[10] = NSOpenGLProfileVersion3_2Core;
OGLInfoCreate_Func = &OGLInfoCreate_3_2; OGLInfoCreate_Func = &OGLInfoCreate_3_2;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
if (format == nil)
{
attributes[9] = NSOpenGLPFAOpenGLProfile;
attributes[10] = NSOpenGLProfileVersionLegacy;
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
}
} }
#endif #endif
NSOpenGLPixelFormat *format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes]; if (format == nil)
{
attributes[9] = (NSOpenGLPixelFormatAttribute)0;
attributes[10] = (NSOpenGLPixelFormatAttribute)0;
OGLInfoCreate_Func = &OGLInfoCreate_Legacy;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
}
context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil];
[format release]; [format release];
cglDisplayContext = (CGLContextObj)[context CGLContextObj]; cglDisplayContext = (CGLContextObj)[context CGLContextObj];