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..7bf69ff4bb 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,22 +145,6 @@ 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) - - - - - -# 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 c23d35729e..b42688358e 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit c23d35729efe1a662f43efbf67355b523e022fd9 +Subproject commit b42688358eb8b36cf665d068239a94df484b626f diff --git a/scripts/DefaultConfig.lua b/scripts/DefaultConfig.lua new file mode 100644 index 0000000000..3e0738115a --- /dev/null +++ b/scripts/DefaultConfig.lua @@ -0,0 +1,16 @@ +{ + 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/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/shaders/singlepassraycaster.frag b/shaders/singlepassraycaster.frag index 0aa3b04703..18158195bd 100644 --- a/shaders/singlepassraycaster.frag +++ b/shaders/singlepassraycaster.frag @@ -42,8 +42,7 @@ bool IntersectBox(Ray r, AABB aabb, out float t0, out float t1) return t0 <= t1; } -void main() -{ +void main() { vec3 rayDirection; rayDirection.xy = 2.0 * gl_FragCoord.xy / WindowSize - 1.0; rayDirection.z = -FocalLength; 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 f17db01ab6..f9e74cc500 100644 --- a/src/openspaceengine.cpp +++ b/src/openspaceengine.cpp @@ -37,6 +37,7 @@ #include #include +#include using namespace ghoul::filesystem; using namespace ghoul::logging; @@ -82,7 +83,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(); @@ -121,12 +122,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}/ExtraConfigScript.lua"), false); - - - + // Create the renderenginge object _engine->_renderEngine = new RenderEngine; - _engine->_interactionHandler = new InteractionHandler; } diff --git a/src/rendering/volumeraycaster.cpp b/src/rendering/volumeraycaster.cpp index 38c9b9474c..5a725671ac 100644 --- a/src/rendering/volumeraycaster.cpp +++ b/src/rendering/volumeraycaster.cpp @@ -61,7 +61,7 @@ void VolumeRaycaster::initialize() { glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind buffer glBindVertexArray(0); //unbind array -// myBox = new sgct_utils::SGCTBox(1.0f, sgct_utils::SGCTBox::Regular); + myBox = new sgct_utils::SGCTBox(1.0f, sgct_utils::SGCTBox::Regular); // ------ VOLUME READING ---------------- const char* filename = absPath("${BASE_PATH}/openspace-data/skull_256x256x256_8.raw").c_str(); @@ -119,6 +119,7 @@ void VolumeRaycaster::initialize() { _singlepassProgram->setUniform("WindowSize", glm::vec2(x,y)); _singlepassProgram->setUniform("Density", 2); + sgct::Engine::instance()->setKeyboardCallbackFunction(keyCallback); // ------ SETUP FBO --------------------- _fbo = new FramebufferObject(); @@ -158,81 +159,80 @@ void VolumeRaycaster::render() { glm::mat4 scene_mat = glm::rotate( glm::mat4(1.0f), static_cast( curr_time.getVal() ) * speed, glm::vec3(0.0f, 1.0f, 0.0f)); glm::mat4 modelViewProjectionMatrix = sgct::Engine::instance()->getActiveModelViewProjectionMatrix() * scene_mat; -//// ------ TWO PASS ---------------------- -//// ------ DRAW TO FBO ------------------- -// _sgctFBO = FramebufferObject::getActiveObject(); // Save SGCTs main FBO -// _fbo->activate(); -// _fboProgram->activate(); -// _fboProgram->setUniform("modelViewProjection", modelViewProjectionMatrix); -// -//// Draw backface -// glDrawBuffer(GL_COLOR_ATTACHMENT0); -// glClearColor(0.2f, 0.2f, 0.2f, 0); -// glClear(GL_COLOR_BUFFER_BIT); -// glEnable(GL_CULL_FACE); -// glCullFace(GL_FRONT); -// myBox->draw(); -// glDisable(GL_CULL_FACE); -// -//// Draw frontface -// glDrawBuffer(GL_COLOR_ATTACHMENT1); -// glClear(GL_COLOR_BUFFER_BIT); -// glClearColor(0.2f, 0.2f, 0.2f, 0); -// glEnable(GL_CULL_FACE); -// glCullFace(GL_BACK); -// myBox->draw(); -// glDisable(GL_CULL_FACE); -// -// _fboProgram->deactivate(); -// _fbo->deactivate(); -// -//// ------ DRAW TO SCREEN ---------------- -// glBindFramebuffer(GL_FRAMEBUFFER, _sgctFBO); // Re-bind SGCTs main FBO -// _twopassProgram->activate(); -// _twopassProgram->setUniform("stepSize", _stepSize); -// -//// Set textures -// glActiveTexture(GL_TEXTURE0); -// _backTexture->bind(); -// glActiveTexture(GL_TEXTURE1); -// _frontTexture->bind(); -// glActiveTexture(GL_TEXTURE2); -// _volume->bind(); -// -//// Draw screenquad -// glClearColor(0.2f, 0.2f, 0.2f, 0); -// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); -// glBindVertexArray(vertexArray); -// glDrawArrays(GL_TRIANGLES, 0, 6); -// glBindVertexArray(0); -// -// _twopassProgram->deactivate(); +// ------ TWO PASS ---------------------- +// ------ DRAW TO FBO ------------------- + _sgctFBO = FramebufferObject::getActiveObject(); // Save SGCTs main FBO + _fbo->activate(); + _fboProgram->activate(); + _fboProgram->setUniform("modelViewProjection", modelViewProjectionMatrix); -// ------ SINGLE PASS ------------------- - glm::mat4 modelView = sgct::Engine::instance()->getActiveModelViewMatrix(); - glm::vec3 eyePos = *sgct::Engine::instance()->getUserPtr()->getPosPtr(); - _singlepassProgram->setUniform("modelViewProjection", modelViewProjectionMatrix); - _singlepassProgram->setUniform("Modelview", modelView); - _singlepassProgram->setUniform("RayOrigin", glm::transpose(modelView)*glm::vec4(eyePos, 1.0)); - _singlepassProgram->setUniform("ProjectionMatrix", sgct::Engine::instance()->getActiveProjectionMatrix()); - _singlepassProgram->setUniform("ViewMatrix", sgct::Engine::instance()->getActiveViewMatrix()); - - CubeCenterVbo = CreatePointVbo(0, 0, 0); - glBindBuffer(GL_ARRAY_BUFFER, CubeCenterVbo); - GLuint SlotPosition = 5; - glEnableVertexAttribArray(SlotPosition); - glVertexAttribPointer(SlotPosition, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); - glEnableVertexAttribArray(SlotPosition); +// Draw backface + glDrawBuffer(GL_COLOR_ATTACHMENT0); glClearColor(0.2f, 0.2f, 0.2f, 0); glClear(GL_COLOR_BUFFER_BIT); - _singlepassProgram->activate(); + glEnable(GL_CULL_FACE); + glCullFace(GL_FRONT); + myBox->draw(); + glDisable(GL_CULL_FACE); +// Draw frontface + glDrawBuffer(GL_COLOR_ATTACHMENT1); + glClear(GL_COLOR_BUFFER_BIT); + glClearColor(0.2f, 0.2f, 0.2f, 0); + glEnable(GL_CULL_FACE); + glCullFace(GL_BACK); + myBox->draw(); + glDisable(GL_CULL_FACE); + + _fboProgram->deactivate(); + _fbo->deactivate(); + +// ------ DRAW TO SCREEN ---------------- + glBindFramebuffer(GL_FRAMEBUFFER, _sgctFBO); // Re-bind SGCTs main FBO + _twopassProgram->activate(); + _twopassProgram->setUniform("stepSize", _stepSize); + +// Set textures + glActiveTexture(GL_TEXTURE0); + _backTexture->bind(); + glActiveTexture(GL_TEXTURE1); + _frontTexture->bind(); glActiveTexture(GL_TEXTURE2); _volume->bind(); - glDrawArrays(GL_POINTS, 0, 1); +// Draw screenquad + glClearColor(0.2f, 0.2f, 0.2f, 0); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + glBindVertexArray(vertexArray); + glDrawArrays(GL_TRIANGLES, 0, 6); + glBindVertexArray(0); - _singlepassProgram->deactivate(); + _twopassProgram->deactivate(); + +//// ------ SINGLE PASS ------------------- +// glm::mat4 modelView = sgct::Engine::instance()->getActiveModelViewMatrix(); +// glm::vec3 eyePos = *sgct::Engine::instance()->getUserPtr()->getPosPtr(); +// _singlepassProgram->setUniform("modelViewProjection", modelViewProjectionMatrix); +// _singlepassProgram->setUniform("Modelview", modelView); +// _singlepassProgram->setUniform("RayOrigin", glm::transpose(modelView)*glm::vec4(eyePos, 1.0)); +// _singlepassProgram->setUniform("ProjectionMatrix", sgct::Engine::instance()->getActiveProjectionMatrix()); +// _singlepassProgram->setUniform("ViewMatrix", sgct::Engine::instance()->getActiveViewMatrix()); +// _singlepassProgram->activate(); +// +// glBindBuffer(GL_ARRAY_BUFFER, CubeCenterVbo); +// GLuint SlotPosition = 5; +// glEnableVertexAttribArray(SlotPosition); +// glVertexAttribPointer(SlotPosition, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), 0); +// glEnableVertexAttribArray(SlotPosition); +// glClearColor(0.2f, 0.2f, 0.2f, 0); +// glClear(GL_COLOR_BUFFER_BIT); +// +// glActiveTexture(GL_TEXTURE2); +// _volume->bind(); +// +// glDrawArrays(GL_POINTS, 0, 1); +// +// _singlepassProgram->deactivate(); } Texture* VolumeRaycaster::createVolumetexture(const char *filename, glm::ivec3 dimensions) {