diff --git a/YACReader/YACReader.pro b/YACReader/YACReader.pro index 3ea50e18..e2c1bf6b 100644 --- a/YACReader/YACReader.pro +++ b/YACReader/YACReader.pro @@ -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{ diff --git a/YACReader/main.cpp b/YACReader/main.cpp index 1a85e808..fd01d04e 100644 --- a/YACReader/main.cpp +++ b/YACReader/main.cpp @@ -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; diff --git a/YACReaderLibrary/YACReaderLibrary.pro b/YACReaderLibrary/YACReaderLibrary.pro index 8ffa2616..5440d0f1 100644 --- a/YACReaderLibrary/YACReaderLibrary.pro +++ b/YACReaderLibrary/YACReaderLibrary.pro @@ -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 diff --git a/YACReaderLibrary/classic_comics_view.cpp b/YACReaderLibrary/classic_comics_view.cpp index c6a3a017..4d2f5db6 100644 --- a/YACReaderLibrary/classic_comics_view.cpp +++ b/YACReaderLibrary/classic_comics_view.cpp @@ -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); diff --git a/YACReaderLibrary/main.cpp b/YACReaderLibrary/main.cpp index 1233ffac..581fcfc3 100644 --- a/YACReaderLibrary/main.cpp +++ b/YACReaderLibrary/main.cpp @@ -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 diff --git a/common/opengl_checker.cpp b/common/opengl_checker.cpp index 9a4353a5..d62bfac1 100644 --- a/common/opengl_checker.cpp +++ b/common/opengl_checker.cpp @@ -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; } diff --git a/common/opengl_checker.h b/common/opengl_checker.h index 6548a359..cce9772f 100644 --- a/common/opengl_checker.h +++ b/common/opengl_checker.h @@ -8,8 +8,10 @@ class OpenGLChecker public: OpenGLChecker(); bool hasCompatibleOpenGLVersion(); + QString textVersionDescription(); private: - //?? + QString description; + bool compatibleOpenGLVersion; }; #endif // OPENGL_CHECKER_H diff --git a/custom_widgets/yacreader_options_dialog.cpp b/custom_widgets/yacreader_options_dialog.cpp index 4047acea..db4d1f34 100644 --- a/custom_widgets/yacreader_options_dialog.cpp +++ b/custom_widgets/yacreader_options_dialog.cpp @@ -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 \ No newline at end of file +#endif