Skip to content

Commit

Permalink
Qt: fix OpenGL initialization on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
fleroviux committed Dec 20, 2021
1 parent 7062818 commit 115bac1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:
- name: Collect artifacts
run: |
mkdir upload
cp -r build/bin/sdl/{NanoBoyAdvance,config.toml,keymap.toml,shaders} upload
cp -r build/bin/qt/{NanoBoyAdvance,config.toml} upload
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
Expand Down
9 changes: 9 additions & 0 deletions src/platform/qt/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

#include <QApplication>
#include <QSurfaceFormat>
#include <stdlib.h>

#include "widget/main_window.hpp"
Expand All @@ -14,6 +15,14 @@ int main(int argc, char** argv) {
// See: https://trac.wxwidgets.org/ticket/19023
#if defined(__APPLE__)
setenv("LC_NUMERIC", "C", 1);

// On macOS QSurfaceFormat::setDefaultFormat() must be called before constructing the QApplication.
auto format = QSurfaceFormat{};
format.setProfile(QSurfaceFormat::CoreProfile);
format.setMajorVersion(3);
format.setMinorVersion(3);
format.setSwapInterval(0);
QSurfaceFormat::setDefaultFormat(format);
#endif

QApplication app{ argc, argv };
Expand Down

0 comments on commit 115bac1

Please sign in to comment.