mirror of
https://github.com/YACReader/yacreader
synced 2025-07-23 15:35:03 -04:00
Merge
This commit is contained in:
44
common/opengl_checker.cpp
Normal file
44
common/opengl_checker.cpp
Normal file
@ -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;
|
||||
}
|
15
common/opengl_checker.h
Normal file
15
common/opengl_checker.h
Normal file
@ -0,0 +1,15 @@
|
||||
#ifndef OPENGL_CHECKER_H
|
||||
#define OPENGL_CHECKER_H
|
||||
|
||||
#include <QOpenGLContext>
|
||||
|
||||
class OpenGLChecker
|
||||
{
|
||||
public:
|
||||
OpenGLChecker();
|
||||
bool hasCompatibleOpenGLVersion();
|
||||
private:
|
||||
//??
|
||||
};
|
||||
|
||||
#endif // OPENGL_CHECKER_H
|
Reference in New Issue
Block a user