diff --git a/.gitignore b/.gitignore index 35128a7b4d..d5bab2c5e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ bin/ build/ -ext/SGCT \ No newline at end of file +ext/SGCT +.DS_Store \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 81b859e460..470a23b315 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,31 +46,17 @@ endif () # Ghoul add_definitions(-DGHL_DEBUG) set(GHOUL_ROOT_DIR "${OPENSPACE_EXT_DIR}/ghoul") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${GHOUL_ROOT_DIR}/ext) include_directories("${GHOUL_ROOT_DIR}/include") add_subdirectory(${GHOUL_ROOT_DIR}) set(DEPENDENT_LIBS ${DEPENDENT_LIBS} Ghoul) -# SGCT (TODO: write cmake script) -#set(SGCT_ROOT_DIR "$ENV{SGCT_ROOT_DIR}") -#set(SGCT_ROOT_DIR "C:/Program Files/SGCT/SGCT_2.0.7") -#set(SGCT_ROOT_DIR "C:/Program Files (x86)/SGCT/SGCT_2.0.5_x86") -#set(SGCT_ROOT_DIR "C:/Program Files/SGCT/SGCT_2.0.7") +# Add ghoul ext +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${GHOUL_ROOT_DIR}/ext) -#add_definitions(-D__WIN32__) -add_definitions(-DGLEW_STATIC) -include_directories("${OPENSPACE_EXT_DIR}/sgct/include") -#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" - ${OPENSPACE_EXT_DIR}/sgct/lib/libsgct_cpp11.a - ) - -#add_subdirectory(${SGCT_ROOT_DIR}) -#set(DEPENDENT_LIBS ${DEPENDENT_LIBS} SGCT) +# SGCT +find_package(SGCT REQUIRED) +include_directories(${SGCT_INCLUDE_DIRECTORIES}) +set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${SGCT_LIBRARIES}) # GLM set(GLM_ROOT_DIR "${GHOUL_ROOT_DIR}/ext/glm") @@ -80,18 +66,18 @@ include_directories(${GLM_INCLUDE_DIRS}) # OpenGL #find_package(OpenGL REQUIRED) #include_directories(${OPENGL_INCLUDE_DIRS}) -set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${OPENGL_LIBRARIES}) +#set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${OPENGL_LIBRARIES}) # GLEW -#find_package(GLEW REQUIRED) -#include_directories(${GLEW_INCLUDE_DIRECTORIES}) +find_package(GLEW REQUIRED) +include_directories(${GLEW_INCLUDE_DIRECTORIES}) 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) +#set(DEPENDENT_LIBS ${DEPENDENT_LIBS} Lua) # Spice set(SPICE_ROOT_DIR "${OPENSPACE_EXT_DIR}/spice") @@ -99,26 +85,13 @@ include_directories("${SPICE_ROOT_DIR}/include") add_subdirectory(${SPICE_ROOT_DIR}) set(DEPENDENT_LIBS ${DEPENDENT_LIBS} Spice) -# Threads -find_library(PTHREADS_LIB pthread) -set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${PTHREADS_LIB}) - if (APPLE) include_directories(/Developer/Headers/FlatCarbon) find_library(CARBON_LIBRARY Carbon) find_library(COCOA_LIBRARY Cocoa) find_library(APP_SERVICES_LIBRARY ApplicationServices) - find_library(APPKIT_LIBRARY AppKit) - find_library(IOKIT_LIBRARY IOKit) - mark_as_advanced(CARBON_LIBRARY COCOA_LIBRARY APP_SERVICES_LIBRARY IOKIT_LIBRARY) - set(DEPENDENT_LIBS - ${DEPENDENT_LIBS} - ${CARBON_LIBRARY} - ${APPKIT_LIBRARY} - ${COCOA_LIBRARY} - ${APP_SERVICES_LIBRARY} - ${IOKIT_LIBRARY} - ) + mark_as_advanced(CARBON_LIBRARY COCOA_LIBRARY APP_SERVICES_LIBRARY) + set(DEPENDENT_LIBS ${DEPENDENT_LIBS} ${CARBON_LIBRARY} ${COCOA_LIBRARY} ${APP_SERVICES_LIBRARY}) endif () ######################################################################################### diff --git a/ext/FindSGCT.cmake b/ext/FindSGCT.cmake new file mode 100644 index 0000000000..88a30f9ddf --- /dev/null +++ b/ext/FindSGCT.cmake @@ -0,0 +1,94 @@ + + + + +# Find the library +if(WIN32) + add_definitions(-D__WIN32__) + file(GLOB SGCT_WINDOWS_PATHS "C:/Program Files/SGCT/SGCT_*") + find_path(SGCT_ROOT_DIR include/sgct.h HINTS + "${SGCT_WINDOWS_PATHS}" + ) + 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" + ) +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" + ) + find_library(SGCT_LIBRARY NAMES ${CMAKE_STATIC_LIBRARY_PREFIX}sgct_cpp11${CMAKE_STATIC_LIBRARY_SUFFIX} + HINTS "${SGCT_ROOT_DIR}/lib") + +endif() + +# make sure glew is static +add_definitions(-DGLEW_STATIC) + +if (APPLE) + find_library(FRAMEWORK_IOKit + NAMES IOKit + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH + ) + find_library(FRAMEWORK_CoreVideo + NAMES CoreVideo + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH + ) + find_library(FRAMEWORK_Cocoa + NAMES Cocoa + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH + ) + set(SGCT_DEPENDENCIES ${SGCT_DEPENDENCIES} ${FRAMEWORK_IOKit} ${FRAMEWORK_CoreVideo} ${FRAMEWORK_Cocoa}) +endif (APPLE) + +# includes +set(SGCT_INCLUDES "${SGCT_ROOT_DIR}/include") +include_directories(${SGCT_INCLUDE_DIRS}) + +# libraries +set(SGCT_INCLUDE_DIRECTORIES ${SGCT_INCLUDES}) +set(SGCT_LIBRARIES ${SGCT_DEPENDENCIES} ${SGCT_LIBRARY}) +#set(SGCT_LIBRARIES "${SGCT_LIBRARY}") + +# handle the QUIETLY and REQUIRED arguments and set SGCT_FOUND to TRUE +# if all listed variables are TRUE +find_package_handle_standard_args(SGCT DEFAULT_MSG + SGCT_LIBRARY SGCT_INCLUDES) + +mark_as_advanced(SGCT_INCLUDE_DIR SGCT_LIBRARY ) + +if(SGCT_FOUND) + MESSAGE(STATUS "SGCT found: ${SGCT_INCLUDES}/sgct.h") + MESSAGE(STATUS "SGCT SGCT_LIBRARY: ${SGCT_LIBRARY}") +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) \ No newline at end of file diff --git a/ext/ghoul b/ext/ghoul index 881aa69183..4a8e9e5408 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 881aa69183aeeff6d80eb95580b315648ea05e4e +Subproject commit 4a8e9e540894fc0ec4ec3cbbbf45e18c37872499 diff --git a/ext/spice b/ext/spice index 784478de97..1947309fea 160000 --- a/ext/spice +++ b/ext/spice @@ -1 +1 @@ -Subproject commit 784478de97c3243c9bbd668256b5e3186a85b8b3 +Subproject commit 1947309fea2f2baad3795503fdc8ecbca0575615 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index abe892d01a..bd7f9e331b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -88,5 +88,28 @@ include_directories(${HEADER_ROOT_DIR}) # hack: set(OPENSPACE_SOURCE ${OPENSPACE_SOURCE} ${OPENSPACE_EXT_DIR}/tinythread.cpp) +if (APPLE) + find_library(FRAMEWORK_IOKit + NAMES IOKit + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH + ) + find_library(FRAMEWORK_CoreVideo + NAMES CoreVideo + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH + ) + find_library(FRAMEWORK_Cocoa + NAMES Cocoa + PATHS ${CMAKE_OSX_SYSROOT}/System/Library + PATH_SUFFIXES Frameworks + NO_DEFAULT_PATH + ) + set(SGCT_DEPENDENCIES ${SGCT_DEPENDENCIES} ${FRAMEWORK_IOKit} ${FRAMEWORK_CoreVideo} ${FRAMEWORK_Cocoa}) +endif (APPLE) +#add_definitions(-framework IOKit -framework CoreVideo) + add_executable(OpenSpace ${OPENSPACE_HEADER} ${OPENSPACE_SOURCE}) target_link_libraries(OpenSpace ${DEPENDENT_LIBS}) diff --git a/src/interaction/deviceidentifier.cpp b/src/interaction/deviceidentifier.cpp index 6d9ff973a2..dec0b14c79 100644 --- a/src/interaction/deviceidentifier.cpp +++ b/src/interaction/deviceidentifier.cpp @@ -66,7 +66,7 @@ void DeviceIdentifier::scanDevices() { //numberOfButtons_[i] = sgct::Engine::getJoystickParam( GLFW_JOYSTICK_1 + i, GLFW_BUTTONS ); // joystick found - void* joystickName; + void* joystickName = NULL; if( joystickName != NULL ) { // sgct::Engine::getJoystickAxes(SGCT_JOYSTICK_1 + i, &numberOfAxes_[i]); // sgct::Engine::getJoystickButtons(SGCT_JOYSTICK_1 + i, &numberOfButtons_[i]); diff --git a/src/openspaceengine.cpp b/src/openspaceengine.cpp index 0810c4c9e5..982b2d431c 100644 --- a/src/openspaceengine.cpp +++ b/src/openspaceengine.cpp @@ -60,6 +60,8 @@ OpenSpaceEngine::~OpenSpaceEngine() { delete _configurationManager; delete _interactionHandler; delete _renderEngine; + + // TODO deallocate scriptengine when starting to use it //delete _scriptEngine; Spice::deinit(); @@ -81,6 +83,20 @@ void OpenSpaceEngine::create(int argc, char** argv, int& newArgc, char**& newArg LogManager::initialize(LogManager::LogLevel::Debug); LogMgr.addLog(new ConsoleLog); + ghoul::filesystem::FileSystem::initialize(); + +#ifdef __WIN32__ + // Windows: Binary two folders down + FileSys.registerPathToken("${BASE_PATH}", "../.."); +#else + // OS X and linux: Binary three folders down + FileSys.registerPathToken("${BASE_PATH}", "../../.."); +#endif + FileSys.registerPathToken("${SCRIPTS}", "${BASE_PATH}/scripts"); + + // OLD + //FileSys.registerPathToken("${SCRIPTS}", "${BASE_PATH}/openspace/scripts"); // FIX ME: tempoary path + _engine->_configurationManager = new ghoul::ConfigurationManager; _engine->_configurationManager->initialize(); @@ -88,14 +104,18 @@ void OpenSpaceEngine::create(int argc, char** argv, int& newArgc, char**& newArg newArgv = new char*[3]; newArgv[0] = "prog"; newArgv[1] = "-config"; +#ifdef __WIN32__ + // Windows uses fixed path to OpenSpace data + #warning "Fixed path" + newArgv[2] = "C:/openspace/config/single.xml"; // FIX ME: tempoary path +#else + // OS X and Linux uses local path to OpenSpace data newArgv[2] = "../../../config/single.xml"; +#endif - ghoul::filesystem::FileSystem::initialize(); - FileSys.registerPathToken("${BASE_PATH}", "../../.."); - //FileSys.registerPathToken("${BASE_PATH}", "../.."); - FileSys.registerPathToken("${SCRIPTS}", "${BASE_PATH}/scripts"); + _engine->_renderEngine = new RenderEngine; @@ -108,9 +128,9 @@ void OpenSpaceEngine::destroy() { } bool OpenSpaceEngine::initialize() { - _configurationManager->initialize(); - _configurationManager->loadConfiguration("${SCRIPTS}/config.lua"); - _configurationManager->loadConfiguration("${SCRIPTS}/config2.lua"); + //_configurationManager->initialize(); + //_configurationManager->loadConfiguration("${SCRIPTS}/config.lua"); + //_configurationManager->loadConfiguration("${SCRIPTS}/config2.lua"); Time::init(); Spice::init(); @@ -229,7 +249,7 @@ void RenderEngine::decode() { sgct::SharedDouble *shDouble = new sgct::SharedDouble(); // sync the time - sharedDataInstance_->readDouble(shDouble); + sharedDataInstance_->Double(shDouble); masterTime_ = shDouble->getVal(); // check that the camera has been allocated diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index fe3fb015b6..bd35f6c2ee 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -144,8 +144,8 @@ void RenderEngine::postSynchronizationPreDraw() { _mainCamera->compileViewRotationMatrix(); // update and evaluate the scene starting from the root node - _sceneGraph->update(); - _sceneGraph->evaluate(_mainCamera); + //_sceneGraph->update(); + //_sceneGraph->evaluate(_mainCamera); } void RenderEngine::render() { @@ -158,11 +158,11 @@ void RenderEngine::render() { view = glm::translate(view, eyePosition); // make sure the eye is in the center // setup the camera for the current frame - _mainCamera->setViewProjectionMatrix(projection*view); + //_mainCamera->setViewProjectionMatrix(projection*view); // render the scene starting from the root node - _sceneGraph->render(_mainCamera); - + //_sceneGraph->render(_mainCamera); + /* if (sgct::Engine::instance()->isMaster()) { const glm::vec2 scaling = _mainCamera->getScaling(); const glm::vec3 viewdirection = _mainCamera->getViewDirection(); @@ -189,6 +189,7 @@ void RenderEngine::render() { "Distance to origin: (%.15f, %.2f)", pssl[0], pssl[1] ); } + */ } SceneGraph* RenderEngine::sceneGraph() { diff --git a/src/scenegraph/scenegraphnode.cpp b/src/scenegraph/scenegraphnode.cpp index b5dbd6c31d..3af3cfba86 100644 --- a/src/scenegraph/scenegraphnode.cpp +++ b/src/scenegraph/scenegraphnode.cpp @@ -70,7 +70,8 @@ void SceneGraphNode::update() { void SceneGraphNode::evaluate(const Camera *camera, const psc & parentPosition) { const psc thisPosition = parentPosition + position_; - const psc toCamera = thisPosition - camera->getPosition(); + const psc camPos = camera->getPosition(); + const psc toCamera = thisPosition - camPos; // init as not visible boundingSphereVisible_ = true;