Skip to content

Commit

Permalink
Ensure the default OpenGL profile exceeds our minimum
Browse files Browse the repository at this point in the history
  • Loading branch information
timangus committed Oct 11, 2023
1 parent 007c876 commit fc11f21
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions source/app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ int start(int argc, char *argv[], ConsoleOutputFiles& consoleOutputFiles)
return 1;
}

OpenGLFunctions::requestMinimumFormat();

configureXDG();

qRegisterMetaType<size_t>("size_t");
Expand Down
11 changes: 11 additions & 0 deletions source/app/rendering/openglfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ QSurfaceFormat OpenGLFunctions::minimumFormat()
return format;
}

void OpenGLFunctions::requestMinimumFormat()
{
auto defaultFormat = QSurfaceFormat::defaultFormat();
std::pair<int, int> defaultVersion = {defaultFormat.majorVersion(), defaultFormat.minorVersion()};
auto requestFormat = minimumFormat();
std::pair<int, int> requestVersion = {requestFormat.majorVersion(), requestFormat.minorVersion()};

if(defaultVersion < requestVersion)
QSurfaceFormat::setDefaultFormat(requestFormat);
}

class QueryFunctions
{
private:
Expand Down
1 change: 1 addition & 0 deletions source/app/rendering/openglfunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class OpenGLFunctions : public QOpenGLFunctions_3_3_Core
static QString info();

static QSurfaceFormat minimumFormat();
static void requestMinimumFormat();

private:
PFNGLMINSAMPLESHADINGARBPROC _glMinSampleShadingARBFnPtr = nullptr;
Expand Down

0 comments on commit fc11f21

Please sign in to comment.