summaryrefslogtreecommitdiffstatshomepage
path: root/src/osd/modules/render/drawogl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/osd/modules/render/drawogl.cpp')
-rw-r--r--src/osd/modules/render/drawogl.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/osd/modules/render/drawogl.cpp b/src/osd/modules/render/drawogl.cpp
index 6837e63bbe3..97acc3d259b 100644
--- a/src/osd/modules/render/drawogl.cpp
+++ b/src/osd/modules/render/drawogl.cpp
@@ -41,6 +41,11 @@
#include "modules/opengl/gl_shader_mgr.h"
#if defined(SDLMAME_MACOSX) || defined(OSD_MAC)
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
#ifndef APIENTRY
#define APIENTRY
#endif
@@ -1116,7 +1121,40 @@ int renderer_ogl::draw(const int update)
// |_________|
// (0,h) (w,h)
- glViewport(0.0, 0.0, (GLsizei) m_width, (GLsizei) m_height);
+ GLsizei iScale = 1;
+
+ /*
+ Mac hack: macOS version 10.15 and later flipped from assuming you don't support Retina to
+ assuming you do support Retina. SDL 2.0.11 is scheduled to fix this, but it's not out yet.
+ So we double-scale everything if you're on 10.15 or later and SDL is not at least version 2.0.11.
+ */
+ #if defined(SDLMAME_MACOSX) || defined(OSD_MAC)
+ SDL_version sdlVers;
+ SDL_GetVersion(&sdlVers);
+ // Only do this if SDL is not at least 2.0.11.
+ if ((sdlVers.major == 2) && (sdlVers.minor == 0) && (sdlVers.patch < 11))
+ {
+ // now get the Darwin kernel version
+ int dMaj, dMin, dPatch;
+ char versStr[64];
+ dMaj = dMin = dPatch = 0;
+ size_t size = sizeof(versStr);
+ int retVal = sysctlbyname("kern.osrelease", versStr, &size, NULL, 0);
+ if (retVal == 0)
+ {
+ sscanf(versStr, "%d.%d.%d", &dMaj, &dMin, &dPatch);
+ // 10.15 Catalina is Darwin version 19
+ if (dMaj >= 19)
+ {
+ // do the workaround for Retina being forced on
+ osd_printf_verbose("OpenGL: enabling Retina workaround\n");
+ iScale = 2;
+ }
+ }
+ }
+ #endif
+
+ glViewport(0.0, 0.0, (GLsizei) m_width * iScale, (GLsizei) m_height * iScale);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, (GLdouble) m_width, (GLdouble) m_height, 0.0, 0.0, -1.0);