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 #load default build flags
include (../config.pri) include (../config.pri)
unix:!macx{ unix:!macx{
QMAKE_CXXFLAGS += -std=c++11 QMAKE_CXXFLAGS += -std=c++11
} }
Release:DESTDIR = ../release CONFIG(force_angle) {
Debug:DESTDIR = ../debug Release:DESTDIR = ../release_angle
Debug:DESTDIR = ../debug_angle
} else {
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
}
SOURCES += main.cpp SOURCES += main.cpp
@ -29,15 +34,25 @@ INCLUDEPATH += ../common \
INCLUDEPATH += ../common/gl \ INCLUDEPATH += ../common/gl \
} }
#there are going to be two builds for windows, OpenGL based and ANGLE based
win32 { 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 LIBS += -lpoppler-qt5
INCLUDEPATH += ../dependencies/poppler/include/qt5 INCLUDEPATH += ../dependencies/poppler/include/qt5
QMAKE_CXXFLAGS_RELEASE += /02 /MP /Ob2 /Oi /Ot /GT /GL QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe CONFIG -= embed_manifest_exe
} }
unix:!macx{ unix:!macx{

View File

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

View File

@ -24,16 +24,25 @@ CONFIG(legacy_gl_widget) {
INCLUDEPATH += ../common/gl \ INCLUDEPATH += ../common/gl \
} }
#there are going to be two builds for windows, OpenGL based and ANGLE based
win32 { 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 QMAKE_CXXFLAGS_RELEASE += /MP /Ob2 /Oi /Ot /GT /GL
INCLUDEPATH += ../dependencies/poppler/include/qt5 QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
QMAKE_CXXFLAGS_RELEASE += /02 /MP /Ob2 /Oi /Ot /GT /GL
QMAKE_LFLAGS_RELEASE += /LTCG
CONFIG -= embed_manifest_exe
} }
unix:!macx{ unix:!macx{
@ -250,9 +259,13 @@ TRANSLATIONS = yacreaderlibrary_es.ts \
yacreaderlibrary_de.ts \ yacreaderlibrary_de.ts \
yacreaderlibrary_source.ts yacreaderlibrary_source.ts
CONFIG(force_angle) {
Release:DESTDIR = ../release Release:DESTDIR = ../release_angle
Debug:DESTDIR = ../debug Debug:DESTDIR = ../debug_angle
} else {
Release:DESTDIR = ../release
Debug:DESTDIR = ../debug
}
#QML/GridView #QML/GridView
QT += quick qml QT += quick qml

View File

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

View File

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

View File

@ -3,42 +3,67 @@
#include "QsLog.h" #include "QsLog.h"
OpenGLChecker::OpenGLChecker() OpenGLChecker::OpenGLChecker()
{ :compatibleOpenGLVersion(true)
}
bool OpenGLChecker::hasCompatibleOpenGLVersion()
{ {
QOpenGLContext * openGLContext = new QOpenGLContext(); QOpenGLContext * openGLContext = new QOpenGLContext();
openGLContext->create(); openGLContext->create();
if(!openGLContext->isValid()) if(!openGLContext->isValid())
return false; {
compatibleOpenGLVersion = false;
description = "unable to create QOpenGLContext";
}
QSurfaceFormat format = openGLContext->format(); QSurfaceFormat format = openGLContext->format();
int majorVersion = format.majorVersion(); int majorVersion = format.majorVersion();
int minorVersion = format.minorVersion(); 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; 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 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 #ifdef Q_OS_WIN //TODO check Qt version, and set this values depending on the use of QOpenGLWidget or QGLWidget
int majorTargetVersion = 1; static const int majorTargetVersion = 1;
int minorTargetVersion = 5; static const int minorTargetVersion = 4;
#else #else
int majorTargetVersion = 2; static const int majorTargetVersion = 2;
int minorTargetVersion = 1; static const int minorTargetVersion = 0;
#endif #endif
if(majorVersion < majorTargetVersion) if(majorVersion < majorTargetVersion)
return false; compatibleOpenGLVersion = false;
if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion) if(majorVersion == majorTargetVersion && minorVersion < minorTargetVersion)
return false; compatibleOpenGLVersion = false;
}
return true;
QString OpenGLChecker::textVersionDescription()
{
return description;
}
bool OpenGLChecker::hasCompatibleOpenGLVersion()
{
return compatibleOpenGLVersion;
} }

View File

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

View File

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