From ccd27980a23fe88458926516ca590e5bce7e44f6 Mon Sep 17 00:00:00 2001 From: Dan Paulat Date: Sat, 14 Jun 2025 22:35:34 -0500 Subject: [PATCH] Updates for OpenGL 4.1 Core on macOS --- scwx-qt/source/scwx/qt/gl/gl_context.cpp | 8 ++++++++ scwx-qt/source/scwx/qt/main/main.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+) diff --git a/scwx-qt/source/scwx/qt/gl/gl_context.cpp b/scwx-qt/source/scwx/qt/gl/gl_context.cpp index 4cc42879..9fd6bd85 100644 --- a/scwx-qt/source/scwx/qt/gl/gl_context.cpp +++ b/scwx-qt/source/scwx/qt/gl/gl_context.cpp @@ -12,6 +12,7 @@ namespace gl { static const std::string logPrefix_ = "scwx::qt::gl::gl_context"; +static const auto logger_ = scwx::util::Logger::Create(logPrefix_); class GlContext::Impl { @@ -84,6 +85,13 @@ void GlContext::Impl::InitializeGL() gl_->initializeOpenGLFunctions(); gl30_->initializeOpenGLFunctions(); + logger_->info("OpenGL Version: {}", + reinterpret_cast(gl_->glGetString(GL_VERSION))); + logger_->info("OpenGL Vendor: {}", + reinterpret_cast(gl_->glGetString(GL_VENDOR))); + logger_->info("OpenGL Renderer: {}", + reinterpret_cast(gl_->glGetString(GL_RENDERER))); + gl_->glGenTextures(1, &textureAtlas_); glInitialized_ = true; diff --git a/scwx-qt/source/scwx/qt/main/main.cpp b/scwx-qt/source/scwx/qt/main/main.cpp index 904ff3b3..7a1993f7 100644 --- a/scwx-qt/source/scwx/qt/main/main.cpp +++ b/scwx-qt/source/scwx/qt/main/main.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -62,6 +63,16 @@ int main(int argc, char* argv[]) QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true); +#if defined(__APPLE__) + // For macOS, we must choose between OpenGL 4.1 Core and OpenGL 2.1 + // Compatibility. OpenGL 2.1 does not meet requirements for shaders used by + // Supercell Wx. + QSurfaceFormat surfaceFormat = QSurfaceFormat::defaultFormat(); + surfaceFormat.setVersion(4, 1); + surfaceFormat.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile); + QSurfaceFormat::setDefaultFormat(surfaceFormat); +#endif + QApplication a(argc, argv); QCoreApplication::setApplicationName("Supercell Wx");