Skip to content

Commit

Permalink
Cocoa Port: Fix OpenGL context creation on older macOS.
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerman committed Aug 3, 2024
1 parent d7dcc85 commit 5baeb02
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 20 deletions.
10 changes: 5 additions & 5 deletions desmume/src/OGLRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -793,12 +793,12 @@ static inline void glDrawBufferDESMUME(GLenum theAttachment, const OpenGLVariant
glDrawBuffers(1, bufs);
return;

case GL_COLOR_ATTACHMENT0:
case GL_COLOR_ATTACHMENT1:
case GL_COLOR_ATTACHMENT2:
case GL_COLOR_ATTACHMENT3:
case GL_COLOR_ATTACHMENT0_EXT:
case GL_COLOR_ATTACHMENT1_EXT:
case GL_COLOR_ATTACHMENT2_EXT:
case GL_COLOR_ATTACHMENT3_EXT:
{
const GLsizei i = theAttachment - GL_COLOR_ATTACHMENT0;
const GLsizei i = theAttachment - GL_COLOR_ATTACHMENT0_EXT;
bufs[i] = theAttachment;
glDrawBuffers(i+1, bufs);
return;
Expand Down
30 changes: 15 additions & 15 deletions desmume/src/frontend/cocoa/cocoa_GPU.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1822,6 +1822,7 @@ static CVReturn MacDisplayLinkCallback(CVDisplayLinkRef displayLink,
#pragma mark -

#if !defined(MAC_OS_X_VERSION_10_7)
#define kCGLPFAOpenGLProfile (CGLPixelFormatAttribute)99
#define kCGLOGLPVersion_Legacy 0x1000
#define kCGLOGLPVersion_3_2_Core 0x3200
#define kCGLOGLPVersion_GL3_Core 0x3200
Expand Down Expand Up @@ -1862,8 +1863,8 @@ static bool __cgl_initOpenGL(const int requestedProfile)
CGLPixelFormatAttribute attrs[] = {
kCGLPFAColorSize, (CGLPixelFormatAttribute)24,
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)8,
kCGLPFADepthSize, (CGLPixelFormatAttribute)0,
kCGLPFAStencilSize, (CGLPixelFormatAttribute)0,
kCGLPFADepthSize, (CGLPixelFormatAttribute)24,
kCGLPFAStencilSize, (CGLPixelFormatAttribute)8,
kCGLPFAOpenGLProfile, (CGLPixelFormatAttribute)0,
kCGLPFAAccelerated,
(CGLPixelFormatAttribute)0
Expand All @@ -1873,11 +1874,13 @@ static bool __cgl_initOpenGL(const int requestedProfile)
{
if (IsOSXVersionSupported(10, 9, 0))
{
attrs[5] = (CGLPixelFormatAttribute)0; // We'll be using FBOs instead of the default framebuffer.
attrs[7] = (CGLPixelFormatAttribute)0; // We'll be using FBOs instead of the default framebuffer.
attrs[9] = (CGLPixelFormatAttribute)requestedProfile;
}
else
{
fprintf(stderr, "%s: Your version of OS X is too old to support this profile.\n", ctxString);
fprintf(stderr, "%s: Your version of OS X is too old to support 4.1 Core Profile.\n", ctxString);
return result;
}
}
Expand All @@ -1888,27 +1891,24 @@ static bool __cgl_initOpenGL(const int requestedProfile)
// instead, which at least has a working shader compiler for OpenGL 3.2.
if (IsOSXVersionSupported(10, 8, 0))
{
attrs[5] = (CGLPixelFormatAttribute)0; // We'll be using FBOs instead of the default framebuffer.
attrs[7] = (CGLPixelFormatAttribute)0; // We'll be using FBOs instead of the default framebuffer.
attrs[9] = (CGLPixelFormatAttribute)requestedProfile;
}
else
{
fprintf(stderr, "%s: Your version of OS X is too old to support this profile.\n", ctxString);
fprintf(stderr, "%s: Your version of OS X is too old to support 3.2 Core Profile.\n", ctxString);
return result;
}
}
else if (IsOSXVersionSupported(10, 7, 0))
{
attrs[9] = (CGLPixelFormatAttribute)kCGLOGLPVersion_Legacy;
}
else
{
if (IsOSXVersionSupported(10, 7, 0))
{
attrs[9] = (CGLPixelFormatAttribute)kCGLOGLPVersion_Legacy;
}
else
{
attrs[5] = (CGLPixelFormatAttribute)24; // Since the default framebuffer may be needed, depth bits are also needed.
attrs[7] = (CGLPixelFormatAttribute)8; // Since the default framebuffer may be needed, stencil bits are also needed.
attrs[8] = (CGLPixelFormatAttribute)kCGLPFAAccelerated;
attrs[10] = (CGLPixelFormatAttribute)0;
}
attrs[8] = (CGLPixelFormatAttribute)kCGLPFAAccelerated;
attrs[10] = (CGLPixelFormatAttribute)0;
}

CGLError error = kCGLNoError;
Expand Down

0 comments on commit 5baeb02

Please sign in to comment.