added an option for choosing between OpenGL/Angle at building time

This commit is contained in:
Luis Ángel San Martín 2015-06-09 19:19:04 +02:00
parent 0461509765
commit ba8892f344
8 changed files with 113 additions and 41 deletions

View File

@ -11,12 +11,17 @@ DEFINES += NOMINMAX YACREADER
#load default build flags
include (../config.pri)
unix:!macx{
QMAKE_CXXFLAGS += -std=c++11
unix:!macx{
QMAKE_CXXFLAGS += -std=c++11
}
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
CONFIG(force_angle) {
Release:DESTDIR = ../release_angle
Debug:DESTDIR = ../debug_angle
} else {
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
}
SOURCES += main.cpp
@ -29,15 +34,25 @@ INCLUDEPATH += ../common \
INCLUDEPATH += ../common/gl \
}
#there are going to be two builds for windows, OpenGL based and ANGLE based
win32 {
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lopengl32 -lglu32 -luser32
CONFIG(force_angle) {
message("using ANGLE")
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
#linking extra libs are necesary for a successful compilation, a better approach should be
#to remove any OpenGL (desktop) dependencies
#the OpenGL stuff should be migrated to OpenGL ES
DEFINES += FORCE_ANGLE
} else {
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32
}
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
QMAKE_CXXFLAGS_RELEASE += /02 /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
}
unix:!macx{

View File

@ -59,6 +59,7 @@ class YACReaderApplication: public QApplication
int main(int argc, char * argv[])
{
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
#endif
@ -78,9 +79,13 @@ int main(int argc, char * argv[])
QApplication app(argc, argv);
#endif
#ifdef FORCE_ANGLE
app.setAttribute(Qt::AA_UseOpenGLES);
#endif
app.setApplicationName("YACReader");
app.setOrganizationName("YACReader");
qApp->setAttribute(Qt::AA_UseHighDpiPixmaps);
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
//simple command line parser
//will be replaced by QCommandLineParser in the future
QStringList optlist;

View File

@ -24,16 +24,25 @@ CONFIG(legacy_gl_widget) {
INCLUDEPATH += ../common/gl \
}
#there are going to be two builds for windows, OpenGL based and ANGLE based
win32 {
CONFIG(force_angle) {
message("using ANGLE")
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
#linking extra libs are necesary for a successful compilation, a better approach should be
#to remove any OpenGL (desktop) dependencies
#the OpenGL stuff should be migrated to OpenGL ES
DEFINES += FORCE_ANGLE
} else {
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32
}
LIBS += -L../dependencies/poppler/lib -loleaut32 -lole32 -lshell32 -lopengl32 -lglu32 -luser32
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5
QMAKE_CXXFLAGS_RELEASE += /02 /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
}
unix:!macx{
@ -250,9 +259,13 @@ TRANSLATIONS = yacreaderlibrary_es.ts \
yacreaderlibrary_de.ts \
yacreaderlibrary_source.ts
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
CONFIG(force_angle) {
Release:DESTDIR = ../release_angle
Debug:DESTDIR = ../debug_angle
} else {
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
}
#QML/GridView
QT += quick qml

View File

@ -16,6 +16,7 @@ ClassicComicsView::ClassicComicsView(QWidget *parent)
settings->beginGroup("libraryConfig");
//FLOW-----------------------------------------------------------------------
//---------------------------------------------------------------------------
//FORCE_ANGLE is not used here, because ComicFlowWidgetGL will use OpenGL ES in the future
#ifndef NO_OPENGL
if((settings->value(USE_OPEN_GL).toBool() == true))
comicFlow = new ComicFlowWidgetGL(0);

View File

@ -19,6 +19,7 @@
#include "db_helper.h"
#include "yacreader_libraries.h"
#include "exit_check.h"
#include "opengl_checker.h"
#include "QsLog.h"
#include "QsLogDest.h"
@ -127,12 +128,16 @@ void logSystemAndConfig()
else
QLOG_INFO() << "OpenGL : disabled";
OpenGLChecker checker;
QLOG_INFO() << "OpenGL version : " << checker.textVersionDescription();
QLOG_INFO() << "Libraries: " << DBHelper::getLibraries().getLibraries();
QLOG_INFO() << "--------------------------------------------";
}
int main( int argc, char ** argv )
{
//fix for misplaced text in Qt4.8 and Mavericks
#ifdef Q_OS_MAC
#if QT_VERSION < 0x050000
@ -144,9 +149,13 @@ int main( int argc, char ** argv )
QApplication app( argc, argv );
#ifdef FORCE_ANGLE
app.setAttribute(Qt::AA_UseOpenGLES);
#endif
app.setApplicationName("YACReaderLibrary");
app.setOrganizationName("YACReader");
qApp->setAttribute(Qt::AA_UseHighDpiPixmaps);
app.setAttribute(Qt::AA_UseHighDpiPixmaps);
//simple command line parser
//will be replaced by QCommandLineParser in the future
//TODO: --headless, --server=[on|off], support for file and directory arguments
@ -212,7 +221,6 @@ int main( int argc, char ** argv )
if(settings->value(SERVER_ON,true).toBool())
{
s->start();
}
#endif

View File

@ -3,42 +3,67 @@
#include "QsLog.h"
OpenGLChecker::OpenGLChecker()
{
}
bool OpenGLChecker::hasCompatibleOpenGLVersion()
:compatibleOpenGLVersion(true)
{
QOpenGLContext * openGLContext = new QOpenGLContext();
openGLContext->create();
if(!openGLContext->isValid())
return false;
{
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";
default: case QSurfaceFormat::DefaultRenderableType:
type = "unknown";
break;
}
delete openGLContext;
QLOG_INFO() << QString("OpenGL version %1.%2").arg(majorVersion).arg(minorVersion);
description = QString("%1.%2 %3").arg(majorVersion).arg(minorVersion).arg(type);
if(format.renderableType() != QSurfaceFormat::OpenGL) //Desktop OpenGL
return false;
compatibleOpenGLVersion = 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;
static const int majorTargetVersion = 1;
static const int minorTargetVersion = 4;
#else
int majorTargetVersion = 2;
int minorTargetVersion = 1;
static const int majorTargetVersion = 2;
static const int minorTargetVersion = 0;
#endif
if(majorVersion < majorTargetVersion)
return false;
compatibleOpenGLVersion = false;
if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion)
return false;
return true;
compatibleOpenGLVersion = false;
}
QString OpenGLChecker::textVersionDescription()
{
return description;
}
bool OpenGLChecker::hasCompatibleOpenGLVersion()
{
return compatibleOpenGLVersion;
}

View File

@ -8,8 +8,10 @@ class OpenGLChecker
public:
OpenGLChecker();
bool hasCompatibleOpenGLVersion();
QString textVersionDescription();
private:
//??
QString description;
bool compatibleOpenGLVersion;
};
#endif // OPENGL_CHECKER_H

View File

@ -46,6 +46,9 @@ YACReaderOptionsDialog::YACReaderOptionsDialog(QWidget * parent)
#ifndef NO_OPENGL
useGL = new QCheckBox(tr("Use hardware acceleration (restart needed)"));
connect(useGL,SIGNAL(stateChanged(int)),this,SLOT(saveUseGL(int)));
#endif
#ifdef FORCE_ANGLE
useGL->setHidden(true);
#endif
//sw CONNECTIONS
connect(sw->radio1,SIGNAL(toggled(bool)),this,SLOT(setClassicConfigSW()));
@ -395,4 +398,4 @@ void YACReaderOptionsDialog::setRouletteConfig()
saveFlowParameters();
}
#endif
#endif