mirror of
https://github.com/YACReader/yacreader
synced 2025-08-12 01:05:06 -04:00
QsLog
YACReader
YACReaderLibrary
YACReaderLibraryServer
common
gl
bookmarks.cpp
bookmarks.h
check_new_version.cpp
check_new_version.h
comic.cpp
comic.h
comic_db.cpp
comic_db.h
custom_widgets.cpp
custom_widgets.h
exit_check.cpp
exit_check.h
folder.cpp
folder.h
http_worker.cpp
http_worker.h
library_item.cpp
library_item.h
onstart_flow_selection_dialog.cpp
onstart_flow_selection_dialog.h
opengl_checker.cpp
opengl_checker.h
pdf_comic.cpp
pdf_comic.h
pdf_comic.mm
pictureflow.cpp
pictureflow.h
qnaturalsorting.cpp
qnaturalsorting.h
scroll_management.cpp
scroll_management.h
yacreader_global.cpp
yacreader_global.h
yacreader_global_gui.cpp
yacreader_global_gui.h
compressed_archive
custom_widgets
dependencies
files
images
release
shortcuts_management
tests
.editorconfig
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
COPYING.txt
INSTALL.md
README.txt
YACReader.1
YACReader.desktop
YACReader.pro
YACReader.svg
YACReaderLibrary.1
YACReaderLibrary.desktop
YACReaderLibrary.svg
appveyor.yml
background.png
cleanOSX.sh
compileOSX.sh
config.pri
icon.icns
mktarball.sh
releaseOSX.sh
71 lines
1.8 KiB
C++
71 lines
1.8 KiB
C++
#include "opengl_checker.h"
|
|
|
|
#include "QsLog.h"
|
|
|
|
OpenGLChecker::OpenGLChecker()
|
|
:compatibleOpenGLVersion(true)
|
|
{
|
|
QOpenGLContext * openGLContext = new QOpenGLContext();
|
|
openGLContext->create();
|
|
|
|
if(!openGLContext->isValid())
|
|
{
|
|
compatibleOpenGLVersion = false;
|
|
description = "unable to create QOpenGLContext";
|
|
}
|
|
|
|
QSurfaceFormat format = openGLContext->format();
|
|
|
|
int majorVersion = format.majorVersion();
|
|
int minorVersion = format.minorVersion();
|
|
QString type;
|
|
|
|
switch (format.renderableType()) {
|
|
case QSurfaceFormat::OpenGL:
|
|
type = "desktop";
|
|
break;
|
|
|
|
case QSurfaceFormat::OpenGLES:
|
|
type = "OpenGL ES";
|
|
break;
|
|
|
|
case QSurfaceFormat::OpenVG:
|
|
type = "OpenVG";
|
|
break;
|
|
|
|
default: case QSurfaceFormat::DefaultRenderableType:
|
|
type = "unknown";
|
|
break;
|
|
}
|
|
|
|
delete openGLContext;
|
|
|
|
description = QString("%1.%2 %3").arg(majorVersion).arg(minorVersion).arg(type);
|
|
|
|
if(format.renderableType() != QSurfaceFormat::OpenGL) //Desktop OpenGL
|
|
compatibleOpenGLVersion = false;
|
|
|
|
#ifdef Q_OS_WIN //TODO check Qt version, and set this values depending on the use of QOpenGLWidget or QGLWidget
|
|
static const int majorTargetVersion = 1;
|
|
static const int minorTargetVersion = 4;
|
|
#else
|
|
static const int majorTargetVersion = 2;
|
|
static const int minorTargetVersion = 0;
|
|
#endif
|
|
|
|
if(majorVersion < majorTargetVersion)
|
|
compatibleOpenGLVersion = false;
|
|
if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion)
|
|
compatibleOpenGLVersion = false;
|
|
}
|
|
|
|
QString OpenGLChecker::textVersionDescription()
|
|
{
|
|
return description;
|
|
}
|
|
|
|
bool OpenGLChecker::hasCompatibleOpenGLVersion()
|
|
{
|
|
return compatibleOpenGLVersion;
|
|
}
|