From 12b123537d83ad0957577e66879c06671acc65aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20=C3=81ngel=20San=20Mart=C3=ADn?= Date: Thu, 7 May 2015 22:01:55 +0200 Subject: [PATCH] added missing files --- common/opengl_checker.cpp | 44 +++++++++++++++++++++++++++++++++++++++ common/opengl_checker.h | 15 +++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 common/opengl_checker.cpp create mode 100644 common/opengl_checker.h diff --git a/common/opengl_checker.cpp b/common/opengl_checker.cpp new file mode 100644 index 00000000..9a4353a5 --- /dev/null +++ b/common/opengl_checker.cpp @@ -0,0 +1,44 @@ +#include "opengl_checker.h" + +#include "QsLog.h" + +OpenGLChecker::OpenGLChecker() +{ + +} + +bool OpenGLChecker::hasCompatibleOpenGLVersion() +{ + QOpenGLContext * openGLContext = new QOpenGLContext(); + openGLContext->create(); + + if(!openGLContext->isValid()) + return false; + + QSurfaceFormat format = openGLContext->format(); + + int majorVersion = format.majorVersion(); + int minorVersion = format.minorVersion(); + + delete openGLContext; + + QLOG_INFO() << QString("OpenGL version %1.%2").arg(majorVersion).arg(minorVersion); + + if(format.renderableType() != QSurfaceFormat::OpenGL) //Desktop OpenGL + return false; + +#ifdef Q_OS_WIN //TODO check Qt version, and set this values depending on the use of QOpenGLWidget or QGLWidget + int majorTargetVersion = 1; + int minorTargetVersion = 5; +#else + int majorTargetVersion = 2; + int minorTargetVersion = 1; +#endif + + if(majorVersion < majorTargetVersion) + return false; + if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion) + return false; + + return true; +} diff --git a/common/opengl_checker.h b/common/opengl_checker.h new file mode 100644 index 00000000..6548a359 --- /dev/null +++ b/common/opengl_checker.h @@ -0,0 +1,15 @@ +#ifndef OPENGL_CHECKER_H +#define OPENGL_CHECKER_H + +#include + +class OpenGLChecker +{ +public: + OpenGLChecker(); + bool hasCompatibleOpenGLVersion(); +private: + //?? +}; + +#endif // OPENGL_CHECKER_H