mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 12:32:34 +00:00
Enable Core Profile on macOS only when OpenGL 3.3 is available
This commit is contained in:
parent
25ab31e92c
commit
c6351825b8
2 changed files with 27 additions and 25 deletions
|
@ -60,6 +60,8 @@ extern RenderBufferOptions rbOpts;
|
|||
#define AppKit10_5 949
|
||||
#define AppKit10_6 1038
|
||||
#define AppKit10_7 1138
|
||||
#define AppKit10_8 1187
|
||||
#define AppKit10_9 1265
|
||||
|
||||
|
||||
@interface NSWindow(ExitAppOnClose)
|
||||
|
|
|
@ -498,13 +498,7 @@ CocoaWindow* CreateCocoaWindow(const NSUInteger styleMask)
|
|||
return window;
|
||||
}
|
||||
|
||||
enum OpenGLProfile
|
||||
{
|
||||
Core,
|
||||
Legacy
|
||||
};
|
||||
|
||||
NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile)
|
||||
NSOpenGLPixelFormat* CreatePixelFormat(const NSOpenGLPixelFormatAttribute profile)
|
||||
{
|
||||
NSOpenGLPixelFormatAttribute attributes[16];
|
||||
size_t i = 0;
|
||||
|
@ -522,20 +516,8 @@ NSOpenGLPixelFormat* CreatePixelFormat(const OpenGLProfile profile)
|
|||
attributes[i++] = NSOpenGLPFAAllowOfflineRenderers;
|
||||
}
|
||||
|
||||
if (NSAppKitVersionNumber >= AppKit10_7 && OpenGLProfile::Core == profile)
|
||||
if (NSAppKitVersionNumber >= AppKit10_7)
|
||||
{
|
||||
NSOpenGLPixelFormatAttribute profile = NSOpenGLProfileVersion3_2Core;
|
||||
const char* const glversion = Args->CheckValue("-glversion");
|
||||
|
||||
if (nullptr != glversion)
|
||||
{
|
||||
const double version = strtod(glversion, nullptr) + 0.01;
|
||||
if (version < 3.0)
|
||||
{
|
||||
profile = NSOpenGLProfileVersionLegacy;
|
||||
}
|
||||
}
|
||||
|
||||
attributes[i++] = NSOpenGLPFAOpenGLProfile;
|
||||
attributes[i++] = profile;
|
||||
}
|
||||
|
@ -564,15 +546,33 @@ CocoaVideo::CocoaVideo()
|
|||
gl_CalculateCPUSpeed();
|
||||
|
||||
// Create OpenGL pixel format
|
||||
NSOpenGLPixelFormatAttribute defaultProfile = NSOpenGLProfileVersion3_2Core;
|
||||
|
||||
if (1 == vid_renderer && NSAppKitVersionNumber < AppKit10_9)
|
||||
{
|
||||
// There is no support for OpenGL 3.3 before Mavericks
|
||||
defaultProfile = NSOpenGLProfileVersionLegacy;
|
||||
}
|
||||
else if (0 == vid_renderer && vid_glswfb && NSAppKitVersionNumber < AppKit10_7)
|
||||
{
|
||||
// There is no support for OpenGL 3.x before Lion
|
||||
defaultProfile = NSOpenGLProfileVersionLegacy;
|
||||
}
|
||||
else if (const char* const glversion = Args->CheckValue("-glversion"))
|
||||
{
|
||||
// Check for explicit version specified in command line
|
||||
const double version = strtod(glversion, nullptr) + 0.01;
|
||||
if (version < 3.3)
|
||||
{
|
||||
defaultProfile = NSOpenGLProfileVersionLegacy;
|
||||
}
|
||||
}
|
||||
|
||||
const OpenGLProfile defaultProfile = (1 == vid_renderer || vid_glswfb)
|
||||
? OpenGLProfile::Core
|
||||
: OpenGLProfile::Legacy;
|
||||
NSOpenGLPixelFormat* pixelFormat = CreatePixelFormat(defaultProfile);
|
||||
|
||||
if (nil == pixelFormat && OpenGLProfile::Core == defaultProfile)
|
||||
if (nil == pixelFormat && NSOpenGLProfileVersion3_2Core == defaultProfile)
|
||||
{
|
||||
pixelFormat = CreatePixelFormat(OpenGLProfile::Legacy);
|
||||
pixelFormat = CreatePixelFormat(NSOpenGLProfileVersionLegacy);
|
||||
|
||||
if (nil == pixelFormat)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue