Use GLEW instead of QOpenGLFunctions

This commit is contained in:
Dan Paulat 2025-07-07 22:44:01 -05:00
parent 4bd749d976
commit 331b2d855f
33 changed files with 788 additions and 959 deletions

View file

@ -43,6 +43,7 @@ static const std::string logPrefix_ = "scwx::main";
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
static void ConfigureTheme(const std::vector<std::string>& args);
static void InitializeOpenGL();
static void OverrideDefaultStyle(const std::vector<std::string>& args);
static void OverridePlatform();
@ -66,17 +67,7 @@ int main(int argc, char* argv[])
scwx::qt::main::kBuildNumber_,
scwx::qt::main::kCommitString_);
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
InitializeOpenGL();
QApplication a(argc, argv);
@ -234,6 +225,23 @@ static void ConfigureTheme(const std::vector<std::string>& args)
}
}
static void InitializeOpenGL()
{
QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true);
QSurfaceFormat surfaceFormat = QSurfaceFormat::defaultFormat();
surfaceFormat.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
#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.
surfaceFormat.setVersion(4, 1);
#endif
QSurfaceFormat::setDefaultFormat(surfaceFormat);
}
static void
OverrideDefaultStyle([[maybe_unused]] const std::vector<std::string>& args)
{