Files
YACReader
YACReaderLibrary
YACReaderLibraryServer
ci
common
gl
bookmarks.cpp
bookmarks.h
check_new_version.cpp
check_new_version.h
comic.cpp
comic.h
comic_db.cpp
comic_db.h
concurrent_queue.cpp
concurrent_queue.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
opengl_checker.cpp
opengl_checker.h
pdf_comic.cpp
pdf_comic.h
pdf_comic.mm
pictureflow.cpp
pictureflow.h
qnaturalsorting.cpp
qnaturalsorting.h
release_acquire_atomic.h
scroll_management.cpp
scroll_management.h
worker_thread.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
third_party
.clang-format
.editorconfig
.gitattributes
.gitignore
CHANGELOG.md
COPYING.txt
INSTALL.md
README.md
YACReader.1
YACReader.desktop
YACReader.pro
YACReader.svg
YACReaderLibrary.1
YACReaderLibrary.desktop
YACReaderLibrary.svg
azure-pipelines-build-number.yml
azure-pipelines-windows-template-qt6.yml
azure-pipelines-windows-template.yml
azure-pipelines.yml
background.png
background@2x.png
cleanOSX.sh
compileOSX.sh
config.pri
dmg.json
icon.icns
mktarball.sh
signapps.sh
yacreader/common/opengl_checker.cpp
Luis Ángel San Martín 5aa02a19bb clang-format
2021-10-18 21:56:52 +02:00

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;
}