From 4a61e0f1d73190da62b37a5174a8f564136f79a7 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 24 Feb 2014 20:56:30 +0100 Subject: [PATCH 1/3] Modify FindSGCT.cmake file - Change tabs to spaces - enable automatic detection of highest SGCT version - enable automatic detection of Visual Studio version --- ext/FindSGCT.cmake | 110 ++++++++++++++++++++++++++------------------- 1 file changed, 64 insertions(+), 46 deletions(-) diff --git a/ext/FindSGCT.cmake b/ext/FindSGCT.cmake index 678d540b91..1e44d911bd 100644 --- a/ext/FindSGCT.cmake +++ b/ext/FindSGCT.cmake @@ -1,7 +1,5 @@ - # Find the library if(WIN32) - # Check for visual studio if(NOT MSVC) message(FATAL_ERROR "Only visual studio supported!") @@ -11,19 +9,26 @@ if(WIN32) add_definitions(-D__WIN32__) # search for SGCT, 64-bit and 32-bit - if(CMAKE_CL_64) + if (CMAKE_CL_64) set(SGCT_PATH "C:/Program Files/SGCT") - else(CMAKE_CL_64) + else (CMAKE_CL_64) set(SGCT_PATH "C:/Program Files (x86)/SGCT") - endif(CMAKE_CL_64) + endif (CMAKE_CL_64) file(GLOB SGCT_WINDOWS_PATHS "${SGCT_PATH}/SGCT_*") - FOREACH(path ${SGCT_WINDOWS_PATHS}) + # sort and reverse the list to find the most recent (a.k.a. highest number) version + list(SORT SGCT_WINDOWS_PATHS) + list(REVERSE SGCT_WINDOWS_PATHS) + + foreach(path ${SGCT_WINDOWS_PATHS}) find_path(SGCT_ROOT_DIR include/sgct.h HINTS "${path}" ) - ENDFOREACH(path) - + if (SGCT_ROOT_DIR) + break() + endif () + endforeach(path) + # Check if found the SGCT root directory if(NOT SGCT_ROOT_DIR) message(FATAL_ERROR "Could not locate SGCT in ${SGCT_PATH}!") @@ -31,42 +36,55 @@ if(WIN32) find_path(SGCT_ROOT_DIR include/sgct.h HINTS - "${SGCT_WINDOWS_PATHS}" - ) - - # Find the sgct library + "${SGCT_WINDOWS_PATHS}" + ) + + # construct the correct library path + if (MSVC10) + set(SGCT_LIBRARY_FOLDER "${SGCT_ROOT_DIR}/lib/msvc10") + elseif (MSVC11) + set(SGCT_LIBRARY_FOLDER "${SGCT_ROOT_DIR}/lib/msvc11") + elseif (MSVC12) + set(SGCT_LIBRARY_FOLDER "${SGCT_ROOT_DIR}/lib/msvc12") + endif (MSVC10) + + if (CMAKE_CL_64) + set(SGCT_LIBRARY_FOLDER "${SGCT_LIBRARY_FOLDER}_x64") + endif (CMAKE_CL_64) + + # Find the sgct library set(SGCT_LIBRARY "ws2_32.lib" - optimized "${SGCT_ROOT_DIR}/lib/msvc11_x64/sgct.lib" - debug "${SGCT_ROOT_DIR}/lib/msvc11_x64/sgctd.lib" + optimized "${SGCT_LIBRARY_FOLDER}/sgct.lib" + debug "${SGCT_LIBRARY_FOLDER}/sgctd.lib" ) else() - find_path(SGCT_ROOT_DIR include/sgct.h HINTS - "/opt/local/include/sgct" - "/usr/local/include/sgct" - "/usr/include/sgct" - "/opt/local" - "/usr/local" - "/usr" - ) + find_path(SGCT_ROOT_DIR include/sgct.h HINTS + "/opt/local/include/sgct" + "/usr/local/include/sgct" + "/usr/include/sgct" + "/opt/local" + "/usr/local" + "/usr" + ) if(NOT SGCT_ROOT_DIR) message(FATAL_ERROR "Could not locate SGCT!") endif(NOT SGCT_ROOT_DIR) - - # OS X has cpp11 support - if (APPLE) - set(SGCT_NAME "sgct_cpp11") - else(APPLE) - set(SGCT_NAME "sgct") - endif(APPLE) - # check if debug or release version of sgct should be used - if(CMAKE_BUILD_TYPE MATCHES DEBUG) - set(SGCT_NAME "${SGCT_NAME}d") - endif(CMAKE_BUILD_TYPE MATCHES DEBUG) - - # Find the sgct library - find_library(SGCT_LIBRARY NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}${SGCT_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} + # OS X has cpp11 support + if (APPLE) + set(SGCT_NAME "sgct_cpp11") + else(APPLE) + set(SGCT_NAME "sgct") + endif(APPLE) + + # check if debug or release version of sgct should be used + if(CMAKE_BUILD_TYPE MATCHES DEBUG) + set(SGCT_NAME "${SGCT_NAME}d") + endif(CMAKE_BUILD_TYPE MATCHES DEBUG) + + # Find the sgct library + find_library(SGCT_LIBRARY NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}${SGCT_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} HINTS "${SGCT_ROOT_DIR}/lib") endif() @@ -97,15 +115,15 @@ if (APPLE) endif (APPLE) if(UNIX AND NOT APPLE) - find_package(XRandR) - find_package(Xi) - if(NOT XRANDR_FOUND) - message(FATAL_ERROR "XRandR not found!") - endif(NOT XRANDR_FOUND) - if(NOT XI_FOUND) - message(FATAL_ERROR "Xi not found!") - endif(NOT XI_FOUND) - set(SGCT_DEPENDENCIES ${SGCT_DEPENDENCIES} ${XRANDR_LIBRARIES} ${XI_LIBRARIES}) + find_package(XRandR) + find_package(Xi) + if(NOT XRANDR_FOUND) + message(FATAL_ERROR "XRandR not found!") + endif(NOT XRANDR_FOUND) + if(NOT XI_FOUND) + message(FATAL_ERROR "Xi not found!") + endif(NOT XI_FOUND) + set(SGCT_DEPENDENCIES ${SGCT_DEPENDENCIES} ${XRANDR_LIBRARIES} ${XI_LIBRARIES}) endif(UNIX AND NOT APPLE) # includes @@ -127,7 +145,7 @@ mark_as_advanced(SGCT_INCLUDE_DIR SGCT_LIBRARY ) if(SGCT_FOUND) MESSAGE(STATUS "SGCT found: ${SGCT_INCLUDES}/sgct.h") else() - MESSAGE(FATAL_ERROR "SGCT not found!") + MESSAGE(FATAL_ERROR "SGCT not found!") endif(SGCT_FOUND) From 880bb377f63631d9f9e108444fc3f0407bd9f26e Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Tue, 25 Feb 2014 20:56:35 -0500 Subject: [PATCH 2/3] Updated OpenSpace to use the updated Ghoul ConfigurationManager - Removed unnecessary comments from CMakeLists - Updated OpenSpace engine to load ConfigurationManager - Added two basic lua configuration scripts --- CMakeLists.txt | 10 +--------- ext/FindSGCT.cmake | 16 ---------------- ext/ghoul | 2 +- scripts/DefaultConfig.lua | 18 ++++++++++++++++++ scripts/ExtraConfig.lua | 14 ++++++++++++++ src/CMakeLists.txt | 1 + src/openspaceengine.cpp | 12 +++++++----- 7 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 scripts/DefaultConfig.lua create mode 100644 scripts/ExtraConfig.lua diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ea957db0c..87335696f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ set(OPENSPACE_EXT_DIR "${OPENSPACE_BASE_DIR}/ext") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${OPENSPACE_EXT_DIR}) -# Make sure abuild type is set. Default is Debug. +# Make sure a build type is set. Default is Debug. if(NOT CMAKE_BUILD_TYPE) set( CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." @@ -51,7 +51,6 @@ endif () ######################################################################################### # Ghoul -add_definitions(-DGHL_DEBUG) set(GHOUL_ROOT_DIR "${OPENSPACE_EXT_DIR}/ghoul") include_directories("${GHOUL_ROOT_DIR}/include") add_subdirectory(${GHOUL_ROOT_DIR}) @@ -70,11 +69,6 @@ set(GLM_ROOT_DIR "${GHOUL_ROOT_DIR}/ext/glm") find_package(GLM REQUIRED) include_directories(${GLM_INCLUDE_DIRS}) -# OpenGL -#find_package(OpenGL REQUIRED) -#include_directories(${OPENGL_INCLUDE_DIRS}) -#set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${OPENGL_LIBRARIES}) - # GLEW find_package(GLEW REQUIRED) include_directories(${GLEW_INCLUDE_DIRECTORIES}) @@ -83,8 +77,6 @@ set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${GLEW_LIBRARIES}) # Lua set(LUA_ROOT_DIR "${GHOUL_ROOT_DIR}/ext/lua") include_directories("${LUA_ROOT_DIR}/include") -#add_subdirectory(${LUA_ROOT_DIR}) -#set(DEPENDENT_LIBS ${DEPENDENT_LIBS} Lua) # Spice set(SPICE_ROOT_DIR "${OPENSPACE_EXT_DIR}/spice") diff --git a/ext/FindSGCT.cmake b/ext/FindSGCT.cmake index 678d540b91..1329144e77 100644 --- a/ext/FindSGCT.cmake +++ b/ext/FindSGCT.cmake @@ -130,19 +130,3 @@ else() MESSAGE(FATAL_ERROR "SGCT not found!") endif(SGCT_FOUND) - - - - - -# OLD STUFF. REMOVE WHEN ABOVE WORKS -#set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${SGCT_ROOT_DOR}/bin/lib/msvc11) -#set(DEPENDENT_LIBS -# ${DEPENDENT_LIBS} -# "Ws2_32.lib" -# optimized "${SGCT_ROOT_DIR}/lib/msvc11_x64/sgct.lib" -# debug "${SGCT_ROOT_DIR}/lib/msvc11_x64/sgctd.lib" -# ) - -#add_subdirectory(${SGCT_ROOT_DIR}) -#set(DEPENDENT_LIBS ${DEPENDENT_LIBS} SGCT) diff --git a/ext/ghoul b/ext/ghoul index 9a8e9f1112..7cb0200c68 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 9a8e9f11124cd28a62ce7078e54de847d9ecbc6d +Subproject commit 7cb0200c683a9bc22d7168309d0cfbe305a5fd3e diff --git a/scripts/DefaultConfig.lua b/scripts/DefaultConfig.lua new file mode 100644 index 0000000000..52b8da7ad9 --- /dev/null +++ b/scripts/DefaultConfig.lua @@ -0,0 +1,18 @@ + +config = +{ + level1_string = "music1", + level1_integer = 2332, + level1_dictionary = + { + level2_string = "stuff", + level2_integer = 32, + level2_dictionary = { + level3_string = "levels", + level3_integer = 323232 + } + }, + level2_double = 3.4, + level2_boolean = true + +} \ No newline at end of file diff --git a/scripts/ExtraConfig.lua b/scripts/ExtraConfig.lua new file mode 100644 index 0000000000..23d1dc5203 --- /dev/null +++ b/scripts/ExtraConfig.lua @@ -0,0 +1,14 @@ + + +configuration = +{ + level1_string = "music2", + level1_lyrics = "This is not, the greatest lyrics in the world. This is just a tribute", + level1_secrets = + { + secret_stuff1 = "Password", + secret_stuff2 = "123456", + }, + level2_double = 4.3 + +} \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b4240c1302..d531d16afb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -87,6 +87,7 @@ include_directories(${HEADER_ROOT_DIR}) # hack: set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${OPENSPACE_EXT_DIR}/tinythread.cpp) +include_directories(${GHOUL_ROOT_DIR}/ext/boost) if (APPLE) find_library(FRAMEWORK_IOKit diff --git a/src/openspaceengine.cpp b/src/openspaceengine.cpp index 69215a57cf..ca51279e2a 100644 --- a/src/openspaceengine.cpp +++ b/src/openspaceengine.cpp @@ -35,6 +35,7 @@ #include #include +#include using namespace ghoul::filesystem; using namespace ghoul::logging; @@ -80,7 +81,7 @@ void OpenSpaceEngine::create(int argc, char** argv, int& newArgc, char**& newArg assert(_engine == nullptr); _engine = new OpenSpaceEngine; - LogManager::initialize(LogManager::LogLevel::Debug); + LogManager::initialize(LogManager::LogLevel::Debug, true); LogMgr.addLog(new ConsoleLog); ghoul::filesystem::FileSystem::initialize(); @@ -119,12 +120,13 @@ void OpenSpaceEngine::create(int argc, char** argv, int& newArgc, char**& newArg newArgv[2] = "../config/single.xml"; #endif + // Load the configurationmanager with the default configuration + ghoul::ConfigurationManager configuration; + configuration.initialize(absPath("${SCRIPTS}/DefaultConfig.lua")); + configuration.loadConfiguration(absPath("${SCRIPTS}/ExtraConfig.lua")); - - - + // Create the renderenginge object _engine->_renderEngine = new RenderEngine; - _engine->_interactionHandler = new InteractionHandler; } From 61a25977cd640cc417b81da0533ad777314e91a7 Mon Sep 17 00:00:00 2001 From: Jonas Strandstedt Date: Wed, 26 Feb 2014 10:41:16 -0500 Subject: [PATCH 3/3] Updated openspaceengine.cpp to use updated ConfigurationManager - Updated src/openspaceengine.cpp to utilize both lua configuration file and lua configuration script - Changed scripts/DefaultConfig.lua to be a lua configuration - Renamned scripts/ExtraConfigScript.lua to be a lua configuration script --- ext/ghoul | 2 +- scripts/DefaultConfig.lua | 2 -- scripts/ExtraConfig.lua | 14 -------------- scripts/ExtraConfigScript.lua | 15 +++++++++++++++ src/openspaceengine.cpp | 2 +- 5 files changed, 17 insertions(+), 18 deletions(-) delete mode 100644 scripts/ExtraConfig.lua create mode 100644 scripts/ExtraConfigScript.lua diff --git a/ext/ghoul b/ext/ghoul index 7cb0200c68..7ee41ec880 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 7cb0200c683a9bc22d7168309d0cfbe305a5fd3e +Subproject commit 7ee41ec88007ca67bdce39d1b9dd7378c28db1ba diff --git a/scripts/DefaultConfig.lua b/scripts/DefaultConfig.lua index 52b8da7ad9..3e0738115a 100644 --- a/scripts/DefaultConfig.lua +++ b/scripts/DefaultConfig.lua @@ -1,5 +1,3 @@ - -config = { level1_string = "music1", level1_integer = 2332, diff --git a/scripts/ExtraConfig.lua b/scripts/ExtraConfig.lua deleted file mode 100644 index 23d1dc5203..0000000000 --- a/scripts/ExtraConfig.lua +++ /dev/null @@ -1,14 +0,0 @@ - - -configuration = -{ - level1_string = "music2", - level1_lyrics = "This is not, the greatest lyrics in the world. This is just a tribute", - level1_secrets = - { - secret_stuff1 = "Password", - secret_stuff2 = "123456", - }, - level2_double = 4.3 - -} \ No newline at end of file diff --git a/scripts/ExtraConfigScript.lua b/scripts/ExtraConfigScript.lua new file mode 100644 index 0000000000..00eeec55f1 --- /dev/null +++ b/scripts/ExtraConfigScript.lua @@ -0,0 +1,15 @@ +musicname = "music2" +lyrics = "This is not, the greatest lyrics in the world. This is just a tribute" + +configuration = +{ + level1_string = musicname, + level1_lyrics = lyrics, + level1_secrets = + { + secret_stuff1 = "Password", + secret_stuff2 = "123456", + }, + level2_double = 4.3 + +} \ No newline at end of file diff --git a/src/openspaceengine.cpp b/src/openspaceengine.cpp index ca51279e2a..6ae3ed6667 100644 --- a/src/openspaceengine.cpp +++ b/src/openspaceengine.cpp @@ -123,7 +123,7 @@ void OpenSpaceEngine::create(int argc, char** argv, int& newArgc, char**& newArg // Load the configurationmanager with the default configuration ghoul::ConfigurationManager configuration; configuration.initialize(absPath("${SCRIPTS}/DefaultConfig.lua")); - configuration.loadConfiguration(absPath("${SCRIPTS}/ExtraConfig.lua")); + configuration.loadConfiguration(absPath("${SCRIPTS}/ExtraConfigScript.lua"), false); // Create the renderenginge object _engine->_renderEngine = new RenderEngine;