From be0951f21f8c800851ca65cfba2895e1af62911a Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:25:08 +0100 Subject: [PATCH 1/8] Fixed: Need to initialize OpenGL driver --HG-- branch : develop --- code/ryzom/tools/client/client_config_qt/system.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ryzom/tools/client/client_config_qt/system.cpp b/code/ryzom/tools/client/client_config_qt/system.cpp index 6070e4abd..a86abb7bb 100644 --- a/code/ryzom/tools/client/client_config_qt/system.cpp +++ b/code/ryzom/tools/client/client_config_qt/system.cpp @@ -145,6 +145,7 @@ void CSystem::GatherOpenGLInfo() try { NL3D::IDriver *driver = NL3D::CDRU::createGlDriver(); + driver->init(0); GetVideoModes( openglInfo.modes, driver ); driver->release(); } From 2c6d4b6a50962687c0265c161640ebff2da244f0 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:26:32 +0100 Subject: [PATCH 2/8] Fixed: Frequency checks useless because it can be 0 or a wrong value, 16 bits depth requirement --HG-- branch : develop --- code/ryzom/tools/client/client_config_qt/system.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/ryzom/tools/client/client_config_qt/system.cpp b/code/ryzom/tools/client/client_config_qt/system.cpp index a86abb7bb..8ef5a930b 100644 --- a/code/ryzom/tools/client/client_config_qt/system.cpp +++ b/code/ryzom/tools/client/client_config_qt/system.cpp @@ -162,7 +162,7 @@ void CSystem::GetVideoModes( std::vector< CVideoMode > &dst, NL3D::IDriver *driv for( std::vector< NL3D::GfxMode >::iterator itr = modes.begin(); itr != modes.end(); ++itr ) { - if( ( itr->Width >= 800 ) && ( itr->Height >= 600 ) && ( itr->Depth == 32 ) && ( itr->Frequency >= 60 ) ) + if( ( itr->Width >= 800 ) && ( itr->Height >= 600 ) && ( itr->Depth >= 16 ) ) { CVideoMode mode; mode.depth = itr->Depth; From b68f2172742d29a2f03c83eddd1bcd5566f1c74f Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:28:11 +0100 Subject: [PATCH 3/8] Fixed: client_config_qt needs QXcbGlxIntegrationPlugin in static --HG-- branch : develop --- code/ryzom/tools/client/client_config_qt/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/code/ryzom/tools/client/client_config_qt/main.cpp b/code/ryzom/tools/client/client_config_qt/main.cpp index 52d3cf7bb..f298426f7 100644 --- a/code/ryzom/tools/client/client_config_qt/main.cpp +++ b/code/ryzom/tools/client/client_config_qt/main.cpp @@ -31,6 +31,7 @@ Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin) #elif defined(Q_OS_UNIX) Q_IMPORT_PLUGIN(QXcbIntegrationPlugin) + Q_IMPORT_PLUGIN(QXcbGlxIntegrationPlugin) #endif #endif From a5d3b2d461373337bc3d2351fb587ede10cbd837 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:29:23 +0100 Subject: [PATCH 4/8] Changed: Added new function getCommandOutput --HG-- branch : develop --- code/nel/include/nel/misc/common.h | 3 +++ code/nel/src/misc/common.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/code/nel/include/nel/misc/common.h b/code/nel/include/nel/misc/common.h index c2a40cc0f..10f6a97e6 100644 --- a/code/nel/include/nel/misc/common.h +++ b/code/nel/include/nel/misc/common.h @@ -349,6 +349,9 @@ std::string formatThousands(const std::string& s); /// The program will be launched in the current directory bool launchProgram (const std::string &programName, const std::string &arguments, bool log = true); +/// This function executes a program and returns output as a string +std::string getCommandOutput(const std::string &command); + /// This function kills a program using his pid (on unix, it uses the kill() POSIX function) bool killProgram(uint32 pid); diff --git a/code/nel/src/misc/common.cpp b/code/nel/src/misc/common.cpp index 8eca1d566..d2d2e5cb0 100644 --- a/code/nel/src/misc/common.cpp +++ b/code/nel/src/misc/common.cpp @@ -23,6 +23,10 @@ # include # include # include + +#define popen _popen +#define pclose _pclose + #elif defined NL_OS_MAC # include #elif defined NL_OS_UNIX @@ -32,6 +36,8 @@ # include #endif +#define MAX_LINE_WIDTH 256 + #include "nel/misc/command.h" #include "nel/misc/path.h" #include "nel/misc/i18n.h" @@ -840,6 +846,25 @@ bool launchProgram(const std::string &programName, const std::string &arguments, } +std::string getCommandOutput(const std::string &command) +{ + FILE *pipe = popen(command.c_str(), "r"); + + if (!pipe) return ""; + + char buffer[MAX_LINE_WIDTH]; + std::string result; + + while (!feof(pipe)) + { + if (fgets(buffer, MAX_LINE_WIDTH, pipe) != NULL) result += buffer; + } + + pclose(pipe); + + return result; +} + /* * Display the bits (with 0 and 1) composing a byte (from right to left) */ From 21ada78b63903c2584942ab20cd9e2a1076f34be Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:30:14 +0100 Subject: [PATCH 5/8] Changed: Display a warning when calling getModes if Display is NULL --HG-- branch : develop --- code/nel/src/3d/driver/opengl/driver_opengl_window.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 36ac67281..3c60da0c0 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2058,6 +2058,12 @@ bool CDriverGL::getModes(std::vector &modes) #elif defined (NL_OS_UNIX) + if (!_dpy) + { + nlwarning("3D: Unable to list modes because Display is NULL, did you forget to call init() ?"); + return false; + } + bool found = false; int screen = DefaultScreen(_dpy); From 75d16f7054533783d98fa860d6368fd956f18d94 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:31:34 +0100 Subject: [PATCH 6/8] Fixed: Define QT_NO_DEBUG in Release with Qt 5 also in PCH --HG-- branch : develop --- code/CMakeModules/PCHSupport.cmake | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/code/CMakeModules/PCHSupport.cmake b/code/CMakeModules/PCHSupport.cmake index dafe72a5a..fa36fd008 100644 --- a/code/CMakeModules/PCHSupport.cmake +++ b/code/CMakeModules/PCHSupport.cmake @@ -145,19 +145,22 @@ MACRO(PCH_SET_COMPILE_FLAGS _target) ENDFOREACH() ENDIF() - # Hack to define missing QT_NO_DEBUG with Qt 5.2 - IF(USE_QT5 AND _UPPER_BUILD STREQUAL "RELEASE") - LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG") - ENDIF() + # Special Qt 5 cases + IF(GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB") + # Hack to define missing QT_NO_DEBUG with Qt 5.2 + IF(_UPPER_BUILD STREQUAL "RELEASE") + LIST(APPEND GLOBAL_DEFINITIONS " -DQT_NO_DEBUG") + ENDIF() - # Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIE - IF(Qt5_POSITION_INDEPENDENT_CODE AND GLOBAL_DEFINITIONS MATCHES "QT_CORE_LIB") - SET(_USE_PIE ON) - ENDIF() + # Qt5_POSITION_INDEPENDENT_CODE should be true if Qt was compiled with PIE + IF(Qt5_POSITION_INDEPENDENT_CODE) + SET(_USE_PIE ON) + ENDIF() - IF(_USE_PIE) - LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") - LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIC}") + IF(_USE_PIE) + LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIE}") + LIST(APPEND _FLAGS " ${CMAKE_CXX_COMPILE_OPTIONS_PIC}") + ENDIF() ENDIF() LIST(APPEND _FLAGS " ${GLOBAL_DEFINITIONS}") From cbc1acfcd201d43e4756544a63f6dfb4be5069c5 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:33:03 +0100 Subject: [PATCH 7/8] Fixed: Link order with Qt 5 static under Linux --HG-- branch : develop --- code/CMakeLists.txt | 81 ++++++++++++++++++++++++++------------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index b16b2febc..65e61a8e4 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -216,41 +216,15 @@ IF(WITH_QT5) FIND_PACKAGE(Qt5LinguistTools) FIND_PACKAGE(Qt5Network) - SET(QT_LIBRARIES Qt5::Widgets Qt5::Core Qt5::Gui Qt5::Network Qt5::OpenGL Qt5::Xml) - IF(QT_STATIC) ADD_DEFINITIONS(-DQT_STATICPLUGIN) - # Core - IF(APPLE) - FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) - - FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) - FIND_LIBRARY(CARBON_FRAMEWORK Carbon) - FIND_LIBRARY(SECURITY_FRAMEWORK Security) - - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${PCRE_LIBRARY} - ${FOUNDATION_FRAMEWORK} - ${CARBON_FRAMEWORK} - ${SECURITY_FRAMEWORK}) - ENDIF() - - # Network - FIND_PACKAGE(OpenSSL REQUIRED) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) - - IF(WIN32) - SET(QT_LIBRARIES ${QT_LIBRARIES} - ${WINSDK_LIBRARY_DIR}/Crypt32.lib - ${WINSDK_LIBRARY_DIR}/WS2_32.Lib) - ENDIF() - - SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + SET(QT_LIBRARIES Qt5::Widgets) # Gui + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Gui Qt5::OpenGL) + ADD_QT_LIBRARY(PrintSupport) - ADD_QT_LIBRARY(PlatformSupport) IF(WIN32) SET(QT_LIBRARIES ${QT_LIBRARIES} @@ -280,17 +254,21 @@ IF(WITH_QT5) ADD_QT_PLUGIN(printsupport cocoaprintersupport) ADD_QT_PLUGIN(platforms qcocoa) ELSE() - FIND_LIBRARY(OPENGL_LIBRARY GL) + ADD_QT_PLUGIN(platforms qxcb) + ADD_QT_PLUGIN(xcbglintegrations qxcb-glx-integration) - SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENGL_LIBRARY}) + ADD_QT_LIBRARY(XcbQpa) + ADD_QT_LIBRARY(PlatformSupport) + SET(QT_LIBRARIES ${QT_LIBRARIES} -lX11-xcb -lXi -lSM -lICE -lxcb) + SET(QT_LIBRARIES ${QT_LIBRARIES} "${QT_LIBRARY_DIR}/libxcb-static.a") + SET(QT_LIBRARIES ${QT_LIBRARIES} -lfontconfig) + ADD_QT_LIBRARY(DBus) ENDIF() ADD_QT_PLUGIN(imageformats qgif) ADD_QT_PLUGIN(imageformats qicns) ADD_QT_PLUGIN(imageformats qico) ADD_QT_PLUGIN(imageformats qjpeg) - ADD_QT_PLUGIN(imageformats qmng) - ADD_QT_PLUGIN(imageformats qwebp) # harfbuzz is needed since Qt 5.3 IF(UNIX) @@ -312,6 +290,25 @@ IF(WITH_QT5) SET(QT_LIBRARIES ${QT_LIBRARIES} ${FREETYPE_LIB}) ENDIF() + ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + + SET(QT_LIBRARIES ${QT_LIBRARIES} ${PNG_LIBRARIES} ${JPEG_LIBRARY}) + + # Network + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Network Qt5::Xml) + + FIND_PACKAGE(OpenSSL REQUIRED) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES}) + + IF(WIN32) + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${WINSDK_LIBRARY_DIR}/Crypt32.lib + ${WINSDK_LIBRARY_DIR}/WS2_32.Lib) + ENDIF() + + # Core + SET(QT_LIBRARIES ${QT_LIBRARIES} Qt5::Core) + # pcre is needed since Qt 5.5 IF(UNIX) SET(PCRE_LIB "${QT_LIBRARY_DIR}/libqtpcre.a") @@ -322,7 +319,23 @@ IF(WITH_QT5) SET(QT_LIBRARIES ${QT_LIBRARIES} ${PCRE_LIB}) ENDIF() - ADD_QT_PLUGIN(accessible qtaccessiblewidgets) + IF(APPLE) + FIND_LIBRARY(PCRE_LIBRARY pcre16 pcre) + + FIND_LIBRARY(FOUNDATION_FRAMEWORK Foundation) + FIND_LIBRARY(CARBON_FRAMEWORK Carbon) + FIND_LIBRARY(SECURITY_FRAMEWORK Security) + + SET(QT_LIBRARIES ${QT_LIBRARIES} + ${PCRE_LIBRARY} + ${FOUNDATION_FRAMEWORK} + ${CARBON_FRAMEWORK} + ${SECURITY_FRAMEWORK}) + ELSEIF(UNIX) + SET(QT_LIBRARIES ${QT_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} -ldl) + ENDIF() + ELSE() + SET(QT_LIBRARIES Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Gui Qt5::OpenGL Qt5::Core) ENDIF() ELSE() MESSAGE(WARNING "Unable to find Qt 5") From 4a1f4cd7252770ef76e10efda6e5fdf94d69fff9 Mon Sep 17 00:00:00 2001 From: kervala Date: Fri, 25 Dec 2015 15:35:04 +0100 Subject: [PATCH 8/8] Changed: Use shared libs for X11 because API doesn't change --HG-- branch : develop --- code/nel/src/3d/driver/opengl/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/code/nel/src/3d/driver/opengl/CMakeLists.txt b/code/nel/src/3d/driver/opengl/CMakeLists.txt index 6d8efb929..18b4886ed 100644 --- a/code/nel/src/3d/driver/opengl/CMakeLists.txt +++ b/code/nel/src/3d/driver/opengl/CMakeLists.txt @@ -5,8 +5,11 @@ IF(NOT WIN32) FIND_LIBRARY(CARBON NAMES Carbon) FIND_LIBRARY(COCOA NAMES Cocoa) ELSE() + SET(OLD_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + SET(CMAKE_FIND_LIBRARY_SUFFIXES .so) FIND_PACKAGE(X11) FIND_PACKAGE(XF86VidMode) + SET(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_CMAKE_FIND_LIBRARY_SUFFIXES}) ENDIF() ENDIF() @@ -71,12 +74,12 @@ IF(UNIX AND NOT APPLE) TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${X11_Xext_LIB}) ENDIF() # libraries needed to be linked while linking to static X11 libraries - FIND_LIBRARY(XCB_LIBRARY - NAMES xcb - HINTS ${X11_LIB_SEARCH_PATH}) - IF(XCB_LIBRARY) - TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XCB_LIBRARY}) - ENDIF() +# FIND_LIBRARY(XCB_LIBRARY +# NAMES xcb +# HINTS ${X11_LIB_SEARCH_PATH}) +# IF(XCB_LIBRARY) +# TARGET_LINK_LIBRARIES(${NLDRV_OGL_LIB} ${XCB_LIBRARY}) +# ENDIF() ENDIF() IF(WITH_PCH)