Bladeren bron

Move OpenGL context preparation to new source file

All OpenGL hacks will find a home here. There's going to be more
(platform specifics for Linux and Windows).
Vincent Lang 9 jaren geleden
bovenliggende
commit
fc18e6dbf9
4 gewijzigde bestanden met toevoegingen van 38 en 9 verwijderingen
  1. 3 9
      src/main.cpp
  2. 1 0
      src/player/CMakeLists.txt
  3. 28 0
      src/player/OpenGLDetect.cpp
  4. 6 0
      src/player/OpenGLDetect.h

+ 3 - 9
src/main.cpp

@@ -15,6 +15,7 @@
 #include "Paths.h"
 #include "player/CodecsComponent.h"
 #include "player/PlayerComponent.h"
+#include "player/OpenGLDetect.h"
 #include "breakpad/CrashDumps.h"
 #include "Version.h"
 #include "settings/SettingsComponent.h"
@@ -98,17 +99,10 @@ int main(int argc, char *argv[])
     //
 #ifdef Q_OS_MAC
     qputenv("QT_LOGGING_RULES", "qt.network.ssl.warning=false");
-
-    // Request OpenGL 4.1 if possible on OSX, otherwise it defaults to 2.0
-    // This needs to be done before we create the QGuiApplication
-    //
-    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
-    format.setMajorVersion(3);
-    format.setMinorVersion(2);
-    format.setProfile(QSurfaceFormat::CoreProfile);
-    QSurfaceFormat::setDefaultFormat(format);
 #endif
 
+    detectOpenGL();
+
     preinitQt();
 
     QGuiApplication app(argc, newArgv);

+ 1 - 0
src/player/CMakeLists.txt

@@ -1,3 +1,4 @@
 add_sources(PlayerComponent.cpp PlayerComponent.h)
 add_sources(PlayerQuickItem.cpp PlayerQuickItem.h)
 add_sources(CodecsComponent.cpp CodecsComponent.h)
+add_sources(OpenGLDetect.cpp OpenGLDetect.h)

+ 28 - 0
src/player/OpenGLDetect.cpp

@@ -0,0 +1,28 @@
+#include <QSurfaceFormat>
+
+#include "OpenGLDetect.h"
+
+#if defined(Q_OS_MAC)
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+void detectOpenGL()
+{
+    // Request OpenGL 4.1 if possible on OSX, otherwise it defaults to 2.0
+    // This needs to be done before we create the QGuiApplication
+    //
+    QSurfaceFormat format = QSurfaceFormat::defaultFormat();
+    format.setMajorVersion(3);
+    format.setMinorVersion(2);
+    format.setProfile(QSurfaceFormat::CoreProfile);
+    QSurfaceFormat::setDefaultFormat(format);
+}
+
+#else
+
+///////////////////////////////////////////////////////////////////////////////////////////////////
+void detectOpenGL()
+{
+  // nothing to do
+}
+
+#endif

+ 6 - 0
src/player/OpenGLDetect.h

@@ -0,0 +1,6 @@
+#ifndef OPENGLDETECT_H
+#define OPENGLDETECT_H
+
+void detectOpenGL();
+
+#endif // OPENGLDETECT_H