fixed, successful build

This commit is contained in:
Ivan
2022-01-21 15:25:51 +02:00
parent 91a872376a
commit a0ef3ea19e
420 changed files with 44 additions and 77718 deletions

View File

@@ -37,7 +37,7 @@ LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
set(OpenCV_DIR C:/Users/iscaLab_admin/Repos/opencv/build)
set(Boost_INCLUDE_DIR C:/Users/iscaLab_admin/Repos/boost_1_78_0)
include_directories(C:/Users/iscaLab_admin/Repos/boost_1_78_0)
set(Pangolin_DIR C:/Users/iscaLab_admin/Repos/ORB_SLAM3-1.0-release/Thirdparty/Pangolin/build)
find_package(OpenCV 4.4)
if(NOT OpenCV_FOUND)

View File

@@ -1,2 +0,0 @@
DisableFormat: true
SortIncludes: false

View File

@@ -1,3 +0,0 @@
.DS_Store
CMakeLists.txt.user
build*

View File

@@ -1,3 +0,0 @@
[submodule "external/pybind11"]
path = external/pybind11
url = https://github.com/pybind/pybind11.git

View File

@@ -1,30 +0,0 @@
sudo: required
dist: xenial
before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt -qq update ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt install -qq --no-install-suggests --no-install-recommends libeigen3-dev libglew-dev libc++-dev libwayland-dev libxkbcommon-dev wayland-protocols libegl1-mesa-dev; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv versions && pyenv global system 3.7; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install eigen glew ; fi
language: cpp
matrix:
include:
- os: linux
compiler: gcc
env: PARALLEL_BUILD="-- -j 8"
- os: linux
compiler: clang
env: PARALLEL_BUILD="-- -j 8"
- os: osx
env: PARALLEL_BUILD="-- -j 8"
- os: windows
env: PARALLEL_BUILD="--parallel 8"
script:
- mkdir build
- cd build
- cmake -D CMAKE_BUILD_TYPE=Release ..
- cmake --build . $PARALLEL_BUILD

View File

@@ -1,109 +0,0 @@
cmake_minimum_required(VERSION 2.8.12)
project("Pangolin")
set(PANGOLIN_VERSION_MAJOR 0)
set(PANGOLIN_VERSION_MINOR 6)
set(PANGOLIN_VERSION ${PANGOLIN_VERSION_MAJOR}.${PANGOLIN_VERSION_MINOR})
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/")
# Platform configuration vars
include(SetPlatformVars)
SET(CPACK_GENERATOR "DEB")
SET(CPACK_DEBIAN_PACKAGE_MAINTAINER "Steven Lovegrove")
SET(CPACK_PACKAGE_VERSION_MAJOR ${PANGOLIN_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${PANGOLIN_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH "0")
include(CPack)
option( BUILD_TESTS "Build Tests" ON )
option( BUILD_TOOLS "Build Examples" ON )
option( BUILD_EXAMPLES "Build Tools" ON )
set (CMAKE_CXX_STANDARD 14)
if(_WIN_)
option( BUILD_SHARED_LIBS "Build Shared Library" OFF)
option( BUILD_EXTERN_GLEW "Automatically download, build and compile GLEW" ON)
option( BUILD_EXTERN_LIBPNG "Automatically download, build and compile libpng" ON)
option( BUILD_EXTERN_LIBJPEG "Automatically download, build and compile libjpeg" ON)
option( MSVC_USE_STATIC_CRT "Use static C Runtime with MSVC, /MT instead of /MD" ON)
# Make sure there are no erroneous C Runtime flags
list(APPEND FLAG_VARS
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
)
if(MSVC_USE_STATIC_CRT)
foreach(FLAG_VAR ${FLAG_VARS})
string(REGEX REPLACE "/MD" "/MT" NEW_FLAGS "${${FLAG_VAR}}")
set(${FLAG_VAR} "${NEW_FLAGS}" CACHE STRING "" FORCE)
endforeach()
else()
foreach(FLAG_VAR ${FLAG_VARS})
string(REGEX REPLACE "/MT" "/MD" NEW_FLAGS "${${FLAG_VAR}}")
set(${FLAG_VAR} "${NEW_FLAGS}" CACHE STRING "" FORCE)
endforeach()
endif()
else()
option( BUILD_SHARED_LIBS "Build Shared Library" ON)
endif()
if(NOT MSVC)
set( CMAKE_CXX_FLAGS "-Wall -Wextra ${CMAKE_CXX_FLAGS}" )
endif()
if(ANDROID)
set(ANDROID_PACKAGE_NAME "com.github.stevenlovegrove.pangolin")
include(AndroidUtils)
endif()
if(ANDROID OR IOS)
set(HAVE_GLES 1)
option(BUILD_FOR_GLES_2 "Build for OpenGL ES 2 instead of ES 1" ON )
if(BUILD_FOR_GLES_2)
set(HAVE_GLES_2 1)
endif()
endif()
if(_OSX_)
set(CMAKE_MACOSX_RPATH ON)
endif()
# Overide with cmake -DCMAKE_BUILD_TYPE=Debug {dir}
if( NOT CMAKE_BUILD_TYPE AND NOT _WIN_ )
message("Build type not set (defaults to release)")
message("-DCMAKE_BUILD_TYPE=Debug for debug")
set( CMAKE_BUILD_TYPE Release )
endif()
string(TOLOWER ${PROJECT_NAME} LIBRARY_NAME)
# make an uninstall target
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY
)
add_custom_target(pangolin_uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
add_subdirectory("external")
add_subdirectory("src")
if(BUILD_TESTS)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory("test")
endif()
if(BUILD_TOOLS)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory(tools)
endif()
if(BUILD_EXAMPLES)
set(Pangolin_DIR ${Pangolin_BINARY_DIR}/src)
add_subdirectory(examples)
endif()

View File

@@ -1,245 +0,0 @@
if(NOT ANDROID_PACKAGE_NAME)
set(ANDROID_PACKAGE_NAME "com.github.stevenlovegrove.pangolin")
endif()
if(NOT ANDROID_DEFERRED_ENTRY_SO)
set(ANDROID_DEFERRED_ENTRY_SO "libpangolin.so")
endif()
# Configure build environment to automatically generate APK's instead of executables.
if(ANDROID AND NOT TARGET apk)
# virtual targets which we'll add apks and push actions to.
add_custom_target( apk )
add_custom_target( push )
add_custom_target( run )
# Reset output directories to be in binary folder (rather than source)
set(LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ANDROID_NDK_ABI_NAME})
macro( create_android_manifest_xml filename prog_name package_name activity_name)
file( WRITE ${filename}
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"
package=\"${package_name}.${prog_name}\"
android:versionCode=\"1\"
android:versionName=\"1.0\">
<!-- This is the platform API where NativeActivity was introduced. -->
<uses-sdk android:minSdkVersion=\"14\" />
<uses-feature android:glEsVersion=\"0x00020000\" />
<uses-feature android:name=\"android.hardware.camera\" />
<uses-permission android:name=\"android.permission.CAMERA\"/>
<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\"/>
<uses-permission android:name=\"android.permission.READ_EXTERNAL_STORAGE\"/>
<!-- This .apk has no Java code itself, so set hasCode to false. -->
<application android:label=\"${activity_name}\" android:hasCode=\"false\">
<!-- Our activity is the built-in NativeActivity framework class.
This will take care of integrating with our NDK code. -->
<activity android:name=\"android.app.NativeActivity\"
android:label=\"${activity_name}\"
android:screenOrientation=\"landscape\"
android:configChanges=\"orientation|keyboard|keyboardHidden\"
android:theme=\"@android:style/Theme.NoTitleBar.Fullscreen\"
>
<!-- Tell NativeActivity the name of our .so -->
<meta-data android:name=\"android.app.lib_name\"
android:value=\"${prog_name}_start\" />
<intent-filter>
<action android:name=\"android.intent.action.MAIN\" />
<category android:name=\"android.intent.category.LAUNCHER\" />
</intent-filter>
</activity>
</application>
</manifest>
<!-- END_INCLUDE(manifest) -->" )
endmacro()
macro( create_bootstrap_library prog_name package_name)
set(bootstrap_cpp "${CMAKE_CURRENT_BINARY_DIR}/${prog_name}_start.cpp" )
file( WRITE ${bootstrap_cpp}
"#include <android/native_activity.h>
#include <android/log.h>
#include <dlfcn.h>
#include <errno.h>
#include <stdlib.h>
#include <cstdio>
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, \"AndroidUtils.cmake\", __VA_ARGS__))
#define LIB_PATH \"/data/data/${package_name}.${prog_name}/lib/\"
void * load_lib(const char * l) {
void * handle = dlopen(l, RTLD_NOW | RTLD_GLOBAL);
if (!handle) LOGE( \"dlopen('%s'): %s\", l, strerror(errno) );
return handle;
}
void ANativeActivity_onCreate(ANativeActivity * app, void * ud, size_t udsize) {
#include \"${prog_name}_shared_load.h\"
// Look for standard entrypoint in user lib
void (*stdentrypoint)(ANativeActivity*, void*, size_t);
*(void **) (&stdentrypoint) = dlsym(load_lib( LIB_PATH \"lib${prog_name}.so\"), \"ANativeActivity_onCreate\");
if (stdentrypoint) {
(*stdentrypoint)(app, ud, udsize);
}else{
// Look for deferred load entry point
void (*exdentrypoint)(ANativeActivity*, void*, size_t, const char*);
*(void **) (&exdentrypoint) = dlsym(load_lib( LIB_PATH \"lib${prog_name}.so\"), \"DeferredNativeActivity_onCreate\");
if (!exdentrypoint) {
// Look in specific shared lib
*(void **) (&exdentrypoint) = dlsym(load_lib( LIB_PATH \"${ANDROID_DEFERRED_ENTRY_SO}\"), \"DeferredNativeActivity_onCreate\");
}
if(exdentrypoint) {
(*exdentrypoint)(app, ud, udsize, LIB_PATH \"lib${prog_name}.so\" );
}else{
LOGE( \"Unable to find compatible entry point\" );
}
}
}" )
add_library( "${prog_name}_start" SHARED ${bootstrap_cpp} )
target_link_libraries( "${prog_name}_start" android log )
add_dependencies( ${prog_name} "${prog_name}_start" )
endmacro()
macro( android_update android_project_name)
# Find which android platforms are available.
execute_process(
COMMAND android list targets -c
OUTPUT_VARIABLE android_target_list
)
# Pick first platform from this list.
string(REGEX MATCH "^[^\n]+" android_target "${android_target_list}" )
message(STATUS "Android Target: ${android_target}")
if( NOT "${android_target}" STREQUAL "" )
# Generate ant build scripts for making APK
execute_process(
COMMAND android update project --name ${android_project_name} --path . --target ${android_target} --subprojects
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
else()
message( FATAL_ERROR "No Android SDK platforms found. Please install an Android platform SDK. On Linux, run 'android'." )
endif()
endmacro()
# Override add_executable to build android .so instead!
macro( add_executable prog_name)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_NDK_ABI_NAME})
add_library( ${prog_name} SHARED ${ARGN} )
# Add required link libs for android
target_link_libraries(${prog_name} log android )
# Create manifest required for APK
create_android_manifest_xml(
"${CMAKE_CURRENT_BINARY_DIR}/AndroidManifest.xml" "${prog_name}"
"${ANDROID_PACKAGE_NAME}" "${prog_name}"
)
# Create library that will launch this program and load shared libs
create_bootstrap_library( ${prog_name} ${ANDROID_PACKAGE_NAME} )
# Generate ant build system for APK
android_update( ${prog_name} )
# Target to invoke ant build system for APK
set( APK_FILE "${CMAKE_CURRENT_BINARY_DIR}/bin/${prog_name}-debug.apk" )
add_custom_command(
OUTPUT ${APK_FILE}
COMMAND ant debug
DEPENDS ${prog_name}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
# Target to install on device
add_custom_target( ${prog_name}-apk
DEPENDS ${APK_FILE}
)
add_dependencies(apk ${prog_name}-apk)
# Target to install on device
add_custom_target( ${prog_name}-push
COMMAND adb install -r ${APK_FILE}
DEPENDS ${APK_FILE}
)
add_dependencies(push ${prog_name}-push)
# install and run on device
add_custom_target( ${prog_name}-run
COMMAND adb shell am start -n ${ANDROID_PACKAGE_NAME}.${prog_name}/android.app.NativeActivity
DEPENDS ${prog_name}-push
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
add_dependencies(run ${prog_name}-run)
# Flag to package dependent libs
set_property(TARGET ${prog_name} APPEND PROPERTY MAKE_APK 1 )
# Clear shared library loading header
file( WRITE "${CMAKE_CURRENT_BINARY_DIR}/${prog_name}_shared_load.h" "")
endmacro()
macro( package_with_target prog_name lib_path )
# Mark lib_path as dependent of prog_name
set_property(TARGET ${prog_name} APPEND PROPERTY IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE ${lib_path} )
# If prog_name is to be packaged, add file copy command to package .so's.
get_target_property( package_dependent_libs ${prog_name} MAKE_APK )
if( package_dependent_libs )
get_filename_component(target_filename ${lib_path} NAME)
file( APPEND ${depend_file} "load_lib(LIB_PATH \"${target_filename}\" );\n")
add_custom_command(TARGET ${prog_name} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${lib_path} "${CMAKE_CURRENT_BINARY_DIR}/libs/${ANDROID_NDK_ABI_NAME}/"
)
endif()
endmacro()
macro( add_to_depend_libs prog_name depend_file lib_name )
# Recursively Process dependents of lib_name
get_target_property(TARGET_LIBS ${lib_name} IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE)
if(NOT TARGET_LIBS)
get_target_property(TARGET_LIBS ${lib_name} IMPORTED_LINK_INTERFACE_LIBRARIES_NOCONFIG)
endif()
if(NOT TARGET_LIBS)
get_target_property(TARGET_LIBS ${lib_name} IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG)
endif()
foreach(SUBLIB ${TARGET_LIBS})
if(SUBLIB)
add_to_depend_libs( ${prog_name} ${depend_file} ${SUBLIB} )
endif()
endforeach()
# Check if lib itself is an external shared library
if("${lib_name}" MATCHES "\\.so$")
package_with_target( ${prog_name} ${lib_name} )
endif()
# Check if lib itself is an internal shared library
get_target_property(TARGET_LIB ${lib_name} LOCATION)
if("${TARGET_LIB}" MATCHES "\\.so$")
package_with_target( ${prog_name} ${TARGET_LIB} )
endif()
endmacro()
macro( target_link_libraries prog_name)
# _target_link_libraries corresponds to original
_target_link_libraries( ${prog_name} ${ARGN} )
# Recursively process dependencies
set(depend_file "${CMAKE_CURRENT_BINARY_DIR}/${prog_name}_shared_load.h" )
foreach( LIB ${ARGN} )
add_to_depend_libs( ${prog_name} ${depend_file} ${LIB} )
endforeach()
endmacro()
endif()

View File

@@ -1,11 +0,0 @@
macro( CreateMethodCallFile filename namespace function symbols)
file(WRITE ${filename} "// CMake generated file. Do Not Edit.\n\n#pragma once\n\nnamespace ${namespace} {\n\n")
foreach( symbol ${symbols} )
file(APPEND ${filename} "void ${symbol}();\n")
endforeach()
file(APPEND ${filename} "\ninline bool ${function}()\n{\n")
foreach( symbol ${symbols} )
file(APPEND ${filename} " ${symbol}();\n")
endforeach()
file(APPEND ${filename} " return true;\n}\n\n} // ${namespace}\n")
endmacro()

View File

@@ -1,32 +0,0 @@
# Creates C resources file from files in given directory
# Based on http://stackoverflow.com/a/27206982
function(embed_binary_files file_glob output)
# Collect input files
file(GLOB bins ${file_glob})
# Stop when output file is newer than all binary files
set(output_newer_than_bins 1)
foreach(bin ${bins})
if(bin IS_NEWER_THAN output)
set(output_newer_than_bins 0)
break()
endif()
endforeach()
if(output_newer_than_bins)
return()
endif()
# Create empty output file
file(WRITE ${output} "")
# Iterate through input files
foreach(bin ${bins})
# Get short filename
string(REGEX MATCH "([^/]+)$" filename ${bin})
# Replace filename spaces & extension separator for C compatibility
string(REGEX REPLACE "\\.| " "_" filename ${filename})
# Read hex data from file
file(READ ${bin} filedata HEX)
# Convert hex data for C compatibility
string(REGEX REPLACE "([0-9a-f][0-9a-f])" "0x\\1," filedata ${filedata})
# Append data to output file
file(APPEND ${output} "extern const unsigned char ${filename}[] = {${filedata}};\nextern const unsigned ${filename}_size = sizeof(${filename});\n")
endforeach()
endfunction()

View File

@@ -1,32 +0,0 @@
# Try to find the dc1394 v2 lib and include files
#
# DC1394_INCLUDE_DIR
# DC1394_LIBRARIES
# DC1394_FOUND
FIND_PATH( DC1394_INCLUDE_DIR dc1394/control.h
/usr/include
/usr/local/include
)
FIND_LIBRARY( DC1394_LIBRARY dc1394
/usr/lib64
/usr/lib
/usr/local/lib
)
IF(DC1394_INCLUDE_DIR AND DC1394_LIBRARY)
SET( DC1394_FOUND TRUE )
SET( DC1394_LIBRARIES ${DC1394_LIBRARY} )
ENDIF(DC1394_INCLUDE_DIR AND DC1394_LIBRARY)
IF(DC1394_FOUND)
IF(NOT DC1394_FIND_QUIETLY)
MESSAGE(STATUS "Found DC1394: ${DC1394_LIBRARY}")
ENDIF(NOT DC1394_FIND_QUIETLY)
ELSE(DC1394_FOUND)
IF(DC1394_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libdc1394")
ENDIF(DC1394_FIND_REQUIRED)
ENDIF(DC1394_FOUND)

View File

@@ -1,43 +0,0 @@
# Try to find the DepthSense SDK For SoftKinetic Cameras
#
# DepthSense_INCLUDE_DIRS
# DepthSense_LIBRARIES
# DepthSense_FOUND
FIND_PATH( DepthSense_INCLUDE_DIR DepthSense.hxx
PATHS
"${PROGRAM_FILES}/SoftKinetic/DepthSenseSDK/include"
"${PROGRAM_FILES}/Meta/DepthSenseSDK/include"
/usr/include
/usr/local/include
/opt/local/include
/opt/softkinetic/DepthSenseSDK/include
)
FIND_LIBRARY( DepthSense_LIBRARY DepthSense
PATHS
"${PROGRAM_FILES}/SoftKinetic/DepthSenseSDK/lib"
"${PROGRAM_FILES}/Meta/DepthSenseSDK/lib"
/usr/lib64
/usr/lib
/usr/local/lib
/opt/local/lib
/opt/softkinetic/DepthSenseSDK/lib
)
IF(DepthSense_INCLUDE_DIR AND DepthSense_LIBRARY)
SET( DepthSense_FOUND TRUE )
SET( DepthSense_LIBRARIES ${DepthSense_LIBRARY} )
SET( DepthSense_INCLUDE_DIRS ${DepthSense_INCLUDE_DIR} )
ENDIF()
IF(DepthSense_FOUND)
IF(NOT DepthSense_FIND_QUIETLY)
MESSAGE(STATUS "Found DepthSense: ${DepthSense_LIBRARY}")
ENDIF()
ELSE()
IF(DepthSense_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find DepthSense")
ENDIF()
ENDIF()

View File

@@ -1,83 +0,0 @@
# - Try to find Eigen lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen 3.1.2)
# to require version 3.1.2 or newer of Eigen.
#
# Once done this will define
#
# EIGEN_FOUND - system has eigen lib with correct version
# EIGEN_INCLUDE_DIR - the eigen include directory
# EIGEN_VERSION - eigen version
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT Eigen_FIND_VERSION)
if(NOT Eigen_FIND_VERSION_MAJOR)
set(Eigen_FIND_VERSION_MAJOR 2)
endif(NOT Eigen_FIND_VERSION_MAJOR)
if(NOT Eigen_FIND_VERSION_MINOR)
set(Eigen_FIND_VERSION_MINOR 91)
endif(NOT Eigen_FIND_VERSION_MINOR)
if(NOT Eigen_FIND_VERSION_PATCH)
set(Eigen_FIND_VERSION_PATCH 0)
endif(NOT Eigen_FIND_VERSION_PATCH)
set(Eigen_FIND_VERSION "${Eigen_FIND_VERSION_MAJOR}.${Eigen_FIND_VERSION_MINOR}.${Eigen_FIND_VERSION_PATCH}")
endif(NOT Eigen_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(Eigen_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(Eigen_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(Eigen_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN_VERSION ${Eigen_WORLD_VERSION}.${Eigen_MAJOR_VERSION}.${Eigen_MINOR_VERSION})
if(${EIGEN_VERSION} VERSION_LESS ${Eigen_FIND_VERSION})
set(EIGEN_VERSION_OK FALSE)
else(${EIGEN_VERSION} VERSION_LESS ${Eigen_FIND_VERSION})
set(EIGEN_VERSION_OK TRUE)
endif(${EIGEN_VERSION} VERSION_LESS ${Eigen_FIND_VERSION})
if(NOT EIGEN_VERSION_OK)
message(STATUS "Eigen version ${EIGEN_VERSION} found in ${EIGEN_INCLUDE_DIR}, "
"but at least version ${Eigen_FIND_VERSION} is required")
endif(NOT EIGEN_VERSION_OK)
endmacro(_eigen3_check_version)
if (EIGEN_INCLUDE_DIR)
# in cache already
_eigen3_check_version()
set(EIGEN_FOUND ${EIGEN_VERSION_OK})
else()
find_path(EIGEN_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
PATHS
third_party/eigen
../eigen
../../eigen
/usr/local/include
/opt/local/include
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)
if(EIGEN_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR EIGEN_VERSION_OK)
mark_as_advanced(EIGEN_INCLUDE_DIR)
endif()
# In case anyone relies on the plural form.
set(EIGEN_INCLUDE_DIRS "${EIGEN_INCLUDE_DIR}")

View File

@@ -1,97 +0,0 @@
# Try to find the ffmpeg libraries and headers for avcodec avformat swscale
#
# FFMPEG_INCLUDE_DIRS
# FFMPEG_LIBRARIES
# FFMPEG_FOUND
# Find header files
FIND_PATH(
AVCODEC_INCLUDE_DIR libavcodec/avcodec.h
/usr/include /usr/local/include /opt/local/include /usr/include/x86_64-linux-gnu
)
FIND_PATH(
AVFORMAT_INCLUDE_DIR libavformat/avformat.h
/usr/include /usr/local/include /opt/local/include /usr/include/x86_64-linux-gnu
)
FIND_PATH(
AVDEVICE_INCLUDE_DIR libavdevice/avdevice.h
/usr/include /usr/local/include /opt/local/include /usr/include/x86_64-linux-gnu
)
FIND_PATH(
AVUTIL_INCLUDE_DIR libavutil/avutil.h
/usr/include /usr/local/include /opt/local/include /usr/include/x86_64-linux-gnu
)
FIND_PATH(
SWSCALE_INCLUDE_DIR libswscale/swscale.h
/usr/include /usr/local/include /opt/local/include /usr/include/x86_64-linux-gnu
)
# Find Library files
FIND_LIBRARY(
AVCODEC_LIBRARY
NAMES avcodec
PATH /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu
)
FIND_LIBRARY(
AVFORMAT_LIBRARY
NAMES avformat
PATH /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu
)
FIND_LIBRARY(
AVDEVICE_LIBRARY
NAMES avdevice
PATH /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu
)
FIND_LIBRARY(
AVUTIL_LIBRARY
NAMES avutil
PATH /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu
)
FIND_LIBRARY(
SWSCALE_LIBRARY
NAMES swscale
PATH /usr/lib /usr/local/lib /opt/local/lib /usr/lib/x86_64-linux-gnu
)
IF( EXISTS "${AVUTIL_INCLUDE_DIR}/libavutil/pixdesc.h" )
SET( AVUTIL_HAVE_PIXDESC TRUE)
endif()
IF(AVCODEC_INCLUDE_DIR AND AVFORMAT_INCLUDE_DIR AND AVUTIL_INCLUDE_DIR AND AVDEVICE_INCLUDE_DIR AND SWSCALE_INCLUDE_DIR AND AVCODEC_LIBRARY AND AVFORMAT_LIBRARY AND AVUTIL_LIBRARY AND SWSCALE_LIBRARY AND AVDEVICE_LIBRARY AND AVUTIL_HAVE_PIXDESC)
SET(FFMPEG_FOUND TRUE)
SET(FFMPEG_LIBRARIES ${AVCODEC_LIBRARY} ${AVFORMAT_LIBRARY} ${AVUTIL_LIBRARY} ${SWSCALE_LIBRARY} ${AVDEVICE_LIBRARY})
SET(FFMPEG_INCLUDE_DIRS ${AVCODEC_INCLUDE_DIR} ${AVFORMAT_INCLUDE_DIR} ${AVUTIL_INCLUDE_DIR} ${SWSCALE_INCLUDE_DIR} ${AVDEVICE_INCLUDE_DIR})
include(CheckCXXSourceCompiles)
SET(CMAKE_REQUIRED_INCLUDES ${FFMPEG_INCLUDE_DIRS})
CHECK_CXX_SOURCE_COMPILES(
"#include \"${AVCODEC_INCLUDE_DIR}/libavformat/avformat.h\"
int main() {
sizeof(AVFormatContext::max_analyze_duration);
}" HAVE_FFMPEG_MAX_ANALYZE_DURATION
)
CHECK_CXX_SOURCE_COMPILES(
"#include \"${AVCODEC_INCLUDE_DIR}/libavformat/avformat.h\"
int main() {
&avformat_alloc_output_context2;
}" HAVE_FFMPEG_AVFORMAT_ALLOC_OUTPUT_CONTEXT2
)
CHECK_CXX_SOURCE_COMPILES(
"#include \"${AVCODEC_INCLUDE_DIR}/libavutil/pixdesc.h\"
int main() {
AVPixelFormat test = AV_PIX_FMT_GRAY8;
}" HAVE_FFMPEG_AVPIXELFORMAT
)
ENDIF()
IF (FFMPEG_FOUND)
IF (NOT FFMPEG_FIND_QUIETLY)
MESSAGE(STATUS "Found FFMPEG: ${FFMPEG_LIBRARIES}")
ENDIF (NOT FFMPEG_FIND_QUIETLY)
ELSE (FFMPEG_FOUND)
IF (FFMPEG_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find FFMPEG")
ENDIF (FFMPEG_FIND_REQUIRED)
ENDIF (FFMPEG_FOUND)

View File

@@ -1,44 +0,0 @@
# Try to find the FREEGLUT library
#
# FREEGLUT_INCLUDE_DIR
# FREEGLUT_LIBRARY
# FREEGLUT_FOUND
FIND_PATH(
FREEGLUT_INCLUDE_DIR GL/freeglut.h
${CMAKE_INCLUDE_PATH}
$ENV{include}
${OPENGL_INCLUDE_DIR}
/usr/include
/usr/local/include
)
SET(STORE_CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
SET(CMAKE_FIND_FRAMEWORK NEVER)
FIND_LIBRARY(
FREEGLUT_LIBRARY
NAMES freeglut_static freeglut glut
PATH
/opt/local/lib
${CMAKE_LIBRARY_PATH}
$ENV{lib}
/usr/lib
/usr/local/lib
)
SET(CMAKE_FIND_FRAMEWORK ${STORE_CMAKE_FIND_FRAMEWORK})
IF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY)
SET(FREEGLUT_FOUND TRUE)
ENDIF (FREEGLUT_INCLUDE_DIR AND FREEGLUT_LIBRARY)
IF (FREEGLUT_FOUND)
IF (NOT FREEGLUT_FIND_QUIETLY)
MESSAGE(STATUS "Found FREEGLUT: ${FREEGLUT_LIBRARY}")
ENDIF (NOT FREEGLUT_FIND_QUIETLY)
ELSE (FREEGLUT_FOUND)
IF (FREEGLUT_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find FREEGLUT")
ENDIF (FREEGLUT_FIND_REQUIRED)
ENDIF (FREEGLUT_FOUND)

View File

@@ -1,53 +0,0 @@
#
# Try to find GLEW library and include path.
# Once done this will define
#
# GLEW_FOUND
# GLEW_INCLUDE_DIR
# GLEW_LIBRARY
#
IF (WIN32)
FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
$ENV{PROGRAMFILES}/GLEW/include
${PROJECT_SOURCE_DIR}/src/nvgl/glew/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARY
NAMES glew GLEW glew32 glew32s
PATHS
$ENV{PROGRAMFILES}/GLEW/lib
${PROJECT_SOURCE_DIR}/src/nvgl/glew/bin
${PROJECT_SOURCE_DIR}/src/nvgl/glew/lib
DOC "The GLEW library")
ELSE (WIN32)
FIND_PATH( GLEW_INCLUDE_DIR GL/glew.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where GL/glew.h resides")
FIND_LIBRARY( GLEW_LIBRARY
NAMES GLEW glew
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The GLEW library")
ENDIF (WIN32)
IF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
SET( GLEW_FOUND TRUE )
ENDIF (GLEW_INCLUDE_DIR AND GLEW_LIBRARY)
IF (GLEW_FOUND)
IF (NOT GLEW_FIND_QUIETLY)
MESSAGE(STATUS "Found GLEW: ${GLEW_LIBRARY}")
ENDIF (NOT GLEW_FIND_QUIETLY)
ELSE (GLEW_FOUND)
IF (GLEW_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find GLEW")
ENDIF (GLEW_FIND_REQUIRED)
ENDIF (GLEW_FOUND)

View File

@@ -1,38 +0,0 @@
# Try to find the GLUES lib and include files
#
# GLUES_INCLUDE_DIR
# GLUES_LIBRARIES
# GLUES_FOUND
FIND_PATH( GLUES_INCLUDE_DIR glues/glues.h
/usr/include
/usr/local/include
/opt/include
/opt/local/include
${CMAKE_INSTALL_PREFIX}/include
)
FIND_LIBRARY( GLUES_LIBRARY glues
/usr/lib64
/usr/lib
/usr/local/lib
/opt/local/lib
/opt/local/lib64
${CMAKE_INSTALL_PREFIX}/lib
)
IF(GLUES_INCLUDE_DIR AND GLUES_LIBRARY)
SET( GLUES_FOUND TRUE )
SET( GLUES_LIBRARIES ${GLUES_LIBRARY} )
ENDIF(GLUES_INCLUDE_DIR AND GLUES_LIBRARY)
IF(GLUES_FOUND)
IF(NOT GLUES_FIND_QUIETLY)
MESSAGE(STATUS "Found GLUES: ${GLUES_LIBRARY}")
ENDIF(NOT GLUES_FIND_QUIETLY)
ELSE(GLUES_FOUND)
IF(GLUES_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find GLUES")
ENDIF(GLUES_FIND_REQUIRED)
ENDIF(GLUES_FOUND)

View File

@@ -1,33 +0,0 @@
# -*- mode: cmake; -*-
###############################################################################
# Find librealsense https://github.com/IntelRealSense/librealsense
#
# This sets the following variables:
# LIBREALSENSE_FOUND - True if OPENNI was found.
# LIBREALSENSE_INCLUDE_DIRS - Directories containing the OPENNI include files.
# LIBREALSENSE_LIBRARIES - Libraries needed to use OPENNI.
# LIBREALSENSE_DEFINITIONS - Compiler flags for OPENNI.
#
# File forked from augmented_dev, project of alantrrs
# (https://github.com/alantrrs/augmented_dev).
find_package(PkgConfig)
if(${CMAKE_VERSION} VERSION_LESS 2.8.2)
endif()
#add a hint so that it can find it without the pkg-config
find_path(LIBREALSENSE_INCLUDE_DIR librealsense/rs.h
HINTS /usr/include/ /usr/local/include)
#add a hint so that it can find it without the pkg-config
find_library(LIBREALSENSE_LIBRARY
NAMES librealsense.so
HINTS /usr/lib /usr/local/lib )
set(LIBREALSENSE_INCLUDE_DIRS ${LIBREALSENSE_INCLUDE_DIR})
set(LIBREALSENSE_LIBRARIES ${LIBREALSENSE_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibRealSense DEFAULT_MSG
LIBREALSENSE_LIBRARY LIBREALSENSE_INCLUDE_DIR)
mark_as_advanced(LIBREALSENSE_LIBRARY LIBREALSENSE_INCLUDE_DIR)

View File

@@ -1,33 +0,0 @@
# -*- mode: cmake; -*-
###############################################################################
# Find librealsense2 https://github.com/IntelRealSense/librealsense
#
# This sets the following variables:
# LIBREALSENSE2_FOUND - True if LIBREALSENSE2 was found.
# LIBREALSENSE2_INCLUDE_DIRS - Directories containing the LIBREALSENSE2 include files.
# LIBREALSENSE2_LIBRARIES - Libraries needed to use LIBREALSENSE2.
# LIBREALSENSE2_DEFINITIONS - Compiler flags for LIBREALSENSE2.
#
# File forked from augmented_dev, project of alantrrs
# (https://github.com/alantrrs/augmented_dev).
find_package(PkgConfig)
if(${CMAKE_VERSION} VERSION_LESS 2.8.2)
endif()
#add a hint so that it can find it without the pkg-config
find_path(LIBREALSENSE2_INCLUDE_DIR librealsense2/rs.h
HINTS /usr/include/ /usr/local/include)
#add a hint so that it can find it without the pkg-config
find_library(LIBREALSENSE2_LIBRARY
NAMES librealsense2.so
HINTS /usr/lib /usr/local/lib )
set(LIBREALSENSE2_INCLUDE_DIRS ${LIBREALSENSE2_INCLUDE_DIR})
set(LIBREALSENSE2_LIBRARIES ${LIBREALSENSE2_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LibRealSense2 DEFAULT_MSG
LIBREALSENSE2_LIBRARY LIBREALSENSE2_INCLUDE_DIR)
mark_as_advanced(LIBREALSENSE2_LIBRARY LIBREALSENSE2_INCLUDE_DIR)

View File

@@ -1,26 +0,0 @@
find_path(Lz4_INCLUDE_DIRS
NAMES lz4frame.h
PATHS
/opt/local/include
/usr/local/include
/usr/include
)
find_library(Lz4_LIBRARIES
NAMES lz4
PATHS
/usr/local/lib
/opt/local/lib
/user/local/lib
/usr/lib
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Lz4 REQUIRED_VARS Lz4_LIBRARIES Lz4_INCLUDE_DIRS)
mark_as_advanced(
Lz4_INCLUDE_DIRS
Lz4_LIBRARIES
Lz4_FOUND
)

View File

@@ -1,20 +0,0 @@
# - Find MediaFoundation
# Find the Windows SDK MediaFoundation libraries
#
# MediaFoundation_LIBRARIES - List of libraries when using MediaFoundation
# MediaFoundation_FOUND - True if MediaFoundation found
IF (MSVC)
SET( MediaFoundation_LIBRARIES mf.lib mfplat.lib mfreadwrite.lib mfuuid.lib strmiids.lib )
SET( MediaFoundation_FOUND true )
ENDIF (MSVC)
IF (MediaFoundation_FOUND)
IF (NOT MediaFoundation_FIND_QUIETLY)
MESSAGE(STATUS "Found MediaFoundation: ${MediaFoundation_LIBRARIES}")
ENDIF (NOT MediaFoundation_FIND_QUIETLY)
ELSE (MediaFoundation_FOUND)
IF (MediaFoundation_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find MediaFoundation")
ENDIF (MediaFoundation_FIND_REQUIRED)
ENDIF (MediaFoundation_FOUND)

View File

@@ -1,63 +0,0 @@
# - Try to find Oculus Rift SDK
#
# Oculus_FOUND - system has libuvc
# Oculus_INCLUDE_DIRS - the libuvc include directories
# Oculus_LIBRARIES - link these to use libuvc
FIND_PATH(
Oculus_INCLUDE_DIRS
NAMES OVR.h
PATHS
${CMAKE_SOURCE_DIR}/../LibOVR/Include
${CMAKE_SOURCE_DIR}/../OculusSDK/LibOVR/Include
/usr/include/LibOVR/Include
/usr/local/include/LibOVR/Include
/opt/local/include/LibOVR/Include
/usr/include/
/usr/local/include
/opt/local/include
)
FIND_LIBRARY(
Oculus_LIBRARIES
NAMES ovr
PATHS
${CMAKE_SOURCE_DIR}/../LibOVR/Lib/MacOS/Release
${CMAKE_SOURCE_DIR}/../OculusSDK/LibOVR/Lib/Linux/Release/x86_64
/usr/include/LibOVR/Lib
/usr/local/include/LibOVR/Lib
/opt/local/include/LibOVR/Lib
/usr/lib
/usr/local/lib
/opt/local/lib
)
IF(Oculus_INCLUDE_DIRS AND Oculus_LIBRARIES)
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_library(CARBON_LIBRARIES NAMES Carbon)
find_library(IOKIT_LIBRARIES NAMES IOKit)
list(APPEND Oculus_LIBRARIES ${CARBON_LIBRARIES})
list(APPEND Oculus_LIBRARIES ${IOKIT_LIBRARIES})
SET(Oculus_FOUND TRUE)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
FIND_PACKAGE(Xrandr QUIET)
IF( Xrandr_FOUND )
list(APPEND Oculus_LIBRARIES ${Xrandr_LIBRARIES} -ludev -lXrandr -lXinerama )
SET(Oculus_FOUND TRUE)
ENDIF()
ENDIF()
ENDIF(Oculus_INCLUDE_DIRS AND Oculus_LIBRARIES)
IF(Oculus_FOUND)
IF(NOT Oculus_FIND_QUIETLY)
MESSAGE(STATUS "Found Oculus: ${Oculus_LIBRARIES}")
MESSAGE(STATUS "Found Oculus: ${Oculus_INCLUDE_DIRS}")
ENDIF(NOT Oculus_FIND_QUIETLY)
ELSE(Oculus_FOUND)
message(STATUS "Oculus NOT found")
IF(Oculus_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Oculus")
ENDIF(Oculus_FIND_REQUIRED)
ENDIF(Oculus_FOUND)

View File

@@ -1,33 +0,0 @@
# Try to find the OpenEXR v2 lib and include files
#
# OpenEXR_INCLUDE_DIR
# OpenEXR_LIBRARIES
# OpenEXR_FOUND
FIND_PATH( OpenEXR_INCLUDE_DIR ImfHeader.h
/usr/include
/usr/local/include
PATH_SUFFIXES OpenEXR
)
FIND_LIBRARY( OpenEXR_LIBRARY IlmImf
/usr/lib64
/usr/lib
/usr/local/lib
)
IF(OpenEXR_INCLUDE_DIR AND OpenEXR_LIBRARY)
SET( OpenEXR_FOUND TRUE )
SET( OpenEXR_LIBRARIES ${OpenEXR_LIBRARY} )
ENDIF()
IF(OpenEXR_FOUND)
IF(NOT OpenEXR_FIND_QUIETLY)
MESSAGE(STATUS "Found OpenEXR: ${OpenEXR_LIBRARY}")
ENDIF(NOT OpenEXR_FIND_QUIETLY)
ELSE(OpenEXR_FOUND)
IF(OpenEXR_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libOpenEXR")
ENDIF(OpenEXR_FIND_REQUIRED)
ENDIF(OpenEXR_FOUND)

View File

@@ -1,49 +0,0 @@
# -*- mode: cmake; -*-
###############################################################################
# Find OpenNI
#
# This sets the following variables:
# OPENNI_FOUND - True if OPENNI was found.
# OPENNI_INCLUDE_DIRS - Directories containing the OPENNI include files.
# OPENNI_LIBRARIES - Libraries needed to use OPENNI.
# OPENNI_DEFINITIONS - Compiler flags for OPENNI.
#
# File forked from augmented_dev, project of alantrrs
# (https://github.com/alantrrs/augmented_dev).
find_package(PkgConfig)
if(${CMAKE_VERSION} VERSION_LESS 2.8.2)
pkg_check_modules(PC_OPENNI openni-dev)
else()
pkg_check_modules(PC_OPENNI QUIET openni-dev)
endif()
set(OPENNI_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER})
#using the 64bit version of OpenNi if generating for 64bit
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PROGRAMFILES_ "$ENV{PROGRAMW6432}")
set(OPENNI_SUFFIX "64")
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PROGRAMFILES_ "$ENV{PROGRAMFILES}")
set(OPENNI_SUFFIX "")
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
#add a hint so that it can find it without the pkg-config
find_path(OPENNI_INCLUDE_DIR XnStatus.h
HINTS ${PC_OPENNI_INCLUDEDIR} ${PC_OPENNI_INCLUDE_DIRS} /usr/include/ni /usr/include/openni
"${PROGRAMFILES_}/OpenNI/Include"
PATH_SUFFIXES openni)
#add a hint so that it can find it without the pkg-config
find_library(OPENNI_LIBRARY
NAMES OpenNI64 OpenNI
HINTS ${PC_OPENNI_LIBDIR} ${PC_OPENNI_LIBRARY_DIRS} /usr/lib "${PROGRAMFILES_}/OpenNI/Lib${OPENNI_SUFFIX}")
set(OPENNI_INCLUDE_DIRS ${OPENNI_INCLUDE_DIR})
set(OPENNI_LIBRARIES ${OPENNI_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenNI DEFAULT_MSG
OPENNI_LIBRARY OPENNI_INCLUDE_DIR)
mark_as_advanced(OPENNI_LIBRARY OPENNI_INCLUDE_DIR)

View File

@@ -1,59 +0,0 @@
###############################################################################
# Find OpenNI2
#
# This sets the following variables:
# OPENNI2_FOUND - True if OPENNI was found.
# OPENNI2_INCLUDE_DIRS - Directories containing the OPENNI include files.
# OPENNI2_LIBRARIES - Libraries needed to use OPENNI.
find_package(PkgConfig)
if(${CMAKE_VERSION} VERSION_LESS 2.8.2)
pkg_check_modules(PC_OPENNI openni2-dev)
else()
pkg_check_modules(PC_OPENNI QUIET openni2-dev)
endif()
set(OPENNI2_DEFINITIONS ${PC_OPENNI_CFLAGS_OTHER})
#add a hint so that it can find it without the pkg-config
find_path(OPENNI2_INCLUDE_DIR OpenNI.h
HINTS
${PC_OPENNI_INCLUDEDIR}
${PC_OPENNI_INCLUDE_DIRS}
PATHS
"${PROGRAM_FILES}/OpenNI2/Include"
"${CMAKE_SOURCE_DIR}/../OpenNI2/Include"
/usr/include
/user/include
PATH_SUFFIXES openni2 ni2
)
if(${CMAKE_CL_64})
set(OPENNI_PATH_SUFFIXES lib64 lib)
else()
set(OPENNI_PATH_SUFFIXES lib)
endif()
#add a hint so that it can find it without the pkg-config
find_library(OPENNI2_LIBRARY
NAMES OpenNI2
HINTS
${PC_OPENNI_LIBDIR}
${PC_OPENNI_LIBRARY_DIRS}
PATHS
"${PROGRAM_FILES}/OpenNI2/Redist"
"${PROGRAM_FILES}/OpenNI2"
"${CMAKE_SOURCE_DIR}/../OpenNI2/Bin/x64-Release"
/usr/lib
/user/lib
PATH_SUFFIXES ${OPENNI_PATH_SUFFIXES}
)
set(OPENNI2_INCLUDE_DIRS ${OPENNI2_INCLUDE_DIR})
set(OPENNI2_LIBRARIES ${OPENNI2_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenNI2 DEFAULT_MSG
OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR)
mark_as_advanced(OPENNI2_LIBRARY OPENNI2_INCLUDE_DIR)

View File

@@ -1,143 +0,0 @@
# - Try to find Pleora SDK
#
# Pleora_FOUND - system has pleora eUSB SDK
# Pleora_INCLUDE_DIRS - the pleora eUSB SDK include directories
# Pleora_LIBRARIES - link these to use pleora eUSB SDK
# Pleora_BASE_DIR - set env varivales to this to use pleora eUSB SDK
set( INCLUDE_SEARCH_PATHS
"/opt/pleora/ebus_sdk/Ubuntu-12.04-x86_64/include"
"/opt/pleora/ebus_sdk/Ubuntu-14.04-x86_64/include"
"$ENV{ProgramFiles}/Pleora Technologies Inc/eBUS SDK/Includes"
)
set( LIBRARIES_SEARCH_PATHS
"/opt/pleora/ebus_sdk/Ubuntu-12.04-x86_64/lib"
"/opt/pleora/ebus_sdk/Ubuntu-14.04-x86_64/lib"
"$ENV{ProgramFiles}/Pleora Technologies Inc/eBUS SDK/Libraries"
)
set( GENAPI_SEARCH_PATHS
"/opt/pleora/ebus_sdk/Ubuntu-12.04-x86_64/lib/genicam/bin/Linux64_x64"
"/opt/pleora/ebus_sdk/Ubuntu-12.04-x86_64/lib/genicam/bin/Linux32_ARM"
"/opt/pleora/ebus_sdk/Ubuntu-14.04-x86_64/lib/genicam/bin/Linux64_x64"
"/opt/pleora/ebus_sdk/Ubuntu-14.04-x86_64/lib/genicam/bin/Linux32_ARM"
"$ENV{ProgramW6432}/GenICam_v2_4/library/CPP/lib/Win64_x64"
)
IF (${CMAKE_CL_64})
set (LIB_NAME_SUFFIX "64")
ELSE()
set (LIB_NAME_SUFFIX "")
ENDIF()
# Find header files
FIND_PATH(
PVBASE_INCLUDE_DIR PvBase.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVDEVICE_INCLUDE_DIR PvDevice.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVBUFFER_INCLUDE_DIR PvBuffer.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVGENICAM_INCLUDE_DIR PvGenICamLib.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVSTREAM_INCLUDE_DIR PvStream.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVTRANSMITTER_INCLUDE_DIR PvTransmitterLib.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVVIRTUALDEVICE_INCLUDE_DIR PvVirtualDeviceLib.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
FIND_PATH(
PVSAMPLEUTILS_INCLUDE_DIR PvSampleUtils.h
HINTS ${PC_PLEORA_DIR}/include
PATHS ${INCLUDE_SEARCH_PATHS}
)
# Find Library files
FIND_LIBRARY(
PVBASE_LIBRARY
NAMES "PvBase${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
PVDEVICE_LIBRARY
NAMES "PvDevice${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
PVBUFFER_LIBRARY
NAMES "PvBuffer${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
PVGENICAM_LIBRARY
NAMES "PvGenICam${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
PVSTREAM_LIBRARY
NAMES "PvStream${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
PVTRANSMITTER_LIBRARY
NAMES "PvTransmitter${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
PVVIRTUALDEVICE_LIBRARY
NAMES "PvVirtualDevice${LIB_NAME_SUFFIX}"
HINTS ${PC_PLEORA_DIR}/lib
PATH ${LIBRARIES_SEARCH_PATHS}
)
FIND_LIBRARY(
GENAPI_LIBRARY
NAMES GenApi_gcc40_v2_4 GenApi_gcc43_v2_4 GenApi_MD_VC80_v2_4
HINTS ${PC_GENAPI_LIBRARY_DIR}
PATH ${GENAPI_SEARCH_PATHS}
)
IF(PVBASE_INCLUDE_DIR AND PVDEVICE_INCLUDE_DIR AND PVBUFFER_INCLUDE_DIR AND PVGENICAM_INCLUDE_DIR AND PVSTREAM_INCLUDE_DIR AND PVTRANSMITTER_INCLUDE_DIR AND PVVIRTUALDEVICE_INCLUDE_DIR AND PVSAMPLEUTILS_INCLUDE_DIR AND PVBASE_LIBRARY AND PVDEVICE_LIBRARY AND PVBUFFER_LIBRARY AND PVGENICAM_LIBRARY AND PVSTREAM_LIBRARY AND PVTRANSMITTER_LIBRARY AND PVVIRTUALDEVICE_LIBRARY AND GENAPI_LIBRARY)
SET(Pleora_FOUND TRUE)
string(REGEX REPLACE "include$" "" Pleora_BASE_DIR ${PVBASE_INCLUDE_DIR})
SET(Pleora_LIBRARIES ${PVBASE_LIBRARY} ${PVDEVICE_LIBRARY} ${PVBUFFER_LIBRARY} ${PVGENICAM_LIBRARY} ${PVSTREAM_LIBRARY} ${PVTRANSMITTER_LIBRARY} ${PVVIRTUALDEVICE_LIBRARY} ${GENAPI_LIBRARY})
SET(Pleora_INCLUDE_DIRS ${PVBASE_INCLUDE_DIR} ${PVDEVICE_INCLUDE_DIR} ${PVBUFFER_INCLUDE_DIR} ${PVGENICAM_INCLUDE_DIR} ${PVSTREAM_INCLUDE_DIR} ${PVTRANSMITTER_INCLUDE_DIR} ${PVVIRTUALDEVICE_INCLUDE_DIR} ${PVSAMPLEUTILS_INCLUDE_DIR})
ENDIF()
IF (Pleora_FOUND)
IF (NOT Pleora_FIND_QUIETLY)
message(STATUS "Found Pleora: ${Pleora_LIBRARIES}")
ENDIF (NOT Pleora_FIND_QUIETLY)
ELSE (Pleora_FOUND)
IF (Pleora_FIND_REQUIRED)
message(FATAL_ERROR "Could not find Pleora")
ENDIF (Pleora_FIND_REQUIRED)
ENDIF (Pleora_FOUND)

View File

@@ -1,31 +0,0 @@
# - Try to find librobotvision
#
# ROBOTVISION_FOUND - system has librobotvision
# ROBOTVISION_INCLUDE_DIR - the librobotvision include directories
# ROBOTVISION_LIBRARY - link these to use librobotvision
FIND_PATH(
ROBOTVISION_INCLUDE_DIR
NAMES robotvision/bundle_adjuster.h
PATHS ${CMAKE_SOURCE_DIR}/.. /usr/include/robotvision /usr/local/include/robotvision
)
FIND_LIBRARY(
ROBOTVISION_LIBRARY
NAMES robotvision
PATHS ${CMAKE_SOURCE_DIR}/../robotvision/release /usr/lib /usr/local/lib
)
IF (ROBOTVISION_INCLUDE_DIR AND ROBOTVISION_LIBRARY)
SET(ROBOTVISION_FOUND TRUE)
ENDIF (ROBOTVISION_INCLUDE_DIR AND ROBOTVISION_LIBRARY)
IF (ROBOTVISION_FOUND)
IF (NOT ROBOTVISION_FIND_QUIETLY)
MESSAGE(STATUS "Found ROBOTVISION: ${ROBOTVISION_LIBRARY}")
ENDIF (NOT ROBOTVISION_FIND_QUIETLY)
ELSE (ROBOTVISION_FOUND)
IF (ROBOTVISION_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find ROBOTVISION")
ENDIF (ROBOTVISION_FIND_REQUIRED)
ENDIF (ROBOTVISION_FOUND)

View File

@@ -1,58 +0,0 @@
###############################################################################
# Find Toshiba TeliCam
#
# This sets the following variables:
# TeliCam_FOUND - True if TeliCam was found.
# TeliCam_INCLUDE_DIRS - Directories containing the TeliCam include files.
# TeliCam_LIBRARIES - Libraries needed to use TeliCam.
find_path(
TeliCam_INCLUDE_DIR TeliCamApi.h
PATHS
"${PROGRAM_FILES}/Toshiba Teli/TeliCamSDK/TeliCamApi/Include"
"${CMAKE_SOURCE_DIR}/../TeliCamSDK/TeliCamApi/Include"
/usr/include
/user/include
/opt/TeliCamSDK/include
PATH_SUFFIXES TeliCam
)
if(${CMAKE_CL_64})
set(TELI_PATH_SUFFIXES x64)
else()
set(TELI_PATH_SUFFIXES x86)
endif()
find_library(
TeliCamApi_LIBRARY
NAMES TeliCamApi TeliCamApi64 TeliCamApi_64
PATHS
"${PROGRAM_FILES}/Toshiba Teli/TeliCamSDK/TeliCamApi/lib"
"${CMAKE_SOURCE_DIR}/../TeliCamSDK/TeliCamApi/lib"
/usr/lib
/user/lib
/opt/TeliCamSDK/lib
PATH_SUFFIXES ${TELI_PATH_SUFFIXES}
)
find_library(
TeliCamUtl_LIBRARY
NAMES TeliCamUtl TeliCamUtl64 TeliCamUtl_64
PATHS
"${PROGRAM_FILES}/Toshiba Teli/TeliCamSDK/TeliCamApi/lib"
"${CMAKE_SOURCE_DIR}/../TeliCamSDK/TeliCamApi/lib"
/usr/lib
/user/lib
/opt/TeliCamSDK/lib
PATH_SUFFIXES ${TELI_PATH_SUFFIXES}
)
set(TeliCam_INCLUDE_DIRS ${TeliCam_INCLUDE_DIR})
set(TeliCam_LIBRARY "${TeliCamApi_LIBRARY}" "${TeliCamUtl_LIBRARY}")
set(TeliCam_LIBRARIES ${TeliCam_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( TeliCam
FOUND_VAR TeliCam_FOUND
REQUIRED_VARS TeliCamApi_LIBRARY TeliCamUtl_LIBRARY TeliCam_INCLUDE_DIR
)

View File

@@ -1,28 +0,0 @@
# - Try to find libTooN
#
# TooN_FOUND - system has libTooN
# TooN_INCLUDE_DIR - the libTooN include directories
FIND_PATH(
TooN_INCLUDE_DIR
NAMES TooN/TooN.h
PATHS
${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/..
/usr/include
/usr/local/include
)
IF(TooN_INCLUDE_DIR)
SET(TooN_FOUND TRUE)
ENDIF()
IF(TooN_FOUND)
IF(NOT TooN_FIND_QUIETLY)
MESSAGE(STATUS "Found TooN: ${TooN_INCLUDE_DIR}")
ENDIF()
ELSE()
IF(TooN_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find TooN")
ENDIF()
ENDIF()

View File

@@ -1,66 +0,0 @@
# Try to find Wayland on a Unix system
#
# This will define:
#
# WAYLAND_FOUND - True if Wayland is found
# WAYLAND_LIBRARIES - Link these to use Wayland
# WAYLAND_INCLUDE_DIR - Include directory for Wayland
# WAYLAND_DEFINITIONS - Compiler flags for using Wayland
#
# In addition the following more fine grained variables will be defined:
#
# WAYLAND_CLIENT_FOUND WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
# WAYLAND_SERVER_FOUND WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
# WAYLAND_EGL_FOUND WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
#
# Copyright (c) 2013 Martin Gräßlin <mgraesslin@kde.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
IF (NOT WIN32)
IF (WAYLAND_INCLUDE_DIR AND WAYLAND_LIBRARIES)
# In the cache already
SET(WAYLAND_FIND_QUIETLY TRUE)
ENDIF ()
# Use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_LIBRARY() calls
FIND_PACKAGE(PkgConfig)
PKG_CHECK_MODULES(PKG_WAYLAND QUIET wayland-client wayland-server wayland-egl wayland-cursor)
SET(WAYLAND_DEFINITIONS ${PKG_WAYLAND_CFLAGS})
FIND_PATH(WAYLAND_CLIENT_INCLUDE_DIR NAMES wayland-client.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_SERVER_INCLUDE_DIR NAMES wayland-server.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_EGL_INCLUDE_DIR NAMES wayland-egl.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_PATH(WAYLAND_CURSOR_INCLUDE_DIR NAMES wayland-cursor.h HINTS ${PKG_WAYLAND_INCLUDE_DIRS})
FIND_LIBRARY(WAYLAND_CLIENT_LIBRARIES NAMES wayland-client HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_SERVER_LIBRARIES NAMES wayland-server HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_EGL_LIBRARIES NAMES wayland-egl HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
FIND_LIBRARY(WAYLAND_CURSOR_LIBRARIES NAMES wayland-cursor HINTS ${PKG_WAYLAND_LIBRARY_DIRS})
set(WAYLAND_INCLUDE_DIR ${WAYLAND_CLIENT_INCLUDE_DIR} ${WAYLAND_SERVER_INCLUDE_DIR} ${WAYLAND_EGL_INCLUDE_DIR} ${WAYLAND_CURSOR_INCLUDE_DIR})
set(WAYLAND_LIBRARIES ${WAYLAND_CLIENT_LIBRARIES} ${WAYLAND_SERVER_LIBRARIES} ${WAYLAND_EGL_LIBRARIES} ${WAYLAND_CURSOR_LIBRARIES})
list(REMOVE_DUPLICATES WAYLAND_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CLIENT DEFAULT_MSG WAYLAND_CLIENT_LIBRARIES WAYLAND_CLIENT_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_SERVER DEFAULT_MSG WAYLAND_SERVER_LIBRARIES WAYLAND_SERVER_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_EGL DEFAULT_MSG WAYLAND_EGL_LIBRARIES WAYLAND_EGL_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND_CURSOR DEFAULT_MSG WAYLAND_CURSOR_LIBRARIES WAYLAND_CURSOR_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(WAYLAND DEFAULT_MSG WAYLAND_LIBRARIES WAYLAND_INCLUDE_DIR)
MARK_AS_ADVANCED(
WAYLAND_INCLUDE_DIR WAYLAND_LIBRARIES
WAYLAND_CLIENT_INCLUDE_DIR WAYLAND_CLIENT_LIBRARIES
WAYLAND_SERVER_INCLUDE_DIR WAYLAND_SERVER_LIBRARIES
WAYLAND_EGL_INCLUDE_DIR WAYLAND_EGL_LIBRARIES
WAYLAND_CURSOR_INCLUDE_DIR WAYLAND_CURSOR_LIBRARIES
)
ENDIF ()

View File

@@ -1,32 +0,0 @@
# - Try to find Xrandr
#
# Xrandr_FOUND - system has libXrandr
# Xrandr_INCLUDE_DIRS - the libXrandr include directories
# Xrandr_LIBRARIES - link these to use libXrandr
FIND_PATH(
Xrandr_INCLUDE_DIRS
NAMES X11/extensions/Xrandr.h
PATH_SUFFIXES X11/extensions
DOC "The Xrandr include directory"
)
FIND_LIBRARY(
Xrandr_LIBRARIES
NAMES Xrandr
DOC "The Xrandr library"
)
IF (Xrandr_INCLUDE_DIRS AND Xrandr_LIBRARIES)
SET(Xrandr_FOUND TRUE)
ENDIF (Xrandr_INCLUDE_DIRS AND Xrandr_LIBRARIES)
IF (Xrandr_FOUND)
IF (NOT Xrandr_FIND_QUIETLY)
MESSAGE(STATUS "Found Xrandr: ${Xrandr_LIBRARIES}")
ENDIF (NOT Xrandr_FIND_QUIETLY)
ELSE (Xrandr_FOUND)
IF (Xrandr_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find Xrandr")
ENDIF (Xrandr_FIND_REQUIRED)
ENDIF (Xrandr_FOUND)

View File

@@ -1,42 +0,0 @@
# - Try to find libusb1
#
# libusb1_FOUND - system has libusb1
# libusb1_INCLUDE_DIRS - the libusb1 include directories
# libusb1_LIBRARIES - link these to use libusb1
FIND_PATH(
libusb1_INCLUDE_DIRS
NAMES libusb-1.0/libusb.h
PATHS
c:/dev/sysroot32/usr/include
${CMAKE_SOURCE_DIR}/../libusb1/include
/usr/include/
/usr/local/include
/opt/local/include
)
FIND_LIBRARY(
libusb1_LIBRARIES
NAMES libusb-1.0
PATHS
c:/dev/sysroot32/usr/lib
${CMAKE_SOURCE_DIR}/../libusb1/lib
/usr/lib
/usr/local/lib
/opt/local/lib
)
IF(libusb1_INCLUDE_DIRS AND libusb1_LIBRARIES)
SET(libusb1_FOUND TRUE)
ENDIF(libusb1_INCLUDE_DIRS AND libusb1_LIBRARIES)
IF(libusb1_FOUND)
IF(NOT libusb1_FIND_QUIETLY)
MESSAGE(STATUS "Found libusb1: ${libusb1_LIBRARIES}")
ENDIF(NOT libusb1_FIND_QUIETLY)
ELSE(libusb1_FOUND)
message(STATUS "libusb1 NOT found")
IF(libusb1_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find libusb1")
ENDIF(libusb1_FIND_REQUIRED)
ENDIF(libusb1_FOUND)

View File

@@ -1,42 +0,0 @@
# - Try to find pthread
#
# pthread_FOUND - system has pthread
# pthread_INCLUDE_DIRS - the pthread include directories
# pthread_LIBRARIES - link these to use pthread
FIND_PATH(
pthread_INCLUDE_DIRS
NAMES pthread.h
PATHS
c:/dev/sysroot32/usr/include
${CMAKE_SOURCE_DIR}/../pthread/include
/usr/include/
/usr/local/include
/opt/local/include
)
FIND_LIBRARY(
pthread_LIBRARIES
NAMES pthreadVSE2 pthread
PATHS
c:/dev/sysroot32/usr/lib
${CMAKE_SOURCE_DIR}/../pthread/lib
/usr/lib
/usr/local/lib
/opt/local/lib
)
IF(pthread_INCLUDE_DIRS AND pthread_LIBRARIES)
SET(pthread_FOUND TRUE)
ENDIF(pthread_INCLUDE_DIRS AND pthread_LIBRARIES)
IF(pthread_FOUND)
IF(NOT pthread_FIND_QUIETLY)
MESSAGE(STATUS "Found pthread: ${pthread_LIBRARIES}")
ENDIF(NOT pthread_FIND_QUIETLY)
ELSE(pthread_FOUND)
message(STATUS "pthread NOT found")
IF(pthread_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find pthread")
ENDIF(pthread_FIND_REQUIRED)
ENDIF(pthread_FOUND)

View File

@@ -1,39 +0,0 @@
# - Try to find uvc
#
# uvc_FOUND - system has libuvc
# uvc_INCLUDE_DIRS - the libuvc include directories
# uvc_LIBRARIES - link these to use libuvc
FIND_PATH(
uvc_INCLUDE_DIRS
NAMES libuvc/libuvc.h
PATHS
${CMAKE_SOURCE_DIR}/..
/usr/include/
/usr/local/include
/opt/local/include
)
FIND_LIBRARY(
uvc_LIBRARIES
NAMES uvc
PATHS
${CMAKE_SOURCE_DIR}/../uvc/build
/usr/lib
/usr/local/lib
/opt/local/lib
)
IF (uvc_INCLUDE_DIRS AND uvc_LIBRARIES)
SET(uvc_FOUND TRUE)
ENDIF (uvc_INCLUDE_DIRS AND uvc_LIBRARIES)
IF (uvc_FOUND)
IF (NOT uvc_FIND_QUIETLY)
MESSAGE(STATUS "Found uvc: ${uvc_LIBRARIES}")
ENDIF (NOT uvc_FIND_QUIETLY)
ELSE (uvc_FOUND)
IF (uvc_FIND_REQUIRED)
MESSAGE(FATAL_ERROR "Could not find uvc")
ENDIF (uvc_FIND_REQUIRED)
ENDIF (uvc_FOUND)

View File

@@ -1,35 +0,0 @@
###############################################################################
# Find Toshiba TeliCam
#
# This sets the following variables:
# TeliCam_FOUND - True if TeliCam was found.
# TeliCam_INCLUDE_DIRS - Directories containing the TeliCam include files.
# TeliCam_LIBRARIES - Libraries needed to use TeliCam.
find_path(
zstd_INCLUDE_DIR zstd.h
PATHS
/opt/local/include
/usr/local/include
/usr/include
PATH_SUFFIXES TeliCam
)
find_library(
zstd_LIBRARY
NAMES zstd
PATHS
/opt/local/lib
/user/local/lib
/usr/lib
)
# Plural forms
set(zstd_INCLUDE_DIRS ${zstd_INCLUDE_DIR})
set(zstd_LIBRARIES ${zstd_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( zstd
FOUND_VAR zstd_FOUND
REQUIRED_VARS zstd_INCLUDE_DIR zstd_LIBRARY
)

View File

@@ -1,56 +0,0 @@
## Compiler configuration
IF(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC)
SET(_GCC_ 1)
ENDIF()
IF(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
SET(_CLANG_ 1)
ENDIF()
IF(MSVC)
SET(_MSVC_ 1)
ENDIF()
## Platform configuration
IF(WIN32 OR WIN64)
SET(_WIN_ 1)
ENDIF()
IF(UNIX)
SET(_UNIX_ 1)
ENDIF()
IF(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
SET(_OSX_ 1)
ENDIF()
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
SET(_LINUX_ 1)
ENDIF()
IF(ANDROID)
SET(_ANDROID_ 1)
ENDIF()
IF(IOS)
SET(_APPLE_IOS_ 1)
ENDIF()
## Default search paths
IF(_WIN_)
IF(${CMAKE_CL_64})
LIST(APPEND CMAKE_INCLUDE_PATH "c:/dev/sysroot64/usr/include")
LIST(APPEND CMAKE_LIBRARY_PATH "c:/dev/sysroot64/usr/lib")
LIST(APPEND CMAKE_LIBRARY_PATH "c:/dev/sysroot64/usr/bin")
set(PROGRAM_FILES "$ENV{PROGRAMW6432}" )
ELSE()
LIST(APPEND CMAKE_INCLUDE_PATH "c:/dev/sysroot32/usr/include")
LIST(APPEND CMAKE_LIBRARY_PATH "c:/dev/sysroot32/usr/lib")
LIST(APPEND CMAKE_LIBRARY_PATH "c:/dev/sysroot32/usr/bin")
set(PROGRAM_FILES "$ENV{PROGRAMFILES}" )
ENDIF()
ENDIF()

View File

@@ -1,176 +0,0 @@
What is Pangolin
====================================
Pangolin is a lightweight portable rapid development library for managing OpenGL
display / interaction and abstracting video input. At its heart is a simple
OpenGl viewport manager which can help to modularise 3D visualisation without
adding to its complexity, and offers an advanced but intuitive 3D navigation
handler. Pangolin also provides a mechanism for manipulating program variables
through config files and ui integration, and has a flexible real-time plotter
for visualising graphical data.
The ethos of Pangolin is to reduce the boilerplate code that normally
gets written to visualise and interact with (typically image and 3D
based) systems, without compromising performance. It also enables write-once
code for a number of platforms, currently including Windows, Linux, OSX, Android
and IOS.
## Code ##
Find the latest version on [Github](http://github.com/stevenlovegrove/Pangolin):
```
git clone https://github.com/stevenlovegrove/Pangolin.git
```
## Dependencies ##
Optional dependencies are enabled when found, otherwise they are silently disabled.
Check the CMake configure output for details.
### Required Dependencies ###
* C++11
* OpenGL (Desktop / ES / ES2)
* (lin) `sudo apt install libgl1-mesa-dev`
* Glew
* (win) built automatically (assuming git is on your path)
* (deb) `sudo apt install libglew-dev`
* (mac) `sudo port install glew`
* CMake (for build environment)
* (win) http://www.cmake.org/cmake/resources/software.html
* (deb) `sudo apt install cmake`
* (mac) `sudo port install cmake`
### Recommended Dependencies ###
* Python2 / Python3, for drop-down interactive console
* (win) http://www.python.org/downloads/windows
* (deb) `sudo apt install libpython2.7-dev`
* (mac) preinstalled with osx
* (for pybind11) `git submodule init && git submodule update`
* (useful modules) `sudo python -mpip install numpy pyopengl Pillow pybind11`
* Wayland
* pkg-config: `sudo apt install pkg-config`
* Wayland and EGL:`sudo apt install libegl1-mesa-dev libwayland-dev libxkbcommon-dev wayland-protocols`
### Optional Dependencies for video input ###
* FFMPEG (For video decoding and image rescaling)
* (deb) `sudo apt install ffmpeg libavcodec-dev libavutil-dev libavformat-dev libswscale-dev libavdevice-dev`
* DC1394 (For firewire input)
* (deb) `sudo apt install libdc1394-22-dev libraw1394-dev`
* libuvc (For cross-platform webcam video input via libusb)
* git://github.com/ktossell/libuvc.git
* libjpeg, libpng, libtiff, libopenexr (For reading still-image sequences)
* (deb) `sudo apt install libjpeg-dev libpng12-dev libtiff5-dev libopenexr-dev`
* OpenNI / OpenNI2 (For Kinect / Xtrion / Primesense capture)
* DepthSense SDK
### Very Optional Dependencies ###
* Eigen / TooN (These matrix types supported in the Pangolin API.)
* CUDA Toolkit >= 3.2 (Some CUDA header-only interop utilities included)
* http://developer.nvidia.com/cuda-downloads
* Doxygen for generating html / pdf documentation.
## Building ##
Pangolin uses the CMake portable pre-build tool. To checkout and build pangolin in the
directory 'build', execute the following at a shell (or the equivelent using a GUI):
```
git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
cmake --build .
```
If you would like to build the documentation and you have Doxygen installed, you
can execute:
```
cmake --build . --target pangolin_doc
```
**On Windows**, Pangolin will attempt to download and build *glew*, *libjpeg*, *libpng* and *zlib* automatically. It does so assuming that git is available on the path - this assumption may be wrong for windows users who have downloaded Pangolin via a zip file on github. You will instead need to download and compile the dependencies manually, and set the BUILD_EXTERN_(lib) options to false for these libraries. The alternate and recommended approach is to install [gitbash](https://git-scm.com/downloads) and work from within their provided console.
## Issues ##
Please visit [Github Issues](https://github.com/stevenlovegrove/Pangolin/issues) to view and report problems with Pangolin. Issues and pull requests should be raised against the master branch which contains the current development version.
Please note; most Pangolin dependencies are optional - to disable a dependency which may be causing trouble on your machine, set the BUILD_PANGOLIN_(option) variable to false with a cmake configuration tool (e.g. ccmake or cmake-gui).
## Contributions and Continuous Integration ##
For CI, Pangolin uses [travis-ci.org](https://travis-ci.org/stevenlovegrove/Pangolin) for Ubuntu, OSX and [ci.appveyor.com](https://ci.appveyor.com/project/stevenlovegrove/pangolin) for Windows.
To contribute to Pangolin, I would appreciate pull requests against the master branch. This will trigger CI builds for your changes automatically, and help me to merge with confidence.
## Binaries ##
Binaries are available for Windows x64, as output by the Windows CI server: [Appveyor Artifacts](https://ci.appveyor.com/project/stevenlovegrove/pangolin/build/artifacts).
## Bindings ##
### Python ###
Pangolin python bindings are enabled via [pybind11](www.pybind11.com). These bindings can be used both standalone and from within Pangolin's drop-down console (press the back-tick key, `).
To enable the bindings, you must checkout the pybind submodule. To use pangolin in python, it's recommend to install a few other python packages too:
```
sudo python -mpip install numpy pyopengl Pillow pybind11
git submodule init && git submodule update
```
The python module pypangolin must be on your python path, either through installation, or by setting it explicitly:
```
import sys
sys.path.append('path/of/pypangolin.so')
```
## Scheme syntax for windowing and video
Pangolin uses 'URI' syntax for modularising video drivers and windowing backends. The syntax follows along the lines of `module_name:[option1=value1,option2=value2,...]//module_resource_to_open`. Some examples for using this URI syntax with the VideoViewer tool is as follows:
```
VideoViewer test://
VideoViewer uvc:[size=640x480]///dev/video0
VideoViewer flip://debayer:[tile=rggb,method=downsample]//file://~/somefile.pango
```
Notice that for video, some modules support chaining to construct a simple filter graph. See include/pangolin/video/video.h for more examples.
For windowing, you can also customize default arguments for Pangolin applications by setting the `PANGOLIN_WINDOW_URI` environment variable. For instance, on high-DPI screens (in this example on OSX), you could set:
```
setenv PANGOLIN_WINDOW_URI "cocoa:[HIGHRES=true]//"
```
Some window parameters that may be interesting to override are `DISPLAYNAME`, `DOUBLEBUFFER`, `SAMPLE_BUFFERS`, `SAMPLES`, `HIGHRES`. Window modules currently include `x11`, `winapi`, `cocoa`.
## Acknowledgements ##
I'd like to thank the growing number of kind contributors to Pangolin for helping to make it more stable and feature rich. Many features of Pangolin have been influenced by other projects such as GFlags, GLConsole, and libcvd in particular. I'd also like to thank the FOSS projects on which Pangolin depends.
For a summary of those who have made code contributions, execute:
```
git shortlog -sne
```

View File

@@ -1,25 +0,0 @@
os: Visual Studio 2015
clone_folder: c:/projects/Pangolin
platform: x64
configuration: Release
build:
verbosity: minimal
project: c:/projects/Pangolin/build/Pangolin.sln
install:
- ps: wget http://bitbucket.org/eigen/eigen/get/3.2.10.zip -outfile eigen3.zip
- cmd: 7z x eigen3.zip -o"C:/projects" -y > nul
before_build:
- cd c:/projects/Pangolin
- mkdir bin
- mkdir build
- cd build
- cmake -G "Visual Studio 14 2015 Win64" -D EIGEN3_INCLUDE_DIR=C:/projects/eigen-eigen-b9cd8366d4e8 -D CMAKE_INSTALL_PREFIX=../bin ..
on_success:
- 7z a pangolin_build.zip "c:/projects/Pangolin/build/src/include" "c:/projects/Pangolin/build/src/Release/pangolin.lib" "c:/projects/Pangolin/build/tools/*/Release/*.exe" "c:/projects/Pangolin/build/examples/*/Release/*.exe"
- appveyor PushArtifact pangolin_build.zip

View File

@@ -1,25 +0,0 @@
# -----------------------------------------------
# File that provides "make uninstall" target
# We use the file 'install_manifest.txt'
# -----------------------------------------------
IF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"")
ENDIF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
FILE(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
STRING(REGEX REPLACE "\n" ";" files "${files}")
FOREACH(file ${files})
MESSAGE(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
IF(EXISTS "$ENV{DESTDIR}${file}")
EXEC_PROGRAM(
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
OUTPUT_VARIABLE rm_out
RETURN_VALUE rm_retval
)
IF(NOT "${rm_retval}" STREQUAL 0)
MESSAGE(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"")
ENDIF(NOT "${rm_retval}" STREQUAL 0)
ELSE(EXISTS "$ENV{DESTDIR}${file}")
MESSAGE(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.")
ENDIF(EXISTS "$ENV{DESTDIR}${file}")
ENDFOREACH(file)

View File

@@ -1,33 +0,0 @@
# All examples depend on Pangolin GUI
if(BUILD_PANGOLIN_GUI)
add_subdirectory(HelloPangolin)
add_subdirectory(HelloPangolinOffscreen)
add_subdirectory(HelloPangolinThreads)
add_subdirectory(SimpleMultiDisplay)
add_subdirectory(SimpleDisplayImage)
add_subdirectory(SimpleScene)
if(NOT HAVE_GLES OR HAVE_GLES_2)
add_subdirectory(SimplePlot)
endif()
## These samples require Pangolin Var support
if(BUILD_PANGOLIN_VARS)
add_subdirectory(SimpleDisplay)
## Video Samples require Pangolin Video support
if(BUILD_PANGOLIN_VIDEO)
add_subdirectory(SimpleVideo)
add_subdirectory(SimpleRecord)
add_subdirectory(SharedMemoryCamera)
endif()
# # This sample fails on many platforms, so exclude it for now,
# # until we can create a better cmake test for support.
# find_package(CUDA QUIET)
# if( CUDA_FOUND )
# add_subdirectory(VBODisplay)
# endif()
endif()
endif()

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(HelloPangolin main.cpp)
target_link_libraries(HelloPangolin ${Pangolin_LIBRARIES})

View File

@@ -1,34 +0,0 @@
#include <pangolin/pangolin.h>
int main( int /*argc*/, char** /*argv*/ )
{
pangolin::CreateWindowAndBind("Main",640,480);
glEnable(GL_DEPTH_TEST);
// Define Projection and initial ModelView matrix
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
);
// Create Interactive View in window
pangolin::Handler3D handler(s_cam);
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
.SetHandler(&handler);
while( !pangolin::ShouldQuit() )
{
// Clear screen and activate view to render into
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
// Render OpenGL Cube
pangolin::glDrawColouredCube();
// Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.5 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(HelloPangolinOffscreen main.cpp)
target_link_libraries(HelloPangolinOffscreen ${Pangolin_LIBRARIES})

View File

@@ -1,48 +0,0 @@
#include <pangolin/pangolin.h>
int main( int /*argc*/, char** /*argv*/ )
{
static const int w = 640;
static const int h = 480;
pangolin::CreateWindowAndBind("Main",w,h,pangolin::Params({{"scheme", "headless"}}));
glEnable(GL_DEPTH_TEST);
// Define Projection and initial ModelView matrix
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(w,h,420,420,320,240,0.2,100),
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
);
// Create Interactive View in window
pangolin::Handler3D handler(s_cam);
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, 0.0, 1.0, -float(w)/float(h))
.SetHandler(&handler);
pangolin::SaveWindowOnRender("window");
// create a frame buffer object with colour and depth buffer
pangolin::GlTexture color_buffer(w,h);
pangolin::GlRenderBuffer depth_buffer(w,h);
pangolin::GlFramebuffer fbo_buffer(color_buffer, depth_buffer);
fbo_buffer.Bind();
// Clear screen and activate view to render into
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
// Render OpenGL Cube
pangolin::glDrawColouredCube();
// Swap frames and Process Events
pangolin::FinishFrame();
fbo_buffer.Unbind();
// download and save the colour buffer
color_buffer.Save("fbo.png", false);
pangolin::QuitAll();
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.5 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(HelloPangolinThreads main.cpp)
target_link_libraries(HelloPangolinThreads ${Pangolin_LIBRARIES})

View File

@@ -1,64 +0,0 @@
#include <pangolin/pangolin.h>
#include <thread>
static const std::string window_name = "HelloPangolinThreads";
void setup() {
// create a window and bind its context to the main thread
pangolin::CreateWindowAndBind(window_name, 640, 480);
// enable depth
glEnable(GL_DEPTH_TEST);
// unset the current context from the main thread
pangolin::GetBoundWindow()->RemoveCurrent();
}
void run() {
// fetch the context and bind it to this thread
pangolin::BindToContext(window_name);
// we manually need to restore the properties of the context
glEnable(GL_DEPTH_TEST);
// Define Projection and initial ModelView matrix
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
);
// Create Interactive View in window
pangolin::Handler3D handler(s_cam);
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
.SetHandler(&handler);
while( !pangolin::ShouldQuit() )
{
// Clear screen and activate view to render into
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
// Render OpenGL Cube
pangolin::glDrawColouredCube();
// Swap frames and Process Events
pangolin::FinishFrame();
}
// unset the current context from the main thread
pangolin::GetBoundWindow()->RemoveCurrent();
}
int main( int /*argc*/, char** /*argv*/ )
{
// create window and context in the main thread
setup();
// use the context in a separate rendering thread
std::thread render_loop;
render_loop = std::thread(run);
render_loop.join();
return 0;
}

View File

@@ -1,7 +0,0 @@
if(UNIX)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SharedMemoryCamera main.cpp)
target_link_libraries(SharedMemoryCamera ${Pangolin_LIBRARIES})
endif()

View File

@@ -1,53 +0,0 @@
#include <pangolin/pangolin.h>
#include <pangolin/utils/posix/condition_variable.h>
#include <pangolin/utils/posix/shared_memory_buffer.h>
#include <pangolin/utils/timer.h>
#include <cmath>
#include <memory>
// This sample acts as a soft camera. It writes a pattern of GRAY8 pixels to the
// shared memory space. It can be seen in Pangolin's SimpleVideo sample using
// the shmem:[size=640x480]//example video URI.
using namespace pangolin;
unsigned char generate_value(double t)
{
// 10s sinusoid
const double d = std::sin(t * 10.0 / M_PI) * 128.0 + 128.0;
return static_cast<unsigned char>(d);
}
int main(/*int argc, char *argv[]*/)
{
std::string shmem_name = "/example";
std::shared_ptr<SharedMemoryBufferInterface> shmem_buffer =
create_named_shared_memory_buffer(shmem_name, 640 * 480);
if (!shmem_buffer) {
perror("Unable to create shared memory buffer");
exit(1);
}
std::string cond_name = shmem_name + "_cond";
std::shared_ptr<ConditionVariableInterface> buffer_full =
create_named_condition_variable(cond_name);
// Sit in a loop and write gray values based on some timing pattern.
while (true) {
shmem_buffer->lock();
unsigned char *ptr = shmem_buffer->ptr();
unsigned char value = generate_value(std::chrono::system_clock::now().time_since_epoch().count());
for (int i = 0; i < 640*480; ++i) {
ptr[i] = value;
}
shmem_buffer->unlock();
buffer_full->signal();
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
}

View File

@@ -1,7 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimpleDisplay main.cpp)
target_link_libraries(SimpleDisplay ${Pangolin_LIBRARIES} )

View File

@@ -1,26 +0,0 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pangolin Sample configuration file
% Comments start with '%' or '#'
%
% Declarations are name value pairs,
% seperated with '=' and terminated with ';'
% We can set any variable referenced in code directly
ui.A Double = 3.2;
ui.A Checkbox = false;
% We can set unreferenced variables too
a.b = 1;
a.c = 2;
z.b = 3;
z.c = 4;
start = z;
% Which we might refer to by reference
ui.An Int = ${${start}.c};
% Declarations can span multiple lines
M =
[1, 0, 0
0, 1, 0
0, 0, 1];

View File

@@ -1,129 +0,0 @@
#include <iostream>
#include <pangolin/pangolin.h>
struct CustomType
{
CustomType()
: x(0), y(0.0f) {}
CustomType(int x, float y, std::string z)
: x(x), y(y), z(z) {}
int x;
float y;
std::string z;
};
std::ostream& operator<< (std::ostream& os, const CustomType& o){
os << o.x << " " << o.y << " " << o.z;
return os;
}
std::istream& operator>> (std::istream& is, CustomType& o){
is >> o.x;
is >> o.y;
is >> o.z;
return is;
}
void SampleMethod()
{
std::cout << "You typed ctrl-r or pushed reset" << std::endl;
}
int main(/*int argc, char* argv[]*/)
{
// Load configuration data
pangolin::ParseVarsFile("app.cfg");
// Create OpenGL window in single line
pangolin::CreateWindowAndBind("Main",640,480);
// 3D Mouse handler requires depth testing to be enabled
glEnable(GL_DEPTH_TEST);
// Define Camera Render Object (for view / scene browsing)
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
pangolin::ModelViewLookAt(-0,0.5,-3, 0,0,0, pangolin::AxisY)
);
const int UI_WIDTH = 180;
// Add named OpenGL viewport to window and provide 3D Handler
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, pangolin::Attach::Pix(UI_WIDTH), 1.0, -640.0f/480.0f)
.SetHandler(new pangolin::Handler3D(s_cam));
// Add named Panel and bind to variables beginning 'ui'
// A Panel is just a View with a default layout and input handling
pangolin::CreatePanel("ui")
.SetBounds(0.0, 1.0, 0.0, pangolin::Attach::Pix(UI_WIDTH));
// Safe and efficient binding of named variables.
// Specialisations mean no conversions take place for exact types
// and conversions between scalar types are cheap.
pangolin::Var<bool> a_button("ui.A_Button",false,false);
pangolin::Var<double> a_double("ui.A_Double",3,0,5);
pangolin::Var<int> an_int("ui.An_Int",2,0,5);
pangolin::Var<double> a_double_log("ui.Log_scale var",3,1,1E4, true);
pangolin::Var<bool> a_checkbox("ui.A_Checkbox",false,true);
pangolin::Var<int> an_int_no_input("ui.An_Int_No_Input",2);
pangolin::Var<CustomType> any_type("ui.Some_Type", CustomType(0,1.2f,"Hello") );
pangolin::Var<bool> save_window("ui.Save_Window",false,false);
pangolin::Var<bool> save_cube("ui.Save_Cube",false,false);
pangolin::Var<bool> record_cube("ui.Record_Cube",false,false);
// std::function objects can be used for Var's too. These work great with C++11 closures.
pangolin::Var<std::function<void(void)> > reset("ui.Reset", SampleMethod);
// Demonstration of how we can register a keyboard hook to alter a Var
pangolin::RegisterKeyPressCallback(pangolin::PANGO_CTRL + 'b', pangolin::SetVarFunctor<double>("ui.A_Double", 3.5));
// Demonstration of how we can register a keyboard hook to trigger a method
pangolin::RegisterKeyPressCallback(pangolin::PANGO_CTRL + 'r', SampleMethod);
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
// Clear entire screen
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if( pangolin::Pushed(a_button) )
std::cout << "You Pushed a button!" << std::endl;
// Overloading of Var<T> operators allows us to treat them like
// their wrapped types, eg:
if( a_checkbox )
an_int = (int)a_double;
if( !any_type->z.compare("robot"))
any_type = CustomType(1,2.3f,"Boogie");
an_int_no_input = an_int;
if( pangolin::Pushed(save_window) )
pangolin::SaveWindowOnRender("window");
if( pangolin::Pushed(save_cube) )
d_cam.SaveOnRender("cube");
if( pangolin::Pushed(record_cube) )
pangolin::DisplayBase().RecordOnRender("ffmpeg:[fps=50,bps=8388608,unique_filename]//screencap.avi");
// Activate efficiently by object
d_cam.Activate(s_cam);
// Render some stuff
glColor3f(1.0,1.0,1.0);
pangolin::glDrawColouredCube();
// Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimpleDisplayImage main.cpp)
target_link_libraries(SimpleDisplayImage ${Pangolin_LIBRARIES})

View File

@@ -1,72 +0,0 @@
#include <limits>
#include <iostream>
#include <pangolin/pangolin.h>
void setImageData(unsigned char * imageArray, int size){
for(int i = 0 ; i < size;i++) {
imageArray[i] = (unsigned char)(rand()/(RAND_MAX/255.0));
}
}
int main(/*int argc, char* argv[]*/)
{
// Create OpenGL window in single line
pangolin::CreateWindowAndBind("Main",640,480);
// 3D Mouse handler requires depth testing to be enabled
glEnable(GL_DEPTH_TEST);
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
pangolin::ModelViewLookAt(-1,1,-1, 0,0,0, pangolin::AxisY)
);
// Aspect ratio allows us to constrain width and height whilst fitting within specified
// bounds. A positive aspect ratio makes a view 'shrink to fit' (introducing empty bars),
// whilst a negative ratio makes the view 'grow to fit' (cropping the view).
pangolin::View& d_cam = pangolin::Display("cam")
.SetBounds(0,1.0f,0,1.0f,-640/480.0)
.SetHandler(new pangolin::Handler3D(s_cam));
// This view will take up no more than a third of the windows width or height, and it
// will have a fixed aspect ratio to match the image that it will display. When fitting
// within the specified bounds, push to the top-left (as specified by SetLock).
pangolin::View& d_image = pangolin::Display("image")
.SetBounds(2/3.0f,1.0f,0,1/3.0f,640.0/480)
.SetLock(pangolin::LockLeft, pangolin::LockTop);
std::cout << "Resize the window to experiment with SetBounds, SetLock and SetAspect." << std::endl;
std::cout << "Notice that the cubes aspect is maintained even though it covers the whole screen." << std::endl;
const int width = 64;
const int height = 48;
unsigned char* imageArray = new unsigned char[3*width*height];
pangolin::GlTexture imageTexture(width,height,GL_RGB,false,0,GL_RGB,GL_UNSIGNED_BYTE);
// Default hooks for exiting (Esc) and fullscreen (tab).
while(!pangolin::ShouldQuit())
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
glColor3f(1.0,1.0,1.0);
pangolin::glDrawColouredCube();
//Set some random image data and upload to GPU
setImageData(imageArray,3*width*height);
imageTexture.Upload(imageArray,GL_RGB,GL_UNSIGNED_BYTE);
//display the image
d_image.Activate();
glColor3f(1.0,1.0,1.0);
imageTexture.RenderToViewport();
pangolin::FinishFrame();
}
delete[] imageArray;
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimpleMultiDisplay main.cpp)
target_link_libraries(SimpleMultiDisplay ${Pangolin_LIBRARIES})

View File

@@ -1,28 +0,0 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Pangolin Sample configuration file
% Comments start with '%' or '#'
%
% Declarations are name value pairs,
% seperated with '=' and terminated with ';'
% We can set any variable referenced in code directly
ui.A Double = 3.2;
% We can set unreferenced variables too
a.b = 1;
a.c = 2;
z.b = 3;
z.c = 4;
start = z;
% Which we might refer to by reference
ui.An Int = ${${start}.c};
% Declarations can span multiple lines
M =
[1, 0, 0
0, 1, 0
0, 0, 1];
ui.Aliased Double = @ui.A Double;
ui.Aliased Double = 2.0;

View File

@@ -1,106 +0,0 @@
#include <iostream>
#include <pangolin/pangolin.h>
void setImageData(unsigned char * imageArray, int size){
for(int i = 0 ; i < size;i++) {
imageArray[i] = (unsigned char)(rand()/(RAND_MAX/255.0));
}
}
int main(/*int argc, char* argv[]*/)
{
// Create OpenGL window in single line
pangolin::CreateWindowAndBind("Main",640,480);
// 3D Mouse handler requires depth testing to be enabled
glEnable(GL_DEPTH_TEST);
// Issue specific OpenGl we might need
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// Define Camera Render Object (for view / scene browsing)
pangolin::OpenGlMatrix proj = pangolin::ProjectionMatrix(640,480,420,420,320,240,0.1,1000);
pangolin::OpenGlRenderState s_cam(proj, pangolin::ModelViewLookAt(1,0.5,-2,0,0,0, pangolin::AxisY) );
pangolin::OpenGlRenderState s_cam2(proj, pangolin::ModelViewLookAt(0,0,-2,0,0,0, pangolin::AxisY) );
// Add named OpenGL viewport to window and provide 3D Handler
pangolin::View& d_cam1 = pangolin::Display("cam1")
.SetAspect(640.0f/480.0f)
.SetHandler(new pangolin::Handler3D(s_cam));
pangolin::View& d_cam2 = pangolin::Display("cam2")
.SetAspect(640.0f/480.0f)
.SetHandler(new pangolin::Handler3D(s_cam2));
pangolin::View& d_cam3 = pangolin::Display("cam3")
.SetAspect(640.0f/480.0f)
.SetHandler(new pangolin::Handler3D(s_cam));
pangolin::View& d_cam4 = pangolin::Display("cam4")
.SetAspect(640.0f/480.0f)
.SetHandler(new pangolin::Handler3D(s_cam2));
pangolin::View& d_img1 = pangolin::Display("img1")
.SetAspect(640.0f/480.0f);
pangolin::View& d_img2 = pangolin::Display("img2")
.SetAspect(640.0f/480.0f);
// LayoutEqual is an EXPERIMENTAL feature - it requires that all sub-displays
// share the same aspect ratio, placing them in a raster fasion in the
// viewport so as to maximise display size.
pangolin::Display("multi")
.SetBounds(0.0, 1.0, 0.0, 1.0)
.SetLayout(pangolin::LayoutEqual)
.AddDisplay(d_cam1)
.AddDisplay(d_img1)
.AddDisplay(d_cam2)
.AddDisplay(d_img2)
.AddDisplay(d_cam3)
.AddDisplay(d_cam4);
const int width = 64;
const int height = 48;
unsigned char* imageArray = new unsigned char[3*width*height];
pangolin::GlTexture imageTexture(width,height,GL_RGB,false,0,GL_RGB,GL_UNSIGNED_BYTE);
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Generate random image and place in texture memory for display
setImageData(imageArray,3*width*height);
imageTexture.Upload(imageArray,GL_RGB,GL_UNSIGNED_BYTE);
glColor3f(1.0,1.0,1.0);
d_cam1.Activate(s_cam);
pangolin::glDrawColouredCube();
d_cam2.Activate(s_cam2);
pangolin::glDrawColouredCube();
d_cam3.Activate(s_cam);
pangolin::glDrawColouredCube();
d_cam4.Activate(s_cam2);
pangolin::glDrawColouredCube();
d_img1.Activate();
glColor4f(1.0f,1.0f,1.0f,1.0f);
imageTexture.RenderToViewport();
d_img2.Activate();
glColor4f(1.0f,1.0f,1.0f,1.0f);
imageTexture.RenderToViewport();
// Swap frames and Process Events
pangolin::FinishFrame();
}
delete[] imageArray;
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimplePlot main.cpp)
target_link_libraries(SimplePlot ${Pangolin_LIBRARIES})

View File

@@ -1,49 +0,0 @@
#include <iostream>
#include <pangolin/pangolin.h>
int main(/*int argc, char* argv[]*/)
{
// Create OpenGL window in single line
pangolin::CreateWindowAndBind("Main",640,480);
// Data logger object
pangolin::DataLog log;
// Optionally add named labels
std::vector<std::string> labels;
labels.push_back(std::string("sin(t)"));
labels.push_back(std::string("cos(t)"));
labels.push_back(std::string("sin(t)+cos(t)"));
log.SetLabels(labels);
const float tinc = 0.01f;
// OpenGL 'view' of data. We might have many views of the same data.
pangolin::Plotter plotter(&log,0.0f,4.0f*(float)M_PI/tinc,-2.0f,2.0f,(float)M_PI/(4.0f*tinc),0.5f);
plotter.SetBounds(0.0, 1.0, 0.0, 1.0);
plotter.Track("$i");
// Add some sample annotations to the plot
plotter.AddMarker(pangolin::Marker::Vertical, -1000, pangolin::Marker::LessThan, pangolin::Colour::Blue().WithAlpha(0.2f) );
plotter.AddMarker(pangolin::Marker::Horizontal, 100, pangolin::Marker::GreaterThan, pangolin::Colour::Red().WithAlpha(0.2f) );
plotter.AddMarker(pangolin::Marker::Horizontal, 10, pangolin::Marker::Equal, pangolin::Colour::Green().WithAlpha(0.2f) );
pangolin::DisplayBase().AddDisplay(plotter);
float t = 0;
// Default hooks for exiting (Esc) and fullscreen (tab).
while( !pangolin::ShouldQuit() )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
log.Log(sin(t),cos(t),sin(t)+cos(t));
t += tinc;
// Render graph, Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimpleRecord main.cpp)
target_link_libraries(SimpleRecord ${Pangolin_LIBRARIES})

View File

@@ -1,94 +0,0 @@
#include <pangolin/pangolin.h>
void RecordSample(const std::string input_uri, const std::string record_uri)
{
// Setup Video Source
pangolin::VideoInput video(input_uri);
const pangolin::PixelFormat vid_fmt = video.PixFormat();
const unsigned w = video.Width();
const unsigned h = video.Height();
pangolin::VideoOutput recorder( record_uri );
recorder.SetStreams(video.Streams());
// Create OpenGL window
pangolin::CreateWindowAndBind("Main",w,h);
// Create viewport for video with fixed aspect
pangolin::View vVideo((float)w/h);
// OpenGl Texture for video frame
pangolin::GlTexture texVideo(w,h,GL_RGBA);
// Allocate image buffer. The +1 is to give ffmpeg some alignment slack
// swscale seems to have a bug which goes over the array by 1...
unsigned char* img = new unsigned char[video.SizeBytes() + 1];
while( !pangolin::ShouldQuit() )
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
if( video.GrabNext(img,true) )
{
// Upload to GPU as texture for display
texVideo.Upload(img, vid_fmt.channels==1 ? GL_LUMINANCE:GL_RGB, GL_UNSIGNED_BYTE);
// Record video frame
recorder.WriteStreams(img);
}
// Activate video viewport and render texture
vVideo.Activate();
texVideo.RenderToViewportFlipY();
// Swap back buffer with front and process window events
pangolin::FinishFrame();
}
delete[] img;
}
int main( int argc, char* argv[] )
{
std::string record_uri = "ffmpeg:[fps=30,bps=8388608]//video.avi";
std::string input_uris[] = {
"dc1394:[fps=30,dma=10,size=640x480,iso=400]//0",
"convert:[fmt=RGB24]//v4l:///dev/video0",
"convert:[fmt=RGB24]//v4l:///dev/video1",
""
};
if( argc >= 2 ) {
const std::string uri = std::string(argv[1]);
if( argc == 3 ) {
record_uri = std::string(argv[2]);
}
RecordSample(uri, record_uri);
}else{
std::cout << "Usage : SimpleRecord [video-uri] [output-uri]" << std::endl << std::endl;
std::cout << "Where video-uri describes a stream or file resource, e.g." << std::endl;
std::cout << "\tfile:[realtime=1]///home/user/video/movie.pvn" << std::endl;
std::cout << "\tfile:///home/user/video/movie.avi" << std::endl;
std::cout << "\tfiles:///home/user/seqiemce/foo%03d.jpeg" << std::endl;
std::cout << "\tdc1394:[fmt=RGB24,size=640x480,fps=30,iso=400,dma=10]//0" << std::endl;
std::cout << "\tdc1394:[fmt=FORMAT7_1,size=640x480,pos=2+2,iso=400,dma=10]//0" << std::endl;
std::cout << "\tv4l:///dev/video0" << std::endl;
std::cout << "\tconvert:[fmt=RGB24]//v4l:///dev/video0" << std::endl;
std::cout << "\tmjpeg://http://127.0.0.1/?action=stream" << std::endl;
std::cout << std::endl;
// Try to open some video device
for(int i=0; !input_uris[i].empty(); ++i )
{
try{
std::cout << "Trying: " << input_uris[i] << std::endl;
RecordSample(input_uris[i], record_uri);
return 0;
}catch(const pangolin::VideoException&) {}
}
}
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimpleScene main.cpp)
target_link_libraries(SimpleScene ${Pangolin_LIBRARIES})

View File

@@ -1,40 +0,0 @@
#include <pangolin/pangolin.h>
#include <pangolin/scene/axis.h>
#include <pangolin/scene/scenehandler.h>
int main( int /*argc*/, char** /*argv*/ )
{
pangolin::CreateWindowAndBind("Main",640,480);
glEnable(GL_DEPTH_TEST);
// Define Projection and initial ModelView matrix
pangolin::OpenGlRenderState s_cam(
pangolin::ProjectionMatrix(640,480,420,420,320,240,0.2,100),
pangolin::ModelViewLookAt(-2,2,-2, 0,0,0, pangolin::AxisY)
);
pangolin::Renderable tree;
tree.Add( std::make_shared<pangolin::Axis>() );
// Create Interactive View in window
pangolin::SceneHandler handler(tree, s_cam);
pangolin::View& d_cam = pangolin::CreateDisplay()
.SetBounds(0.0, 1.0, 0.0, 1.0, -640.0f/480.0f)
.SetHandler(&handler);
d_cam.SetDrawFunction([&](pangolin::View& view){
view.Activate(s_cam);
tree.Render();
});
while( !pangolin::ShouldQuit() )
{
// Clear screen and activate view to render into
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}

View File

@@ -1,6 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
add_executable(SimpleVideo main.cpp)
target_link_libraries(SimpleVideo ${Pangolin_LIBRARIES})

View File

@@ -1,111 +0,0 @@
/**
* @author Steven Lovegrove
* Copyright (C) 2010 Steven Lovegrove
* Imperial College London
**/
#include <pangolin/pangolin.h>
void SetGlFormat(GLint& glformat, GLenum& gltype, const pangolin::PixelFormat& fmt)
{
switch( fmt.channels) {
case 1: glformat = GL_LUMINANCE; break;
case 3: glformat = GL_RGB; break;
case 4: glformat = GL_RGBA; break;
default: throw std::runtime_error("Unable to display video format");
}
switch (fmt.channel_bits[0]) {
case 8: gltype = GL_UNSIGNED_BYTE; break;
case 16: gltype = GL_UNSIGNED_SHORT; break;
case 32: gltype = GL_FLOAT; break;
default: throw std::runtime_error("Unknown channel format");
}
}
void VideoSample(const std::string uri)
{
// Setup Video Source
pangolin::VideoInput video(uri);
const pangolin::PixelFormat vid_fmt = video.PixFormat();
const unsigned w = video.Width();
const unsigned h = video.Height();
// Work out appropriate GL channel and format options
GLint glformat;
GLenum gltype;
SetGlFormat(glformat, gltype, vid_fmt);
// Create OpenGL window
pangolin::CreateWindowAndBind("Main",w,h);
// Create viewport for video with fixed aspect
pangolin::View& vVideo = pangolin::Display("Video").SetAspect((float)w/h);
// OpenGl Texture for video frame.
pangolin::GlTexture texVideo(w,h,glformat,false,0,glformat,gltype);
unsigned char* img = new unsigned char[video.SizeBytes()];
for(int frame=0; !pangolin::ShouldQuit(); ++frame)
{
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
if( video.GrabNext(img,true) ) {
texVideo.Upload( img, glformat, gltype );
}
// Activate video viewport and render texture
vVideo.Activate();
texVideo.RenderToViewportFlipY();
// Swap back buffer with front and process window events
pangolin::FinishFrame();
}
delete[] img;
}
int main( int argc, char* argv[] )
{
std::string uris[] = {
"dc1394:[fps=30,dma=10,size=640x480,iso=400]//0",
"convert:[fmt=RGB24]//v4l:///dev/video0",
"convert:[fmt=RGB24]//v4l:///dev/video1",
"openni:[img1=rgb]//",
"pleora:[sn=00000215,size=640x480,pos=64x64]//",
"test:[size=160x120,n=1,fmt=RGB24]//"
""
};
if( argc > 1 ) {
const std::string uri = std::string(argv[1]);
VideoSample(uri);
}else{
std::cout << "Usage : SimpleRecord [video-uri]" << std::endl << std::endl;
std::cout << "Where video-uri describes a stream or file resource, e.g." << std::endl;
std::cout << "\tfile:[realtime=1]///home/user/video/movie.pvn" << std::endl;
std::cout << "\tfile:///home/user/video/movie.avi" << std::endl;
std::cout << "\tfiles:///home/user/seqiemce/foo%03d.jpeg" << std::endl;
std::cout << "\tdc1394:[fmt=RGB24,size=640x480,fps=30,iso=400,dma=10]//0" << std::endl;
std::cout << "\tdc1394:[fmt=FORMAT7_1,size=640x480,pos=2+2,iso=400,dma=10]//0" << std::endl;
std::cout << "\tv4l:///dev/video0" << std::endl;
std::cout << "\tconvert:[fmt=RGB24]//v4l:///dev/video0" << std::endl;
std::cout << "\tmjpeg://http://127.0.0.1/?action=stream" << std::endl;
std::cout << "\topenni:[img1=rgb]//" << std::endl;
std::cout << std::endl;
// Try to open some video device
for(int i=0; !uris[i].empty(); ++i )
{
try{
std::cout << "Trying: " << uris[i] << std::endl;
VideoSample(uris[i]);
return 0;
}catch(const pangolin::VideoException&) { }
}
}
return 0;
}

View File

@@ -1,19 +0,0 @@
# Find Pangolin (https://github.com/stevenlovegrove/Pangolin)
find_package(Pangolin 0.4 REQUIRED)
include_directories(${Pangolin_INCLUDE_DIRS})
link_directories(${Pangolin_LIBRARY_DIRS})
link_libraries(${Pangolin_LIBRARIES})
find_package(CUDA QUIET)
# This example could be made to work with C++11, but the kernel code must be
# compiled without it.
if(CUDA_FOUND)
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
cuda_add_executable(
VBODisplay
main.cpp kernal.cu
)
endif()

View File

@@ -1,30 +0,0 @@
// Colour Sine wave Kernal
// Based on kernal_colour in kernelVBO.cpp by Rob Farber
__global__ void kernel(float4* dVertexArray, uchar4 *dColorArray,
unsigned int width, unsigned int height, float time)
{
unsigned int x = blockIdx.x*blockDim.x + threadIdx.x;
unsigned int y = blockIdx.y*blockDim.y + threadIdx.y;
// Each thread is unique point (u,v) in interval [-1,1],[-1,1]
const float u = 2.0f* (x/(float)width) - 1.0f;
const float v = 2.0f* (y/(float)height) - 1.0f;
const float w = 0.5f * sinf(4.0f*u + time) * cosf(4.0f*v + time);
// Update vertex array for point
dVertexArray[y*width+x] = make_float4(u, w, v, 1.0f);
// Update colour array for point
dColorArray[y*width+x].w = 0.0f;
dColorArray[y*width+x].x = 255.0f *0.5f*(1.f+sinf(w+x));
dColorArray[y*width+x].y = 255.0f *0.5f*(1.f+sinf(x)*cosf(y));
dColorArray[y*width+x].z = 255.0f *0.5f*(1.f+sinf(w+time/10.0f));
}
extern "C" void launch_kernel(float4* dVertexArray, uchar4* dColourArray,
unsigned int width, unsigned int height, float time)
{
dim3 block(8, 8, 1);
dim3 grid(width / block.x, height / block.y, 1);
kernel<<< grid, block>>>(dVertexArray, dColourArray, width, height, time);
}

View File

@@ -1,84 +0,0 @@
#include <iostream>
#include <GL/glew.h>
#include <pangolin/pangolin.h>
#include <pangolin/gl/glcuda.h>
#include <pangolin/gl/glvbo.h>
#include <cuda_runtime.h>
#include <cuda_gl_interop.h>
#include <vector_types.h>
using namespace pangolin;
using namespace std;
// Mesh size
const int mesh_width=256;
const int mesh_height=256;
extern "C" void launch_kernel(float4* dVertexArray, uchar4* dColourArray, unsigned int width, unsigned int height, float time);
int main( int /*argc*/, char* argv[] )
{
// cudaGLSetGLDevice(0);
pangolin::CreateWindowAndBind("Main",640,480);
glewInit();
// 3D Mouse handler requires depth testing to be enabled
glEnable(GL_DEPTH_TEST);
// Create vertex and colour buffer objects and register them with CUDA
GlBufferCudaPtr vertex_array(
GlArrayBuffer, mesh_width*mesh_height, GL_FLOAT, 4,
cudaGraphicsMapFlagsWriteDiscard, GL_STREAM_DRAW
);
GlBufferCudaPtr colour_array(
GlArrayBuffer, mesh_width*mesh_height, GL_UNSIGNED_BYTE, 4,
cudaGraphicsMapFlagsWriteDiscard, GL_STREAM_DRAW
);
// Define Camera Render Object (for view / scene browsing)
pangolin::OpenGlRenderState s_cam(
ProjectionMatrix(640,480,420,420,320,240,0.1,1000),
ModelViewLookAt(-0,2,-2, 0,0,0, AxisY)
);
const int UI_WIDTH = 180;
// Add named OpenGL viewport to window and provide 3D Handler
View& d_cam = pangolin::Display("cam")
.SetBounds(0.0, 1.0, Attach::Pix(UI_WIDTH), 1.0, -640.0f/480.0f)
.SetHandler(new Handler3D(s_cam));
// Add named Panel and bind to variables beginning 'ui'
// A Panel is just a View with a default layout and input handling
View& d_panel = pangolin::CreatePanel("ui")
.SetBounds(0.0, 1.0, 0.0, Attach::Pix(UI_WIDTH));
// Default hooks for exiting (Esc) and fullscreen (tab).
for(int frame=0; !pangolin::ShouldQuit(); ++frame)
{
static double time = 0;
static Var<double> delta("ui.time delta", 0.001, 0, 0.005);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
d_cam.Activate(s_cam);
glColor3f(1.0,1.0,1.0);
{
CudaScopedMappedPtr var(vertex_array);
CudaScopedMappedPtr car(colour_array);
launch_kernel((float4*)*var,(uchar4*)*car,mesh_width,mesh_height,time);
time += delta;
}
pangolin::RenderVboCbo(vertex_array, colour_array);
// Swap frames and Process Events
pangolin::FinishFrame();
}
return 0;
}

View File

@@ -1,153 +0,0 @@
include(ExternalProject)
set(ExternConfig "")
if( BUILD_EXTERN_GLEW )
#########################################################
# GLEW
#########################################################
ExternalProject_Add( __glew
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/glew"
GIT_REPOSITORY https://github.com/Perlmint/glew-cmake.git
GIT_TAG 7574ab4d00b683e56adbfdec7da636529dfe65d8
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
)
add_library(_glew STATIC IMPORTED GLOBAL)
add_dependencies(_glew __glew)
set_target_properties(_glew PROPERTIES
IMPORTED_LOCATION_RELWITHDEBINFO ${CMAKE_INSTALL_PREFIX}/lib/glew.lib
IMPORTED_LOCATION_RELEASE ${CMAKE_INSTALL_PREFIX}/lib/glew.lib
IMPORTED_LOCATION_DEBUG ${CMAKE_INSTALL_PREFIX}/lib/glewd.lib
)
set(GLEW_FOUND true PARENT_SCOPE)
set(GLEW_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" PARENT_SCOPE)
set(GLEW_LIBRARY _glew PARENT_SCOPE)
set(GLEW_STATIC 1 PARENT_SCOPE)
set(ExternConfig "${ExternConfig}
add_library(_glew STATIC IMPORTED)
set_target_properties(_glew PROPERTIES
IMPORTED_LOCATION_RELWITHDEBINFO \"${CMAKE_INSTALL_PREFIX}/lib/glew.lib\"
IMPORTED_LOCATION_RELEASE \"${CMAKE_INSTALL_PREFIX}/lib/glew.lib\"
IMPORTED_LOCATION_DEBUG \"${CMAKE_INSTALL_PREFIX}/lib/glewd.lib\"
)")
endif()
if( BUILD_EXTERN_LIBPNG )
#########################################################
# zlib
#########################################################
ExternalProject_Add( __zlib
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/zlib"
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG v1.2.8
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
)
add_library(_zlib STATIC IMPORTED GLOBAL)
add_dependencies(_zlib __zlib)
set_target_properties(_zlib PROPERTIES
IMPORTED_LOCATION_RELEASE ${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib
IMPORTED_LOCATION_RELWITHDEBINFO ${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib
IMPORTED_LOCATION_DEBUG ${CMAKE_INSTALL_PREFIX}/lib/zlibstaticd.lib
)
#########################################################
# libpng
#########################################################
ExternalProject_Add( __libpng
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libpng"
GIT_REPOSITORY https://github.com/glennrp/libpng.git
GIT_TAG v1.6.18
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DZLIB_INCLUDE_DIR=${CMAKE_INSTALL_PREFIX}/include
-DZLIB_LIBRARY=${CMAKE_INSTALL_PREFIX}/lib/zlibstatic*.lib
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
DEPENDS __zlib
)
add_library(_libpng STATIC IMPORTED GLOBAL)
add_dependencies(_libpng __libpng)
set_target_properties(_libpng PROPERTIES
IMPORTED_LOCATION_RELWITHDEBINFO ${CMAKE_INSTALL_PREFIX}/lib/libpng16_static.lib
IMPORTED_LOCATION_RELEASE ${CMAKE_INSTALL_PREFIX}/lib/libpng16_static.lib
IMPORTED_LOCATION_DEBUG ${CMAKE_INSTALL_PREFIX}/lib/libpng16_staticd.lib
)
set(PNG_FOUND true PARENT_SCOPE)
set(PNG_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" PARENT_SCOPE)
set(PNG_LIBRARY _libpng PARENT_SCOPE)
set(ZLIB_LIBRARY _zlib PARENT_SCOPE)
set(ExternConfig "${ExternConfig}
add_library(_zlib STATIC IMPORTED)
set_target_properties(_zlib PROPERTIES
IMPORTED_LOCATION_RELEASE \"${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib\"
IMPORTED_LOCATION_RELWITHDEBINFO \"${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib\"
IMPORTED_LOCATION_DEBUG \"${CMAKE_INSTALL_PREFIX}/lib/zlibstaticd.lib\"
)
add_library(_libpng STATIC IMPORTED)
set_target_properties(_libpng PROPERTIES
IMPORTED_LOCATION_RELEASE \"${CMAKE_INSTALL_PREFIX}/lib/libpng16_static.lib\"
IMPORTED_LOCATION_RELWITHDEBINFO \"${CMAKE_INSTALL_PREFIX}/lib/libpng16_static.lib\"
IMPORTED_LOCATION_DEBUG \"${CMAKE_INSTALL_PREFIX}/lib/libpng16_staticd.lib\"
)")
endif()
if( BUILD_EXTERN_LIBJPEG )
#########################################################
# libjpg
#########################################################
ExternalProject_Add( __libjpeg
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/libjpeg"
GIT_REPOSITORY https://github.com/LuaDist/libjpeg.git
GIT_TAG bc8f8be222287fec977ec3f47a5cb065cceb2ee9
INSTALL_DIR ${CMAKE_INSTALL_PREFIX}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DBUILD_SHARED_LIBS=false
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_FLAGS_RELEASE=${CMAKE_C_FLAGS_RELEASE}
-DCMAKE_C_FLAGS_DEBUG=${CMAKE_C_FLAGS_DEBUG}
-DCMAKE_C_FLAGS_MINSIZEREL=${CMAKE_C_FLAGS_MINSIZEREL}
-DCMAKE_C_FLAGS_RELWITHDEBINFO=${CMAKE_C_FLAGS_RELWITHDEBINFO}
)
add_library(_libjpeg STATIC IMPORTED GLOBAL)
add_dependencies(_libjpeg __libjpeg)
set_target_properties(_libjpeg PROPERTIES
IMPORTED_LOCATION ${CMAKE_INSTALL_PREFIX}/lib/jpeg.lib
)
set(JPEG_FOUND true PARENT_SCOPE)
set(JPEG_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include" PARENT_SCOPE)
set(JPEG_LIBRARY _libjpeg PARENT_SCOPE)
set(ExternConfig "${ExternConfig}
add_library(_libjpeg STATIC IMPORTED)
set_target_properties(_libjpeg PROPERTIES
IMPORTED_LOCATION \"${CMAKE_INSTALL_PREFIX}/lib/jpeg.lib\"
)")
endif()
set(ExternConfig "${ExternConfig}" PARENT_SCOPE)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/gl/glplatform.h>
#include <pangolin/gl/glfont.h>
#ifdef HAVE_GLES
GLfloat g_raster_pos[4];
inline void glRasterPos3f(GLfloat x, GLfloat y, GLfloat z)
{
// find object point (x,y,z)' in pixel coords
GLdouble projection[16];
GLdouble modelview[16];
GLint view[4];
#ifdef HAVE_GLES_2
std::copy(pangolin::glEngine().projection.top().m, pangolin::glEngine().projection.top().m+16, projection);
std::copy(pangolin::glEngine().modelview.top().m, pangolin::glEngine().modelview.top().m+16, modelview);
#else
glGetDoublev(GL_PROJECTION_MATRIX, projection );
glGetDoublev(GL_MODELVIEW_MATRIX, modelview );
#endif
glGetIntegerv(GL_VIEWPORT, view );
pangolin::glProject(x, y, z, modelview, projection, view,
g_raster_pos, g_raster_pos + 1, g_raster_pos + 2);
}
inline void glRasterPos2f(GLfloat x, GLfloat y)
{
glRasterPos3f(x,y,1.0f);
}
inline void glRasterPos2i(GLint x, GLint y)
{
glRasterPos3f((GLfloat)x, (GLfloat)y, 1.0f );
}
inline void glRasterPos3fv(const GLfloat *v){
glRasterPos3f(v[0],v[1],v[2]);
}
inline void glRasterPos2fv(const GLfloat *v){
glRasterPos3f(v[0],v[1],1.0f);
}
#endif // HAVE_GLES
inline void glutBitmapString(void * /*font*/, const unsigned char *str)
{
#ifndef HAVE_GLES
float g_raster_pos[4];
glGetFloatv(GL_CURRENT_RASTER_POSITION, g_raster_pos);
#endif
pangolin::GlFont::I().Text( (const char *)str ).DrawWindow(
g_raster_pos[0], g_raster_pos[1], g_raster_pos[2]
);
}
inline int glutBitmapLength(void * /*font*/, const unsigned char *str)
{
return (int)(pangolin::GlFont::I().Text((const char *)str).Width());
}
#define GLUT_BITMAP_HELVETICA_12 0;

View File

@@ -1,20 +0,0 @@
#pragma once
#include <pangolin/platform.h>
// Use either C++17 optional, or the standalone backwards compatible version
#if (__cplusplus >= 201703L)
# include <optional>
#else
# include <experimental/optional.hpp>
#endif
namespace pangolin {
#if (__cplusplus >= 201703L)
template <typename T>
using optional = std::optional<T>;
#else
template <typename T>
using optional = std::experimental::optional<T>;
#endif
}

View File

@@ -1,49 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <typeinfo>
#include <type_traits>
// enable_if From Boost
namespace pangolin
{
template <bool B, class T = void>
struct enable_if_c {
typedef T type;
};
template <class T>
struct enable_if_c<false, T> {};
template <class Cond, class T = void>
struct enable_if : public enable_if_c<Cond::value, T> {};
}

View File

@@ -1,25 +0,0 @@
#pragma once
#include <pangolin/platform.h>
// Use either C++17 variant, or the standalone backwards compatible version
// of M. Park.
#if (__cplusplus >= 201703L)
# include <variant>
#else
# include <mpark/variant.hpp>
#endif
namespace pangolin {
#if (__cplusplus >= 201703L)
using std::variant;
using std::get;
using std::get_if;
using std::visit;
#else
using mpark::variant;
using mpark::get;
using mpark::get_if;
using mpark::visit;
#endif
}

View File

@@ -1,80 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <vector>
#include <string>
namespace pangolin
{
enum ConsoleLineType
{
ConsoleLineTypeCmd,
ConsoleLineTypeCmdOptions,
ConsoleLineTypeStdout,
ConsoleLineTypeStderr,
ConsoleLineTypeOutput,
ConsoleLineTypeHelp,
};
class ConsoleLine
{
public:
inline ConsoleLine()
: linetype(ConsoleLineTypeCmd)
{
}
inline ConsoleLine(std::string text, ConsoleLineType linetype = ConsoleLineTypeOutput)
: text(text), linetype(linetype)
{
}
std::string text;
ConsoleLineType linetype;
};
class ConsoleInterpreter
{
public:
inline virtual ~ConsoleInterpreter()
{
}
virtual void PushCommand(const std::string& cmd) = 0;
virtual bool PullLine(ConsoleLine& line) = 0;
virtual std::vector<std::string> Complete(
const std::string& cmd, int max_options = 20
) = 0;
};
}

View File

@@ -1,109 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <deque>
#include <pangolin/platform.h>
#include <pangolin/gl/glfont.h>
#include <pangolin/var/var.h>
#include <pangolin/display/view.h>
#include <pangolin/handler/handler.h>
#include <pangolin/gl/colour.h>
#include <pangolin/console/ConsoleInterpreter.h>
namespace pangolin
{
class ConsoleView : public pangolin::View, pangolin::Handler
{
public:
struct Line
{
Line()
: linetype(ConsoleLineTypeCmd)
{
}
Line(const GlText& text, ConsoleLineType linetype = ConsoleLineTypeCmd )
: text(text), linetype(linetype)
{
}
GlText text;
ConsoleLineType linetype;
};
// Construct with interpreter (and take ownership)
ConsoleView(ConsoleInterpreter* interpreter);
~ConsoleView();
View& ShowWithoutAnimation(bool show=true);
// Replace implementation in View to account for hiding animation
View& Show(bool show=true);
// Replace implementation in View to account for hiding animation
void ToggleShow();
// Replace implementation in View to account for hiding animation
bool IsShown() const;
void Render() override;
void Keyboard(View&, unsigned char key, int x, int y, bool pressed) override;
private:
void DrawLine(const ConsoleView::Line& l, int carat);
void ProcessOutputLines();
void AddLine(const std::string& text, ConsoleLineType linetype = ConsoleLineTypeCmd);
Line* GetLine(int id, ConsoleLineType line_type, const std::string& prefix = "");
ConsoleInterpreter* interpreter;
GlFont& font;
int carat;
Line current_line;
std::deque<Line> line_buffer;
bool hiding;
GLfloat bottom;
Colour background_colour;
std::map<ConsoleLineType,pangolin::Colour> line_colours;
float animation_speed;
};
}

View File

@@ -1,86 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <iostream>
#include <string>
#include <cmath>
namespace pangolin
{
/// Units for measuring screen distances.
enum Unit {
Fraction,
Pixel,
ReversePixel
};
/// Defines absolute or relative position from parent viewport edge.
/// Constructors distinguised by whole pixels, or floating
/// fraction in interval [0,1]
struct PANGOLIN_EXPORT Attach {
/// Attach to Left/Bottom edge
Attach() : unit(Fraction), p(0) {}
/// General constructor
Attach(Unit unit, GLfloat p) : unit(unit), p(p) {}
/// Specify relative position in range [0,1].
/// 0 represents leftmost / bottom-most edge,
/// 1 represents rightmost / topmost edge
Attach(GLfloat p) : unit(Fraction), p(p) {
// Allow for numerical imprecision when checking usage.
if( p < -1E-3 || 1.001 < p ) {
std::cerr << "Pangolin API Change: Display::SetBounds must be used with Attach::Pix or Attach::ReversePix to specify pixel bounds relative to an edge. See the code samples for details." << std::endl;
throw std::exception();
}
}
/// Specify absolute position from leftmost / bottom-most edge.
static Attach Pix(int p) {
return Attach(p >=0 ? Pixel : ReversePixel, std::abs((float)p));
}
/// Specify absolute position from rightmost / topmost edge.
static Attach ReversePix(int p) {
return Attach(ReversePixel, (GLfloat)p);
}
/// Specify relative position in range [0,1].
/// 0 represents leftmost / bottom-most edge,
/// 1 represents rightmost / topmost edge
static Attach Frac(float frac) {
return Attach(frac);
}
Unit unit;
GLfloat p;
};
} // namespace pangolin

View File

@@ -1,68 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <pangolin/display/display_internal.h>
#include <pangolin/display/device/PangolinNSApplication.h>
#include <pangolin/display/device/PangolinNSGLView.h>
namespace pangolin
{
struct OsxWindow : public PangolinGl
{
OsxWindow(const std::string& title, int width, int height, bool USE_RETINA);
~OsxWindow();
void StartFullScreen();
void StopFullScreen();
void ToggleFullscreen() override;
void Move(int x, int y) override;
void Resize(unsigned int w, unsigned int h) override;
void MakeCurrent() override;
void RemoveCurrent() override;
void SwapBuffers() override;
void ProcessEvents() override;
private:
NSWindow* _window;
PangolinNSGLView *view;
};
}

View File

@@ -1,59 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
////////////////////////////////////////////////////////////////////
// PangolinNSApplication
////////////////////////////////////////////////////////////////////
@interface PangolinNSApplication : NSObject {
}
+ (void)run_pre;
+ (void)run_step;
@end
////////////////////////////////////////////////////////////////////
// PangolinWindowDelegate
////////////////////////////////////////////////////////////////////
@interface PangolinWindowDelegate : NSObject <NSWindowDelegate>
@end
////////////////////////////////////////////////////////////////////
// PangolinAppDelegate
////////////////////////////////////////////////////////////////////
@interface PangolinAppDelegate : NSObject <NSApplicationDelegate>
@end

View File

@@ -1,45 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#import <Carbon/Carbon.h>
#import <Cocoa/Cocoa.h>
#include <pangolin/display/display_internal.h>
////////////////////////////////////////////////////////////////////
// PangolinNSGLView
////////////////////////////////////////////////////////////////////
@interface PangolinNSGLView : NSOpenGLView
{
pangolin::PangolinGl* context;
float backing_scale;
}
@end

View File

@@ -1,89 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <pangolin/display/display_internal.h>
#include <string>
#include <windowsx.h>
namespace pangolin
{
struct WinWindow : public PangolinGl
{
WinWindow(
const std::string& title, int width, int height
);
~WinWindow();
void StartFullScreen();
void StopFullScreen();
void ToggleFullscreen() override;
void Move(int x, int y) override;
void Resize(unsigned int w, unsigned int h) override;
void MakeCurrent() override;
void RemoveCurrent() override;
void SwapBuffers() override;
void ProcessEvents() override;
HGLRC GetGLRenderContext()
{
return hGLRC;
}
private:
static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
LRESULT HandleWinMessages(UINT message, WPARAM wParam, LPARAM lParam);
void RegisterThisClass(HMODULE hCurrentInst);
void SetupPixelFormat(HDC hdc);
void SetupPalette(HDC hDC);
// Owns the Window
HWND hWnd;
HDC hDC;
HGLRC hGLRC;
HPALETTE hPalette;
};
}

View File

@@ -1,109 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <pangolin/display/display_internal.h>
#include <stdexcept>
#include <string>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <GL/glx.h>
namespace pangolin
{
struct X11Display
{
X11Display(const char* name = 0) {
XInitThreads();
display = XOpenDisplay(name);
if (!display) {
throw std::runtime_error("Pangolin X11: Failed to open X display");
}
}
~X11Display() {
XCloseDisplay(display);
}
// Owns the display
::Display* display;
};
struct X11GlContext : public GlContextInterface
{
X11GlContext(std::shared_ptr<X11Display> &d, ::GLXFBConfig chosenFbc, std::shared_ptr<X11GlContext> shared_context = std::shared_ptr<X11GlContext>() );
~X11GlContext();
std::shared_ptr<X11Display> display;
std::shared_ptr<X11GlContext> shared_context;
// Owns the OpenGl Context
::GLXContext glcontext;
};
struct X11Window : public PangolinGl
{
X11Window(
const std::string& title, int width, int height,
std::shared_ptr<X11Display>& display, ::GLXFBConfig chosenFbc
);
~X11Window();
void ToggleFullscreen() override;
void Move(int x, int y) override;
void Resize(unsigned int w, unsigned int h) override;
void MakeCurrent(GLXContext ctx);
void MakeCurrent() override;
void RemoveCurrent() override;
void SwapBuffers() override;
void ProcessEvents() override;
// References the X11 display and context.
std::shared_ptr<X11Display> display;
std::shared_ptr<X11GlContext> glcontext;
// Owns the X11 Window and Colourmap
::Window win;
::Colormap cmap;
Atom delete_message;
};
}

View File

@@ -1,333 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <poll.h>
#include <pthread.h>
#include <sched.h>
#include <android/configuration.h>
#include <android/looper.h>
#include <android/native_activity.h>
#include <android/log.h>
#include <string>
#include <pangolin/utils/type_convert.h>
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "pango", __VA_ARGS__))
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "pango", __VA_ARGS__))
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "pango", __VA_ARGS__))
/* For debug builds, always enable the debug traces in this library */
#undef NDEBUG
#ifndef NDEBUG
# define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "pango", __VA_ARGS__))
#else
# define LOGV(...) ((void)0)
#endif
template<typename T> inline
void Log(T v) {
const std::string sv = pangolin::Convert<std::string,T>::Do(v);
LOGI(sv.c_str());
}
template<typename T> inline
void Log(const std::string& str, T v)
{
const std::string sv = pangolin::Convert<std::string,T>::Do(v);
LOGI((str + ":" + sv).c_str());
}
namespace pangolin
{
void CreateAndroidWindowAndBind(std::string name);
void ProcessAndroidEvents();
void FinishAndroidFrame();
}
#ifdef __cplusplus
extern "C" {
#endif
struct android_app;
/**
* Data associated with an ALooper fd that will be returned as the "outData"
* when that source has data ready.
*/
struct android_poll_source {
// The identifier of this source. May be LOOPER_ID_MAIN or
// LOOPER_ID_INPUT.
int32_t id;
// The android_app this ident is associated with.
struct android_app* app;
// Function to call to perform the standard processing of data from
// this source.
void (*process)(struct android_app* app, struct android_poll_source* source);
};
/**
* This is the interface for the standard glue code of a threaded
* application. In this model, the application's code is running
* in its own thread separate from the main thread of the process.
* It is not required that this thread be associated with the Java
* VM, although it will need to be in order to make JNI calls any
* Java objects.
*/
struct android_app {
// The application can place a pointer to its own state object
// here if it likes.
void* userData;
// Fill this in with the function to process main app commands (APP_CMD_*)
void (*onAppCmd)(struct android_app* app, int32_t cmd);
// Fill this in with the function to process input events. At this point
// the event has already been pre-dispatched, and it will be finished upon
// return. Return 1 if you have handled the event, 0 for any default
// dispatching.
int32_t (*onInputEvent)(struct android_app* app, AInputEvent* event);
// The ANativeActivity object instance that this app is running in.
ANativeActivity* activity;
// The current configuration the app is running in.
AConfiguration* config;
// This is the last instance's saved state, as provided at creation time.
// It is NULL if there was no state. You can use this as you need; the
// memory will remain around until you call android_app_exec_cmd() for
// APP_CMD_RESUME, at which point it will be freed and savedState set to NULL.
// These variables should only be changed when processing a APP_CMD_SAVE_STATE,
// at which point they will be initialized to NULL and you can malloc your
// state and place the information here. In that case the memory will be
// freed for you later.
void* savedState;
size_t savedStateSize;
// The ALooper associated with the app's thread.
ALooper* looper;
// When non-NULL, this is the input queue from which the app will
// receive user input events.
AInputQueue* inputQueue;
// When non-NULL, this is the window surface that the app can draw in.
ANativeWindow* window;
// Current content rectangle of the window; this is the area where the
// window's content should be placed to be seen by the user.
ARect contentRect;
// Current state of the app's activity. May be either APP_CMD_START,
// APP_CMD_RESUME, APP_CMD_PAUSE, or APP_CMD_STOP; see below.
int activityState;
// This is non-zero when the application's NativeActivity is being
// destroyed and waiting for the app thread to complete.
int destroyRequested;
// -------------------------------------------------
// Below are "private" implementation of the glue code.
pthread_mutex_t mutex;
pthread_cond_t cond;
int msgread;
int msgwrite;
pthread_t thread;
struct android_poll_source cmdPollSource;
struct android_poll_source inputPollSource;
int running;
int stateSaved;
int destroyed;
int redrawNeeded;
AInputQueue* pendingInputQueue;
ANativeWindow* pendingWindow;
ARect pendingContentRect;
const char* application_so;
};
enum {
/**
* Looper data ID of commands coming from the app's main thread, which
* is returned as an identifier from ALooper_pollOnce(). The data for this
* identifier is a pointer to an android_poll_source structure.
* These can be retrieved and processed with android_app_read_cmd()
* and android_app_exec_cmd().
*/
LOOPER_ID_MAIN = 1,
/**
* Looper data ID of events coming from the AInputQueue of the
* application's window, which is returned as an identifier from
* ALooper_pollOnce(). The data for this identifier is a pointer to an
* android_poll_source structure. These can be read via the inputQueue
* object of android_app.
*/
LOOPER_ID_INPUT = 2,
/**
* Start of user-defined ALooper identifiers.
*/
LOOPER_ID_USER = 3,
};
enum {
/**
* Command from main thread: the AInputQueue has changed. Upon processing
* this command, android_app->inputQueue will be updated to the new queue
* (or NULL).
*/
APP_CMD_INPUT_CHANGED,
/**
* Command from main thread: a new ANativeWindow is ready for use. Upon
* receiving this command, android_app->window will contain the new window
* surface.
*/
APP_CMD_INIT_WINDOW,
/**
* Command from main thread: the existing ANativeWindow needs to be
* terminated. Upon receiving this command, android_app->window still
* contains the existing window; after calling android_app_exec_cmd
* it will be set to NULL.
*/
APP_CMD_TERM_WINDOW,
/**
* Command from main thread: the current ANativeWindow has been resized.
* Please redraw with its new size.
*/
APP_CMD_WINDOW_RESIZED,
/**
* Command from main thread: the system needs that the current ANativeWindow
* be redrawn. You should redraw the window before handing this to
* android_app_exec_cmd() in order to avoid transient drawing glitches.
*/
APP_CMD_WINDOW_REDRAW_NEEDED,
/**
* Command from main thread: the content area of the window has changed,
* such as from the soft input window being shown or hidden. You can
* find the new content rect in android_app::contentRect.
*/
APP_CMD_CONTENT_RECT_CHANGED,
/**
* Command from main thread: the app's activity window has gained
* input focus.
*/
APP_CMD_GAINED_FOCUS,
/**
* Command from main thread: the app's activity window has lost
* input focus.
*/
APP_CMD_LOST_FOCUS,
/**
* Command from main thread: the current device configuration has changed.
*/
APP_CMD_CONFIG_CHANGED,
/**
* Command from main thread: the system is running low on memory.
* Try to reduce your memory use.
*/
APP_CMD_LOW_MEMORY,
/**
* Command from main thread: the app's activity has been started.
*/
APP_CMD_START,
/**
* Command from main thread: the app's activity has been resumed.
*/
APP_CMD_RESUME,
/**
* Command from main thread: the app should generate a new saved state
* for itself, to restore from later if needed. If you have saved state,
* allocate it with malloc and place it in android_app.savedState with
* the size in android_app.savedStateSize. The will be freed for you
* later.
*/
APP_CMD_SAVE_STATE,
/**
* Command from main thread: the app's activity has been paused.
*/
APP_CMD_PAUSE,
/**
* Command from main thread: the app's activity has been stopped.
*/
APP_CMD_STOP,
/**
* Command from main thread: the app's activity is being destroyed,
* and waiting for the app thread to clean up and exit before proceeding.
*/
APP_CMD_DESTROY,
};
/**
* Call when ALooper_pollAll() returns LOOPER_ID_MAIN, reading the next
* app command message.
*/
int8_t android_app_read_cmd(struct android_app* android_app);
/**
* Call with the command returned by android_app_read_cmd() to do the
* initial pre-processing of the given command. You can perform your own
* actions for the command after calling this function.
*/
void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd);
/**
* Call with the command returned by android_app_read_cmd() to do the
* final post-processing of the given command. You must have done your own
* actions for the command before calling this function.
*/
void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd);
#ifdef __cplusplus
}
#endif

View File

@@ -1,219 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove, Richard Newcombe
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <pangolin/gl/glinclude.h>
#include <pangolin/handler/handler_enums.h>
#include <pangolin/utils/params.h>
#include <pangolin/display/window.h>
#include <functional>
#include <string>
#include <memory>
/*! \file display.h
* This file contains a number of global methods for creating and
* querying window state as well as handling user input.
*/
namespace pangolin
{
// CreateWindowAndBind parameter key names.
// X11 Window options:
extern const char* PARAM_DISPLAYNAME; // std::string
extern const char* PARAM_DOUBLEBUFFER; // bool
extern const char* PARAM_SAMPLE_BUFFERS; // int
extern const char* PARAM_SAMPLES; // int
extern const char* PARAM_HIGHRES; // bool - Apple Retina screens only
// Forward Declarations
struct View;
struct Viewport;
class UserApp;
/// Give this OpenGL context a name or switch contexts.
/// This is required to initialise Pangolin for use with an
/// externally defined OpenGL context. You needn't call it
/// if you have used CreateWindowAndBind() to create a window
/// or launched a pangolin::UserApp
PANGOLIN_EXPORT
WindowInterface& BindToContext(std::string name);
/// Initialise OpenGL window (determined by platform) and bind context.
/// This method will choose an available windowing system if one is present.
PANGOLIN_EXPORT
WindowInterface& CreateWindowAndBind(std::string window_title, int w = 640, int h = 480, const Params& params = Params());
/// Return pointer to current Pangolin Window context, or nullptr if none bound.
PANGOLIN_EXPORT
WindowInterface* GetBoundWindow();
PANGOLIN_EXPORT
void DestroyWindow(const std::string& window_title);
/// Launch users derived UserApp, controlling OpenGL event loop.
/// This method will block until the application exits, calling app's
/// Init() method to start and Render() method subsequently to draw each frame.
/// @return exit code for use when returning from main. Currently always 0.
PANGOLIN_EXPORT
int LaunchUserApp(UserApp& app);
/// Perform any post rendering, event processing and frame swapping.
PANGOLIN_EXPORT
void FinishFrame();
/// Request that the window close.
PANGOLIN_EXPORT
void Quit();
/// Request that all windows close.
PANGOLIN_EXPORT
void QuitAll();
/// Returns true if user has requested to close OpenGL window.
PANGOLIN_EXPORT
bool ShouldQuit();
/// Returns true if user has interacted with the window since this was last called.
PANGOLIN_EXPORT
bool HadInput();
/// Returns true if user has resized the window.
PANGOLIN_EXPORT
bool HasResized();
/// Renders any views with default draw methods.
PANGOLIN_EXPORT
void RenderViews();
/// Perform any post render events, such as screen recording.
PANGOLIN_EXPORT
void PostRender();
/// Request to be notified via functor when key is pressed.
/// Functor may take one parameter which will equal the key pressed
PANGOLIN_EXPORT
void RegisterKeyPressCallback(int key, std::function<void(void)> func);
/// Save window contents to image.
PANGOLIN_EXPORT
void SaveWindowOnRender(std::string filename_prefix);
PANGOLIN_EXPORT
void SaveFramebuffer(std::string prefix, const Viewport& v);
namespace process
{
/// Tell pangolin to process input to drive display.
/// You will need to call this manually if you haven't let
/// Pangolin register callbacks from your windowing system
PANGOLIN_EXPORT
void Keyboard( unsigned char key, int x, int y);
PANGOLIN_EXPORT
void KeyboardUp(unsigned char key, int x, int y);
PANGOLIN_EXPORT
void SpecialFunc(int key, int x, int y);
PANGOLIN_EXPORT
void SpecialFuncUp(int key, int x, int y);
/// Tell pangolin base window size has changed
/// You will need to call this manually if you haven't let
/// Pangolin register callbacks from your windowing system
PANGOLIN_EXPORT
void Resize(int width, int height);
/// Event based rendering entry point. Not currently supported.
PANGOLIN_EXPORT
void Display();
PANGOLIN_EXPORT
void Mouse( int button, int state, int x, int y);
PANGOLIN_EXPORT
void MouseMotion( int x, int y);
PANGOLIN_EXPORT
void PassiveMouseMotion(int x, int y);
PANGOLIN_EXPORT
void Scroll(float x, float y);
PANGOLIN_EXPORT
void Zoom(float m);
PANGOLIN_EXPORT
void Rotate(float r);
PANGOLIN_EXPORT
void SubpixMotion(float x, float y, float pressure, float rotation, float tiltx, float tilty);
PANGOLIN_EXPORT
void SpecialInput(InputSpecial inType, float x, float y, float p1, float p2, float p3, float p4);
}
/// Retrieve 'base' display, corresponding to entire window.
PANGOLIN_EXPORT
View& DisplayBase();
/// Create or retrieve named display managed by pangolin (automatically deleted).
PANGOLIN_EXPORT
View& Display(const std::string& name);
/// Create unnamed display managed by pangolin (automatically deleted).
PANGOLIN_EXPORT
View& CreateDisplay();
/// Switch between windowed and fullscreen mode.
PANGOLIN_EXPORT
void ToggleFullscreen();
/// Switch windows/fullscreenmode = fullscreen.
PANGOLIN_EXPORT
void SetFullscreen(bool fullscreen = true);
/// Toggle display of Pangolin console
PANGOLIN_EXPORT
void ToggleConsole();
/// Convenience functor for toggling pangolin::View.
/// Use with RegisterKeyPressCallback for example
struct ToggleViewFunctor {
inline ToggleViewFunctor(View& view);
inline ToggleViewFunctor(const std::string& name);
void operator()();
View& view;
};
}

View File

@@ -1,138 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <pangolin/display/window.h>
#include <pangolin/display/view.h>
#include <pangolin/display/user_app.h>
#include <functional>
#include <memory>
#include <map>
#include <queue>
#ifdef BUILD_PANGOLIN_VIDEO
# include <pangolin/video/video_output.h>
#endif // BUILD_PANGOLIN_VIDEO
namespace pangolin
{
// Forward Declarations
#ifdef HAVE_PYTHON
class ConsoleView;
#endif // HAVE_PYTHON
class GlFont;
typedef std::map<const std::string,View*> ViewMap;
typedef std::map<int,std::function<void(void)> > KeyhookMap;
struct PANGOLIN_EXPORT PangolinGl : public WindowInterface
{
PangolinGl();
~PangolinGl();
// Base container for displays
View base;
// Named views which are managed by pangolin (i.e. created / deleted by pangolin)
ViewMap named_managed_views;
// Optional user app
UserApp* user_app;
// Global keypress hooks
KeyhookMap keypress_hooks;
// Manage fullscreen (ToggleFullscreen is quite new)
bool is_double_buffered;
bool is_fullscreen;
GLint windowed_size[2];
bool is_high_res;
// State relating to interactivity
bool quit;
int had_input;
int has_resized;
int mouse_state;
View* activeDisplay;
std::queue<std::pair<std::string,Viewport> > screen_capture;
#ifdef BUILD_PANGOLIN_VIDEO
View* record_view;
VideoOutput recorder;
#endif
#ifdef HAVE_PYTHON
ConsoleView* console_view;
#endif
std::shared_ptr<GlFont> font;
virtual void ToggleFullscreen() override {
pango_print_warn("ToggleFullscreen: Not available with non-pangolin window.\n");
}
virtual void ProcessEvents() override {
pango_print_warn("ProcessEvents: Not available with non-pangolin window.\n");
}
virtual void SwapBuffers() override {
pango_print_warn("SwapBuffers: Not available with non-pangolin window.\n");
}
virtual void MakeCurrent() override {
pango_print_warn("MakeCurrent: Not available with non-pangolin window.\n");
}
virtual void RemoveCurrent() override {
pango_print_warn("RemoveCurrent: Not available with non-pangolin window.\n");
}
virtual void Move(int /*x*/, int /*y*/) override {
pango_print_warn("Move: Not available with non-pangolin window.\n");
}
virtual void Resize(unsigned int /*w*/, unsigned int /*h*/) override {
pango_print_warn("Resize: Not available with non-pangolin window.\n");
}
};
PangolinGl* GetCurrentContext();
void RegisterNewContext(const std::string& name, std::shared_ptr<PangolinGl> newcontext);
void DeleteContext(const std::string& name);
PangolinGl *FindContext(const std::string& name);
}

View File

@@ -1,74 +0,0 @@
#pragma once
#include <pangolin/display/display.h>
#include <pangolin/gl/glpixformat.h>
#include <pangolin/gl/glformattraits.h>
#include <pangolin/gl/glsl.h>
#include <pangolin/handler/handler_image.h>
#include <pangolin/image/image_utils.h>
#include <mutex>
namespace pangolin
{
class ImageView : public pangolin::View, public pangolin::ImageViewHandler
{
public:
ImageView();
~ImageView();
void Render() override;
void Mouse(View& view, pangolin::MouseButton button, int x, int y, bool pressed, int button_state) override;
void Keyboard(View& view, unsigned char key, int x, int y, bool pressed) override;
pangolin::GlTexture& Tex();
ImageView& SetImage(void* ptr, size_t w, size_t h, size_t pitch, pangolin::GlPixFormat img_fmt, bool delayed_upload = false);
ImageView& SetImage(const pangolin::Image<unsigned char>& img, const pangolin::GlPixFormat& glfmt, bool delayed_upload = false);
template<typename T> inline
ImageView& SetImage(const pangolin::Image<T>& img, bool delayed_upload = false)
{
return SetImage(img.template UnsafeReinterpret<unsigned char>(), GlPixFormat::FromType<T>(), delayed_upload);
}
ImageView& SetImage(const pangolin::TypedImage& img, bool delayed_upload = false);
ImageView& SetImage(const pangolin::GlTexture& texture);
void LoadPending();
ImageView& Clear();
std::pair<float, float>& GetOffsetScale();
bool MouseReleased() const;
bool MousePressed() const;
void SetRenderOverlay(const bool& val);
// private:
// img_to_load contains image data that should be uploaded to the texture on
// the next render cycle. The data is owned by this object and should be
// freed after use.
pangolin::ManagedImage<unsigned char> img_to_load;
pangolin::GlPixFormat img_fmt_to_load;
std::pair<float, float> offset_scale;
pangolin::GlPixFormat fmt;
pangolin::GlTexture tex;
bool lastPressed;
bool mouseReleased;
bool mousePressed;
bool overlayRender;
std::mutex texlock;
};
}

View File

@@ -1,446 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
#include <pangolin/utils/simple_math.h>
#include <vector>
#if defined(HAVE_EIGEN) && !defined(__CUDACC__) //prevent including Eigen in cuda files
#define USE_EIGEN
#endif
#ifdef USE_EIGEN
#include <Eigen/Core>
#include <Eigen/Geometry>
#endif
#ifdef HAVE_TOON
#include <cstring>
#include <TooN/TooN.h>
#include <TooN/se3.h>
#endif
#ifdef HAVE_OCULUS
#include <pangolin/compat/ovr.h>
#endif
namespace pangolin {
#ifdef HAVE_GLES
typedef float GLprecision;
#else
typedef double GLprecision;
#endif
/// Capture OpenGL matrix types in enum to typing.
enum OpenGlStack {
GlModelViewStack = 0x1700, // GL_MODELVIEW
GlProjectionStack = 0x1701, // GL_PROJECTION
GlTextureStack = 0x1702 // GL_TEXTURE
};
enum AxisDirection
{
AxisNone,
AxisNegX, AxisX,
AxisNegY, AxisY,
AxisNegZ, AxisZ
};
struct CameraSpec {
GLprecision forward[3];
GLprecision up[3];
GLprecision right[3];
GLprecision img_up[2];
GLprecision img_right[2];
};
const static CameraSpec CameraSpecOpenGl = {{0,0,-1},{0,1,0},{1,0,0},{0,1},{1,0}};
const static CameraSpec CameraSpecYDownZForward = {{0,0,1},{0,-1,0},{1,0,0},{0,-1},{1,0}};
/// Direction vector for each AxisDirection enum
const static GLprecision AxisDirectionVector[7][3] = {
{0,0,0},
{-1,0,0}, {1,0,0},
{0,-1,0}, {0,1,0},
{0,0,-1}, {0,0,1}
};
/// Object representing OpenGl Matrix.
struct PANGOLIN_EXPORT OpenGlMatrix {
static OpenGlMatrix Translate(GLprecision x, GLprecision y, GLprecision z);
static OpenGlMatrix Scale(GLprecision x, GLprecision y, GLprecision z);
static OpenGlMatrix RotateX(GLprecision theta_rad);
static OpenGlMatrix RotateY(GLprecision theta_rad);
static OpenGlMatrix RotateZ(GLprecision theta_rad);
template<typename P>
static OpenGlMatrix ColMajor4x4(const P* col_major_4x4);
OpenGlMatrix();
#ifdef USE_EIGEN
template<typename P>
OpenGlMatrix(const Eigen::Matrix<P,4,4>& mat);
template<typename P>
OpenGlMatrix(const Eigen::Transform<P,3,Eigen::Affine>& mat) : OpenGlMatrix(mat.matrix()) { }
template<typename P>
operator Eigen::Matrix<P,4,4>() const;
template<typename P>
operator Eigen::Transform<P,3,Eigen::Affine>() const;
#endif // USE_EIGEN
#ifdef HAVE_TOON
OpenGlMatrix(const TooN::SE3<>& T);
OpenGlMatrix(const TooN::Matrix<4,4>& M);
operator const TooN::SE3<>() const;
operator const TooN::Matrix<4,4>() const;
#endif // HAVE_TOON
#ifdef HAVE_OCULUS
OpenGlMatrix(const OVR::Matrix4f& M);
operator const OVR::Matrix4f() const;
#endif // HAVE_OCULUS
// Load matrix on to OpenGl stack
void Load() const;
void Multiply() const;
void SetIdentity();
OpenGlMatrix Transpose() const;
OpenGlMatrix Inverse() const;
GLprecision& operator()(int r, int c) {
return m[4*c +r];
}
GLprecision operator()(int r, int c) const {
return m[4 * c + r];
}
// Column major Internal buffer
GLprecision m[16];
};
PANGOLIN_EXPORT
OpenGlMatrix operator*(const OpenGlMatrix& lhs, const OpenGlMatrix& rhs);
PANGOLIN_EXPORT
std::ostream& operator<<(std::ostream& os, const OpenGlMatrix& mat);
/// Deprecated.
struct PANGOLIN_EXPORT OpenGlMatrixSpec : public OpenGlMatrix {
// Specify which stack this refers to
OpenGlStack type;
};
/// Object representing attached OpenGl Matrices / transforms.
class PANGOLIN_EXPORT OpenGlRenderState
{
public:
OpenGlRenderState();
OpenGlRenderState(const OpenGlMatrix& projection_matrix);
OpenGlRenderState(const OpenGlMatrix& projection_matrix, const OpenGlMatrix& modelview_matrix);
static void ApplyIdentity();
void Apply() const;
OpenGlRenderState& SetProjectionMatrix(OpenGlMatrix m);
OpenGlRenderState& SetModelViewMatrix(OpenGlMatrix m);
OpenGlMatrix& GetProjectionMatrix();
OpenGlMatrix GetProjectionMatrix() const;
OpenGlMatrix& GetModelViewMatrix();
OpenGlMatrix GetModelViewMatrix() const;
OpenGlMatrix GetProjectionModelViewMatrix() const;
OpenGlMatrix GetProjectiveTextureMatrix() const;
void EnableProjectiveTexturing() const;
void DisableProjectiveTexturing() const;
//! Seemlessly move OpenGl camera relative to changes in T_wc,
//! whilst still enabling interaction
void Follow(const OpenGlMatrix& T_wc, bool follow = true);
void Unfollow();
// Experimental - subject to change
OpenGlMatrix& GetProjectionMatrix(unsigned int view);
OpenGlMatrix GetProjectionMatrix(unsigned int view) const;
OpenGlMatrix& GetViewOffset(unsigned int view);
OpenGlMatrix GetViewOffset(unsigned int view) const;
OpenGlMatrix GetModelViewMatrix(int i) const;
void ApplyNView(int view) const;
PANGOLIN_DEPRECATED
OpenGlRenderState& Set(OpenGlMatrixSpec spec);
protected:
OpenGlMatrix modelview;
std::vector<OpenGlMatrix> projection;
std::vector<OpenGlMatrix> modelview_premult;
OpenGlMatrix T_cw;
bool follow;
};
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRUB_BottomLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRUB_TopLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRDF_TopLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRDF_TopRight(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRDF_BottomLeft(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixRDF_BottomRight(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
//! Use OpenGl's default frame RUB_BottomLeft
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrix(int w, int h, GLprecision fu, GLprecision fv, GLprecision u0, GLprecision v0, GLprecision zNear, GLprecision zFar );
PANGOLIN_EXPORT
OpenGlMatrixSpec ProjectionMatrixOrthographic(GLprecision l, GLprecision r, GLprecision b, GLprecision t, GLprecision n, GLprecision f );
//! Generate glulookat style model view matrix, looking at (lx,ly,lz)
//! X-Right, Y-Up, Z-Back
PANGOLIN_EXPORT
OpenGlMatrix ModelViewLookAtRUB(GLprecision ex, GLprecision ey, GLprecision ez, GLprecision lx, GLprecision ly, GLprecision lz, GLprecision ux, GLprecision uy, GLprecision uz);
//! Generate glulookat style model view matrix, looking at (lx,ly,lz)
//! X-Right, Y-Down, Z-Forward
PANGOLIN_EXPORT
OpenGlMatrix ModelViewLookAtRDF(GLprecision ex, GLprecision ey, GLprecision ez, GLprecision lx, GLprecision ly, GLprecision lz, GLprecision ux, GLprecision uy, GLprecision uz);
//! Generate glulookat style model view matrix, OpenGL Default camera convention (XYZ=RUB), looking at (lx,ly,lz)
PANGOLIN_EXPORT
OpenGlMatrix ModelViewLookAt(GLprecision x, GLprecision y, GLprecision z, GLprecision lx, GLprecision ly, GLprecision lz, AxisDirection up);
PANGOLIN_EXPORT
OpenGlMatrix ModelViewLookAt(GLprecision ex, GLprecision ey, GLprecision ez, GLprecision lx, GLprecision ly, GLprecision lz, GLprecision ux, GLprecision uy, GLprecision uz);
PANGOLIN_EXPORT
OpenGlMatrix IdentityMatrix();
PANGOLIN_EXPORT
OpenGlMatrixSpec IdentityMatrix(OpenGlStack type);
PANGOLIN_EXPORT
OpenGlMatrixSpec negIdentityMatrix(OpenGlStack type);
#ifdef HAVE_TOON
OpenGlMatrixSpec FromTooN(const TooN::SE3<>& T_cw);
OpenGlMatrixSpec FromTooN(OpenGlStack type, const TooN::Matrix<4,4>& M);
TooN::Matrix<4,4> ToTooN(const OpenGlMatrixSpec& ms);
TooN::SE3<> ToTooN_SE3(const OpenGlMatrixSpec& ms);
#endif
#ifdef HAVE_EIGEN
template<typename P>
Eigen::Matrix<P,4,4> ToEigen(const OpenGlMatrix& ms);
#endif
}
// Inline definitions
namespace pangolin
{
template<typename P>
inline OpenGlMatrix OpenGlMatrix::ColMajor4x4(const P* col_major_4x4)
{
OpenGlMatrix mat;
std::copy(col_major_4x4, col_major_4x4 + 16, mat.m);
return mat;
}
inline OpenGlMatrix::OpenGlMatrix() {
}
#ifdef USE_EIGEN
template<typename P> inline
OpenGlMatrix::OpenGlMatrix(const Eigen::Matrix<P,4,4>& mat)
{
for(int r=0; r<4; ++r ) {
for(int c=0; c<4; ++c ) {
m[c*4+r] = mat(r,c);
}
}
}
template<typename P>
OpenGlMatrix::operator Eigen::Matrix<P,4,4>() const
{
return ToEigen<P>(*this);
}
template<typename P>
OpenGlMatrix::operator Eigen::Transform<P,3,Eigen::Affine>() const
{
return Eigen::Transform<P,3,Eigen::Affine>(ToEigen<P>(*this));
}
template<typename P> inline
Eigen::Matrix<P,4,4> ToEigen(const OpenGlMatrix& ms)
{
Eigen::Matrix<P,4,4> mat;
for(int r=0; r<4; ++r ) {
for(int c=0; c<4; ++c ) {
mat(r,c) = (P)ms.m[c*4+r];
}
}
return mat;
}
#endif // USE_EIGEN
#ifdef HAVE_TOON
inline OpenGlMatrix::OpenGlMatrix(const TooN::SE3<>& T)
{
TooN::Matrix<4,4,GLprecision,TooN::ColMajor> M;
M.slice<0,0,3,3>() = T.get_rotation().get_matrix();
M.T()[3].slice<0,3>() = T.get_translation();
M[3] = TooN::makeVector(0,0,0,1);
std::memcpy(m, &(M[0][0]),16*sizeof(GLprecision));
}
inline OpenGlMatrix::OpenGlMatrix(const TooN::Matrix<4,4>& M)
{
// Read in remembering col-major convension for our matrices
int el = 0;
for(int c=0; c<4; ++c)
for(int r=0; r<4; ++r)
m[el++] = M[r][c];
}
inline OpenGlMatrix::operator const TooN::SE3<>() const
{
const TooN::Matrix<4,4> m = *this;
const TooN::SO3<> R(m.slice<0,0,3,3>());
const TooN::Vector<3> t = m.T()[3].slice<0,3>();
return TooN::SE3<>(R,t);
}
inline OpenGlMatrix::operator const TooN::Matrix<4,4>() const
{
TooN::Matrix<4,4> M;
int el = 0;
for( int c=0; c<4; ++c )
for( int r=0; r<4; ++r )
M(r,c) = m[el++];
return M;
}
PANGOLIN_DEPRECATED
inline OpenGlMatrixSpec FromTooN(const TooN::SE3<>& T_cw)
{
TooN::Matrix<4,4,GLprecision,TooN::ColMajor> M;
M.slice<0,0,3,3>() = T_cw.get_rotation().get_matrix();
M.T()[3].slice<0,3>() = T_cw.get_translation();
M[3] = TooN::makeVector(0,0,0,1);
OpenGlMatrixSpec P;
P.type = GlModelViewStack;
std::memcpy(P.m, &(M[0][0]),16*sizeof(GLprecision));
return P;
}
PANGOLIN_DEPRECATED
inline OpenGlMatrixSpec FromTooN(OpenGlStack type, const TooN::Matrix<4,4>& M)
{
// Read in remembering col-major convension for our matrices
OpenGlMatrixSpec P;
P.type = type;
int el = 0;
for(int c=0; c<4; ++c)
for(int r=0; r<4; ++r)
P.m[el++] = M[r][c];
return P;
}
PANGOLIN_DEPRECATED
inline TooN::Matrix<4,4> ToTooN(const OpenGlMatrix& ms)
{
TooN::Matrix<4,4> m;
int el = 0;
for( int c=0; c<4; ++c )
for( int r=0; r<4; ++r )
m(r,c) = ms.m[el++];
return m;
}
PANGOLIN_DEPRECATED
inline TooN::SE3<> ToTooN_SE3(const OpenGlMatrix& ms)
{
TooN::Matrix<4,4> m = ms;
const TooN::SO3<> R(m.slice<0,0,3,3>());
const TooN::Vector<3> t = m.T()[3].slice<0,3>();
return TooN::SE3<>(R,t);
}
#endif // HAVE_TOON
#ifdef HAVE_OCULUS
inline OpenGlMatrix::OpenGlMatrix(const OVR::Matrix4f& mat)
{
for(int r=0; r<4; ++r )
for(int c=0; c<4; ++c )
m[c*4+r] = mat.M[r][c];
}
inline OpenGlMatrix::operator const OVR::Matrix4f() const
{
OVR::Matrix4f mat;
for(int r=0; r<4; ++r )
for(int c=0; c<4; ++c )
mat.M[r][c] = m[c*4+r];
return mat;
}
#endif // HAVE_OCULUS
}

View File

@@ -1,43 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/platform.h>
namespace pangolin
{
class PANGOLIN_EXPORT UserApp
{
public:
virtual ~UserApp() {}
virtual void Init() {}
virtual void Render() = 0;
};
}

View File

@@ -1,235 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <functional>
#include <vector>
#include <pangolin/display/viewport.h>
#include <pangolin/display/attach.h>
namespace pangolin
{
enum Layout
{
LayoutOverlay,
LayoutVertical,
LayoutHorizontal,
LayoutEqual,
LayoutEqualVertical,
LayoutEqualHorizontal
};
enum Lock {
LockLeft = 0,
LockBottom = 0,
LockCenter = 1,
LockRight = 2,
LockTop = 2
};
// Forward declarations
struct Handler;
class OpenGlRenderState;
/// A Display manages the location and resizing of an OpenGl viewport.
struct PANGOLIN_EXPORT View
{
View(double aspect=0.0)
: aspect(aspect), top(1.0),left(0.0),right(1.0),bottom(0.0), hlock(LockCenter),vlock(LockCenter),
layout(LayoutOverlay), scroll_offset(0), show(1), zorder(0), handler(0), scroll_show(1) {}
virtual ~View() {}
//! Activate Displays viewport for drawing within this area
void Activate() const;
//! Activate Displays and set State Matrices
void Activate(const OpenGlRenderState& state ) const;
//! Activate Displays viewport and Scissor for drawing within this area
void ActivateAndScissor() const;
//! Activate Displays viewport and Scissor for drawing within this area
void ActivateScissorAndClear() const;
//! Activate Display and set State Matrices
void ActivateAndScissor(const OpenGlRenderState& state ) const;
//! Activate Display and set State Matrices
void ActivateScissorAndClear(const OpenGlRenderState& state ) const;
//! Activate Display and setup coordinate system for 2d pixel View coordinates
void ActivatePixelOrthographic() const;
//! Activate Display and reset coordinate system to OpenGL default
void ActivateIdentity() const;
//! Return closest depth buffer value within radius of window (winx,winy)
GLfloat GetClosestDepth(int winx, int winy, int radius) const;
//! Obtain camera space coordinates of scene at pixel (winx, winy, winzdepth)
//! winzdepth can be obtained from GetClosestDepth
void GetCamCoordinates(const OpenGlRenderState& cam_state, double winx, double winy, double winzdepth, GLdouble& x, GLdouble& y, GLdouble& z) const;
//! Obtain object space coordinates of scene at pixel (winx, winy, winzdepth)
//! winzdepth can be obtained from GetClosestDepth
void GetObjectCoordinates(const OpenGlRenderState& cam_state, double winx, double winy, double winzdepth, GLdouble& x, GLdouble& y, GLdouble& z) const;
//! Given the specification of Display, compute viewport
virtual void Resize(const Viewport& parent);
//! Instruct all children to resize
virtual void ResizeChildren();
//! Perform any automatic rendering for this View.
//! Default implementation simply instructs children to render themselves.
virtual void Render();
//! Instruct all children to render themselves if appropriate
virtual void RenderChildren();
//! Set this view as the active View to receive input
View& SetFocus();
//! Returns true iff this view currently has focus and will receive user input
bool HasFocus() const;
//! Set bounds for the View using mixed fractional / pixel coordinates (OpenGl view coordinates)
View& SetBounds(Attach bottom, Attach top, Attach left, Attach right);
//! Set bounds for the View using mixed fractional / pixel coordinates (OpenGl view coordinates)
View& SetBounds(Attach bottom, Attach top, Attach left, Attach right, bool keep_aspect);
//! Set bounds for the View using mixed fractional / pixel coordinates (OpenGl view coordinates)
View& SetBounds(Attach bottom, Attach top, Attach left, Attach right, double aspect);
//! Designate handler for accepting mouse / keyboard input.
View& SetHandler(Handler* handler);
//! Set drawFunc as the drawing function for this view
View& SetDrawFunction(const std::function<void(View&)>& drawFunc);
//! Force this view to have the given aspect, whilst fitting snuggly
//! within the parent. A negative value with 'over-draw', fitting the
//! smaller side of the parent.
View& SetAspect(double aspect);
//! Set how this view should be positioned relative to its parent
View& SetLock(Lock horizontal, Lock vertical );
//! Set layout policy for this view
View& SetLayout(Layout layout);
//! Add view as child
View& AddDisplay(View& view);
//! Show / hide this view
View& Show(bool show=true);
//! Toggle this views visibility
void ToggleShow();
//! Return whether this view should be shown.
//! This method should be checked if drawing manually
bool IsShown() const;
//! Returns viewport reflecting space that will actually get drawn
//! The minimum of vp and v
Viewport GetBounds() const;
//! Specify that this views region in the framebuffer should be saved to
//! a file just before the buffer is flipped.
void SaveOnRender(const std::string& filename_prefix);
//! Specify that this views region in the framebuffer should be saved to
//! a video just before the buffer is flipped
void RecordOnRender(const std::string& record_uri);
//! Uses the views default render method to draw into an FBO 'scale' times
//! the size of the view and save to a file.
void SaveRenderNow(const std::string& filename_prefix, float scale = 1);
//! Return number of child views attached to this view
size_t NumChildren() const;
//! Return (i)th child of this view
View& operator[](size_t i);
//! Return number of visible child views attached to this view.
size_t NumVisibleChildren() const;
//! Return visible child by index.
View& VisibleChild(size_t i);
//! Return visible child at window coords x,y
View* FindChild(int x, int y);
// Desired width / height aspect (0 if dynamic)
double aspect;
// Bounds to fit display within
Attach top, left, right, bottom;
Lock hlock;
Lock vlock;
Layout layout;
int scroll_offset;
// Cached client area (space allocated from parent)
Viewport vp;
// Cached absolute viewport (recomputed on resize - respects aspect)
Viewport v;
// Should this view be displayed?
bool show;
// Child views are rendered in order of low to high z-order
// Views default to 0 z-order
int zorder;
// Input event handler (if any)
Handler* handler;
// Map for sub-displays (if any)
std::vector<View*> views;
// External draw function
std::function<void(View&)> extern_draw_function;
private:
// Private copy constructor
View(View&) { /* Do Not copy - take reference instead*/ }
bool scroll_show;
};
}

View File

@@ -1,65 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/gl/glinclude.h>
#include <pangolin/display/opengl_render_state.h>
namespace pangolin
{
/// Encapsulates OpenGl Viewport.
struct PANGOLIN_EXPORT Viewport
{
Viewport() : l(0),b(0),w(0),h(0) {}
Viewport(GLint l,GLint b,GLint w,GLint h) : l(l),b(b),w(w),h(h) {}
void Activate() const;
void ActivateIdentity() const;
void ActivatePixelOrthographic() const;
void Scissor() const;
void ActivateAndScissor() const;
bool Contains(int x, int y) const;
Viewport Inset(int i) const;
Viewport Inset(int horiz, int vert) const;
Viewport Intersect(const Viewport& vp) const;
void GetCamCoordinates(const OpenGlRenderState& cam_state, double winx, double winy, double winzdepth, GLdouble& x, GLdouble& y, GLdouble& z) const;
static void DisableScissor();
GLint r() const { return l+w;}
GLint t() const { return b+h;}
GLfloat aspect() const { return (GLfloat)w / (GLfloat)h; }
GLint l,b,w,h;
};
}

View File

@@ -1,141 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/display/view.h>
#include <pangolin/var/var.h>
#include <pangolin/handler/handler.h>
#include <pangolin/gl/glfont.h>
#include <functional>
namespace pangolin
{
PANGOLIN_EXPORT
View& CreatePanel(const std::string& name);
struct PANGOLIN_EXPORT Panel : public View
{
Panel();
Panel(const std::string& auto_register_var_prefix);
void Render();
void ResizeChildren();
static void AddVariable(void* data, const std::string& name, VarValueGeneric& var, bool brand_new);
};
template<typename T>
struct Widget : public View, Handler, Var<T>
{
Widget(std::string title, VarValueGeneric& tv)
: Var<T>(tv), title(title)
{
handler = this;
}
std::string title;
};
struct PANGOLIN_EXPORT Button : public Widget<bool>
{
Button(std::string title, VarValueGeneric& tv);
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
void Render();
//Cache params on resize
void ResizeChildren();
GlText gltext;
GLfloat raster[2];
bool down;
};
struct PANGOLIN_EXPORT FunctionButton : public Widget<std::function<void(void)> >
{
FunctionButton(std::string title, VarValueGeneric& tv);
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
void Render();
//Cache params on resize
void ResizeChildren();
GlText gltext;
GLfloat raster[2];
bool down;
};
struct PANGOLIN_EXPORT Checkbox : public Widget<bool>
{
Checkbox(std::string title, VarValueGeneric& tv);
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
void Render();
//Cache params on resize
void ResizeChildren();
GlText gltext;
GLfloat raster[2];
Viewport vcb;
};
struct PANGOLIN_EXPORT Slider : public Widget<double>
{
Slider(std::string title, VarValueGeneric& tv);
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
void MouseMotion(View&, int x, int y, int mouse_state);
void Keyboard(View&, unsigned char key, int x, int y, bool pressed);
void Render();
//Cache params on resize
void ResizeChildren();
GlText gltext;
GLfloat raster[2];
bool lock_bounds;
bool logscale;
bool is_integral_type;
};
struct PANGOLIN_EXPORT TextInput : public Widget<std::string>
{
TextInput(std::string title, VarValueGeneric& tv);
void Mouse(View&, MouseButton button, int x, int y, bool pressed, int mouse_state);
void MouseMotion(View&, int x, int y, int mouse_state);
void Keyboard(View&, unsigned char key, int x, int y, bool pressed);
void Render();
std::string edit;
GlText gledit;
//Cache params on resize
void ResizeChildren();
GlText gltext;
GLfloat raster[2];
bool can_edit;
bool do_edit;
int sel[2];
};
}

View File

@@ -1,90 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2016 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <exception>
#include <pangolin/platform.h>
#include <string>
namespace pangolin
{
class GlContextInterface
{
public:
virtual ~GlContextInterface() {}
};
class WindowInterface
{
public:
virtual ~WindowInterface() {}
virtual void ToggleFullscreen() = 0;
virtual void Move(int x, int y) = 0;
virtual void Resize(unsigned int w, unsigned int h) = 0;
/**
* @brief MakeCurrent set the current context
* to be called in a thread before accessing OpenGL
*/
virtual void MakeCurrent() = 0;
/**
* @brief RemoveCurrent remove the current context
* to be called at the end of a thread
*/
virtual void RemoveCurrent() = 0;
virtual void ProcessEvents() = 0;
virtual void SwapBuffers() = 0;
};
struct PANGOLIN_EXPORT WindowException : std::exception
{
WindowException(std::string str) : desc(str) {}
WindowException(std::string str, std::string detail) {
desc = str + "\n\t" + detail;
}
~WindowException() throw() {}
const char* what() const throw() { return desc.c_str(); }
std::string desc;
};
struct PANGOLIN_EXPORT WindowExceptionNoKnownHandler : public WindowException
{
WindowExceptionNoKnownHandler(const std::string& scheme)
: WindowException("No known window handler for URI '" + scheme + "'")
{
}
};
}

View File

@@ -1,114 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011-2013 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <memory>
#include <vector>
#include <algorithm>
#include <pangolin/utils/uri.h>
namespace pangolin
{
template<typename T>
struct FactoryInterface
{
typedef T FactoryItem;
virtual ~FactoryInterface() = default;
virtual std::unique_ptr<T> Open(const Uri& uri) = 0;
};
template<typename T>
class FactoryRegistry
{
public:
// IMPORTANT: Implement for each templated instantiation within a seperate compilation unit.
static FactoryRegistry<T>& I();
~FactoryRegistry()
{
}
void RegisterFactory(std::shared_ptr<FactoryInterface<T>> factory, uint32_t precedence, const std::string& scheme_name )
{
FactoryItem item = {precedence, scheme_name, factory};
factories.push_back( item );
std::sort(factories.begin(), factories.end());
}
void UnregisterFactory(FactoryInterface<T>* factory)
{
for( auto i = factories.end()-1; i != factories.begin(); --i)
{
if( i->factory.get() == factory ) {
factories.erase(i);
}
}
}
void UnregisterAllFactories()
{
factories.clear();
}
std::unique_ptr<T> Open(const Uri& uri)
{
// Iterate over all registered factories in order of precedence.
for(auto& item : factories) {
if( item.scheme == uri.scheme) {
std::unique_ptr<T> video = item.factory->Open(uri);
if(video) {
return video;
}
}
}
return std::unique_ptr<T>();
}
private:
struct FactoryItem
{
uint32_t precedence;
std::string scheme;
std::shared_ptr<FactoryInterface<T>> factory;
bool operator<(const FactoryItem& rhs) const {
return precedence < rhs.precedence;
}
};
// Priority, Factory tuple
std::vector<FactoryItem> factories;
};
#define PANGOLIN_REGISTER_FACTORY(x) void Register ## x ## Factory()
}

View File

@@ -1,95 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef PANGOLIN_GEOMETRY_H
#define PANGOLIN_GEOMETRY_H
#include <map>
#include <unordered_map>
#include <vector>
#include <pangolin/image/typed_image.h>
#include <pangolin/compat/variant.h>
#ifdef HAVE_EIGEN
#include <Eigen/Geometry>
#endif
namespace pangolin
{
struct Geometry
{
struct Element : public ManagedImage<uint8_t> {
Element() = default;
Element(Element&&) = default;
Element& operator=(Element&&) = default;
Element(size_t stride_bytes, size_t num_elements)
: ManagedImage<uint8_t>(stride_bytes, num_elements)
{}
using Attribute = variant<Image<float>,Image<uint32_t>,Image<uint16_t>,Image<uint8_t>>;
// "vertex", "rgb", "normal", "uv", "tris", "quads", ...
std::map<std::string, Attribute> attributes;
};
// Store vertices and attributes
std::map<std::string, Element> buffers;
// Stores index buffers for each sub-object
std::multimap<std::string, Element> objects;
// Stores pixmaps
std::map<std::string, TypedImage> textures;
};
pangolin::Geometry::Element::Attribute MakeAttribute(uint32_t gldatatype, size_t num_items, size_t count_per_item, void* ptr, size_t pitch_bytes);
pangolin::Geometry LoadGeometry(const std::string& filename);
#ifdef HAVE_EIGEN
inline Eigen::AlignedBox3f GetAxisAlignedBox(const Geometry& geom)
{
Eigen::AlignedBox3f box;
box.setEmpty();
for(const auto& b : geom.buffers) {
const auto& it_vert = b.second.attributes.find("vertex");
if(it_vert != b.second.attributes.end()) {
const Image<float>& vs = get<Image<float>>(it_vert->second);
for(size_t i=0; i < vs.h; ++i) {
const Eigen::Map<const Eigen::Vector3f> v(vs.RowPtr(i));
box.extend(v);
}
}
}
return box;
}
#endif
}
#endif // PANGOLIN_GEOMETRY_H

View File

@@ -1,34 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <pangolin/geometry/geometry.h>
namespace pangolin {
pangolin::Geometry LoadGeometryObj(const std::string& filename);
}

View File

@@ -1,165 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#include <pangolin/platform.h>
#include <pangolin/compat/variant.h>
#include <pangolin/geometry/geometry.h>
#include <fstream>
#include <vector>
#include <algorithm>
namespace pangolin
{
#define PLY_GROUP_LIST(m) m(PlyHeader) m(PlyFormat) m(PlyType)
#define PLY_HEADER_LIST(m) m(ply) m(format) m(comment) m(property) m(element) m(end_header)
#define PLY_FORMAT_LIST(m) m(ascii) m(binary_big_endian) m(binary_little_endian)
#define PLY_TYPE_LIST(m) m(char) m(int8) m(uchar) m(uint8) m(short) m(int16) m(ushort) m(uint16) m(int) m(int32) m(uint) m(uint32) m(float) m(float32) m(double) m(float64) m(list)
// Define Enums / strings
enum PlyHeader {
#define FORMAT_ENUM(x) PlyHeader_##x,
PLY_HEADER_LIST(FORMAT_ENUM)
PlyHeaderSize
#undef FORMAT_ENUM
};
enum PlyFormat {
#define FORMAT_ENUM(x) PlyFormat_##x,
PLY_FORMAT_LIST(FORMAT_ENUM)
PlyFormatSize
#undef FORMAT_ENUM
};
enum PlyType {
#define FORMAT_ENUM(x) PlyType_##x,
PLY_TYPE_LIST(FORMAT_ENUM)
PlyTypeSize
#undef FORMAT_ENUM
};
const size_t PlyTypeGl[] = {
// char, int8 -> GL_BYTE
0x1400, 0x1400,
// uchar, uint8 -> GL_UNSIGNED_BYTE
0x1401, 0x1401,
// short, int16 -> GL_SHORT
0x1402, 0x1402,
// ushort, uint16 -> GL_UNSIGNED_SHORT
0x1403, 0x1403,
// int, int32 -> GL_INT
0x1404, 0x1404,
// uint, uint32 -> GL_UNSIGNED_INT
0x1405, 0x1405,
// float, float32 -> GL_FLOAT
0x1406, 0x1406,
// double, float64 -> GL_DOUBLE
0x140A, 0x140A,
// list -> GL_NONE
0
};
#undef FORMAT_ENUM
struct PlyPropertyDetails
{
std::string name;
// Type of property (GLenum)
size_t type;
// Type of list index if a list, or 0 otherwise. (GLenum)
size_t list_index_type;
// Offset from element start
size_t offset_bytes;
// Number of items in the list. 1 if not a list. -1 if unknown.
int num_items;
bool isList() const {
return list_index_type > 0;
}
};
struct PlyElementDetails
{
std::string name;
int num_items;
int stride_bytes;
std::vector<PlyPropertyDetails> properties;
inline std::vector<PlyPropertyDetails>::iterator FindProperty(const std::string& name)
{
return std::find_if(properties.begin(), properties.end(),
[&name](const PlyPropertyDetails& p){ return p.name == name;}
);
}
};
struct PlyHeaderDetails
{
PlyFormat format;
std::string version;
std::vector<PlyElementDetails> elements;
inline std::vector<PlyElementDetails>::iterator FindElement(const std::string& name)
{
return std::find_if(elements.begin(), elements.end(),
[&name](const PlyElementDetails& el){ return el.name == name;}
);
}
};
void ParsePlyHeader(PlyHeaderDetails& ply, std::istream& is);
struct PlyBuffer
{
size_t index_size_bytes;
size_t element_item_size_bytes;
std::vector<unsigned char> data;
};
void ParsePlyAscii(pangolin::Geometry& /*geom*/, const PlyHeaderDetails& /*ply*/, std::istream& /*is*/);
// Convert Seperate "x","y","z" attributes into a single "vertex" attribute
void StandardizeXyzToVertex(pangolin::Geometry& geom);
// The Artec scanner saves with these attributes, for example
void StandardizeMultiTextureFaceToXyzuv(pangolin::Geometry& geom);
void Standardize(pangolin::Geometry& geom);
void ParsePlyLE(pangolin::Geometry& geom, PlyHeaderDetails& ply, std::istream& is);
void ParsePlyBE(pangolin::Geometry& /*geom*/, const PlyHeaderDetails& /*ply*/, std::istream& /*is*/);
void AttachAssociatedTexturesPly(pangolin::Geometry& geom, const std::string& filename);
pangolin::Geometry LoadGeometryPly(const std::string& filename);
}

View File

@@ -1,87 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <pangolin/geometry/geometry.h>
#include <pangolin/gl/gl.h>
#include <pangolin/gl/glsl.h>
namespace pangolin {
struct GlGeometry
{
GlGeometry() = default;
GlGeometry(GlGeometry&&) = default;
GlGeometry& operator=(GlGeometry&&) = default;
struct Element : public GlBufferData
{
Element() = default;
Element(Element&&) = default;
Element& operator=(Element&&) = default;
Element(GlBufferType buffer_type, size_t size_bytes, GLenum gluse, uint8_t* data)
: GlBufferData(buffer_type, size_bytes, gluse, data)
{}
inline bool HasAttribute(const std::string& name) const {
return attributes.find(name) != attributes.end();
}
struct Attribute {
// Stuff needed by glVertexAttribPointer
GLenum gltype;
size_t count_per_element;
size_t num_elements;
size_t offset;
size_t stride_bytes;
};
std::map<std::string, Attribute> attributes;
};
inline bool HasAttribute(const std::string& name) const
{
for(const auto& b : buffers) if(b.second.HasAttribute(name)) return true;
return false;
}
// Store vertices and attributes
std::map<std::string, Element> buffers;
// Stores index buffers for each sub-object
std::multimap<std::string, Element> objects;
// Stores pixmaps
std::map<std::string, GlTexture> textures;
};
GlGeometry::Element ToGlGeometry(const Geometry::Element& el, GlBufferType buffertype);
GlGeometry ToGlGeometry(const Geometry& geom);
void GlDraw(GlSlProgram& prog, const GlGeometry& geom, const GlTexture *matcap);
}

View File

@@ -1,283 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2011 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <sstream>
#include <algorithm>
// Cg includes
#include <Cg/cg.h>
#include <Cg/cgGL.h>
#include "gl.h"
#ifdef HAVE_TOON
#include <TooN/TooN.h>
#endif // HAVE_TOON
namespace pangolin
{
////////////////////////////////////////////////
// Interface
////////////////////////////////////////////////
/// Lightweight object wrapper for NVidia Cg Shader program objects.
class CgProgram
{
friend class CgLoader;
public:
void SetUniform(const std::string& name, GlTexture& tex);
void SetUniform(const std::string& name, float f);
void SetUniform(const std::string& name, float v0, float v1);
void SetUniform(const std::string& name, float v0, float v1, float v2, float v3);
#ifdef HAVE_TOON
void SetUniform(const std::string& name, const TooN::Vector<2>& v );
void SetUniform(const std::string& name, const TooN::Vector<3>& v );
template <int R, int C>
void SetUniform(const std::string& name, const TooN::Matrix<R,C>& M );
#endif
void UpdateParams();
protected:
CGprogram mProg;
CGcontext mContext;
CGprofile mProfile;
};
class CgLoader
{
public:
CgLoader();
~CgLoader();
// Call AFTER glewInit (or similar)
void Initialise();
CgProgram LoadProgramFromFile(const std::string& file, const std::string& function, bool isVertexShader );
void EnableProgram(CgProgram program);
void DisablePrograms();
void RenderDummyQuad();
void RenderDummyQuadWithTexCoords(int w, int h);
protected:
CGcontext mContext;
CGprofile mFragmentProfile;
CGprofile mVertexProfile;
};
////////////////////////////////////////////////
// Implementation
////////////////////////////////////////////////
inline bool cgOkay()
{
CGerror error;
const char *string = cgGetLastErrorString(&error);
if (error != CG_NO_ERROR) {
std::cout << "CG Error: " << string << std::endl;
// assert(0);
return false;
}
return true;
}
inline CgLoader::CgLoader()
:mContext(0)
{
}
inline CgLoader::~CgLoader()
{
if(mContext)
{
// Destroying context destroys all programs associated with it
cgDestroyContext(mContext);
}
}
inline void CgLoader::Initialise()
{
mContext = cgCreateContext();
cgSetParameterSettingMode(mContext, CG_DEFERRED_PARAMETER_SETTING);
cgOkay();
mFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT);
cgGLSetOptimalOptions(mFragmentProfile);
cgOkay();
mVertexProfile = cgGLGetLatestProfile(CG_GL_VERTEX);
cgGLSetOptimalOptions(mVertexProfile);
cgOkay();
}
inline CgProgram CgLoader::LoadProgramFromFile(const std::string& file, const std::string& function, bool isVertexShader )
{
if( !mContext ) {
Initialise();
}
CgProgram prog;
prog.mContext = mContext;
prog.mProfile = isVertexShader ? mVertexProfile : mFragmentProfile;
prog.mProg = cgCreateProgramFromFile( prog.mContext, CG_SOURCE, file.c_str(), prog.mProfile, function.c_str(), NULL);
if( !cgOkay() )
{
std::cout << cgGetLastListing(mContext) << std::endl;
assert(0);
}
cgGLLoadProgram(prog.mProg);
if( !cgOkay() )
{
const char* err = cgGetProgramString( prog.mProg, CG_COMPILED_PROGRAM );
int pos;
glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos);
std::cout << err << std::endl;
std::cout << "@ " << pos << std::endl;
assert(0);
}
return prog;
}
inline void CgLoader::EnableProgram(CgProgram program)
{
cgGLBindProgram(program.mProg);
cgGLEnableProfile(program.mProfile);
cgOkay();
}
inline void CgLoader::DisablePrograms()
{
cgGLDisableProfile(mFragmentProfile);
cgGLDisableProfile(mVertexProfile);
}
inline void CgLoader::RenderDummyQuad()
{
glBegin(GL_QUADS);
glVertex2d(-1,1);
glVertex2d(1,1);
glVertex2d(1,-1);
glVertex2d(-1,-1);
glEnd();
}
inline void CgLoader::RenderDummyQuadWithTexCoords(int w, int h)
{
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2d(-1,-1);
glTexCoord2f(w, 0);
glVertex2d(1,-1);
glTexCoord2f(w, h);
glVertex2d(1,1);
glTexCoord2f(0, h);
glVertex2d(-1,1);
glEnd();
}
void CgProgram::SetUniform(const std::string& name, float f)
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
cgSetParameter1f( p, f );
cgUpdateProgramParameters(mProg);
}
void CgProgram::SetUniform(const std::string& name, GlTexture& tex)
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
cgGLSetTextureParameter(p, tex.tid );
cgGLEnableTextureParameter(p);
cgUpdateProgramParameters(mProg);
}
void CgProgram::SetUniform(const std::string& name, float v0, float v1, float v2, float v3)
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
cgGLSetParameter4f(p, v0,v1,v2,v3);
cgUpdateProgramParameters(mProg);
}
void CgProgram::SetUniform(const std::string& name, float v0, float v1)
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
cgGLSetParameter2f(p, v0,v1);
cgUpdateProgramParameters(mProg);
}
#ifdef HAVE_TOON
void CgProgram::SetUniform(const std::string& name, const TooN::Vector<2>& v )
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
cgGLSetParameter2f(p, v[0],v[1] );
cgUpdateProgramParameters(mProg);
}
void CgProgram::SetUniform(const std::string& name, const TooN::Vector<3>& v )
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
cgGLSetParameter3f(p, v[0],v[1],v[2] );
cgUpdateProgramParameters(mProg);
}
template <int R, int C>
void CgProgram::SetUniform(const std::string& name, const TooN::Matrix<R,C>& M )
{
CGparameter p = cgGetNamedParameter( mProg, name.c_str());
float Mdata[R*C];
int i=0;
for( int r=0; r<R; ++r )
for( int c=0; c<C; ++c )
Mdata[i++] = (float)(M[r][c]);
cgGLSetMatrixParameterfr(p, Mdata );
cgUpdateProgramParameters(mProg);
}
#endif
void CgProgram::UpdateParams()
{
cgUpdateProgramParameters(mProg);
}
}

View File

@@ -1,178 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <cmath>
#include <stdexcept>
namespace pangolin
{
/// Represent OpenGL floating point colour: Red, Green and Blue with alpha.
struct Colour
{
inline static Colour White() {
return Colour(1.0f,1.0f,1.0f,1.0f);
}
inline static Colour Black() {
return Colour(0.0f,0.0f,0.0f,1.0f);
}
inline static Colour Red() {
return Colour(1.0f,0.0f,0.0f,1.0f);
}
inline static Colour Green() {
return Colour(0.0f,1.0f,0.0f,1.0f);
}
inline static Colour Blue() {
return Colour(0.0f,0.0f,1.0f,1.0f);
}
inline static Colour Unspecified() {
return Colour(
std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN(),
std::numeric_limits<float>::quiet_NaN(), std::numeric_limits<float>::quiet_NaN()
);
}
/// Default constructs white.
inline Colour()
: red(1.0f), green(1.0f), blue(1.0f), alpha(1.0f)
{
}
/// Construct from component values
inline Colour(const float red, const float green, const float blue, const float alpha = 1.0f)
: red(red), green(green), blue(blue), alpha(alpha)
{
}
/// Construct from rgba array.
inline Colour(const float rgba[4])
{
r = rgba[0];
g = rgba[1];
b = rgba[2];
a = rgba[3];
}
/// Return pointer to OpenGL compatible RGBA array.
inline float* Get()
{
return c;
}
/// Return this colour with alpha adjusted.
inline Colour WithAlpha(const float alpha)
{
return Colour(r,g,b,alpha);
}
/// Construct from HSV Colour
/// @param hue Colour hue in range [0,1]
/// @param sat Saturation in range [0,1]
/// @param val Value / Brightness in range [0,1].
static inline Colour Hsv(const float hue, const float sat = 1.0f, const float val = 1.0f, const float alpha = 1.0f)
{
const float h = 6.0f * hue;
const int i = (int)floor(h);
const float f = (i%2 == 0) ? 1-(h-i) : h-i;
const float m = val * (1-sat);
const float n = val * (1-sat*f);
switch(i)
{
case 0: return Colour(val,n,m,alpha);
case 1: return Colour(n,val,m,alpha);
case 2: return Colour(m,val,n,alpha);
case 3: return Colour(m,n,val,alpha);
case 4: return Colour(n,m,val,alpha);
case 5: return Colour(val,m,n,alpha);
default:
throw std::runtime_error("Found extra colour in rainbow.");
}
}
union {
struct {
float red;
float green;
float blue;
float alpha;
};
struct {
float r;
float g;
float b;
float a;
};
float c[4];
};
};
/// A ColourWheel is like a continuous colour palate that can be sampled.
/// In the future, different ColourWheels will be supported, but this one
/// is based on sampling hues in HSV colourspace. An indefinite number of
/// unique colours are sampled using the golden angle.
class ColourWheel
{
public:
/// Construct ColourWheel with Saturation, Value and Alpha constant.
inline ColourWheel(float saturation = 0.5f, float value = 1.0f, float alpha = 1.0f)
: unique_colours(0), sat(saturation), val(value), alpha(alpha)
{
}
/// Use Golden ratio (/angle) to pick well spaced colours.
inline Colour GetColourBin(int i) const
{
float hue = i * 0.5f * (3.0f - sqrt(5.0f));
hue -= (int)hue;
return Colour::Hsv(hue,sat,val,alpha);
}
/// Return next unique colour from ColourWheel.
inline Colour GetUniqueColour()
{
return GetColourBin(unique_colours++);
}
/// Reset colour wheel counter to initial state
inline void Reset() {
unique_colours = 0;
}
protected:
int unique_colours;
float sat;
float val;
float alpha;
};
}

View File

@@ -1,320 +0,0 @@
/* This file is part of the Pangolin Project.
* http://github.com/stevenlovegrove/Pangolin
*
* Copyright (c) 2014 Steven Lovegrove
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once
#include <stack>
#include <pangolin/opengl_render_state.h>
#include <pangolin/glsl.h>
namespace pangolin {
class GlEngine
{
public:
const char* vert =
"attribute vec4 a_position;\n"
"attribute vec4 a_color;\n"
"attribute vec3 a_normal;\n"
"attribute vec2 a_texcoord;\n"
"uniform vec4 u_color;\n"
"uniform mat4 u_modelViewMatrix;\n"
"uniform mat4 u_modelViewProjectionMatrix;\n"
"varying vec4 v_frontColor;\n"
"varying vec2 v_texcoord;\n"
"void main() {\n"
" gl_Position = u_modelViewProjectionMatrix * a_position;\n"
" v_frontColor = u_color;\n"
" v_texcoord = a_texcoord;\n"
"}\n";
const char* frag =
#ifdef HAVE_GLES_2
"precision mediump float;\n"
#endif // HAVE_GLES_2
"varying vec4 v_frontColor;\n"
"varying vec2 v_texcoord;\n"
"uniform sampler2D u_texture;\n"
"uniform bool u_textureEnable;\n"
"void main() {\n"
" gl_FragColor = v_frontColor;\n"
" if(u_textureEnable) {\n"
" gl_FragColor *= texture2D(u_texture, v_texcoord);\n"
" }\n"
"}\n";
GlEngine()
{
// Initialise default state
projection.push(IdentityMatrix());
modelview.push(IdentityMatrix());
currentmatrix = &modelview;
// Set GL_TEXTURE0 as default active texture
glActiveTexture(GL_TEXTURE0);
// Compile and link shaders
prog_fixed.AddShader(GlSlVertexShader, vert);
prog_fixed.AddShader(GlSlFragmentShader, frag);
prog_fixed.BindPangolinDefaultAttribLocationsAndLink();
// Save locations of uniforms
u_color = prog_fixed.GetUniformHandle("u_color");
u_modelViewMatrix = prog_fixed.GetUniformHandle("u_modelViewMatrix");
u_modelViewProjectionMatrix = prog_fixed.GetUniformHandle("u_modelViewProjectionMatrix");
u_texture = prog_fixed.GetUniformHandle("u_texture");
u_textureEnable = prog_fixed.GetUniformHandle("u_textureEnable");
// Initialise default uniform values
UpdateMatrices();
SetColor(1.0,1.0,1.0,1.0);
}
void UpdateMatrices()
{
OpenGlMatrix pmv = projection.top() * modelview.top();
prog_fixed.SaveBind();
glUniformMatrix4fv( u_modelViewMatrix, 1, false, modelview.top().m );
glUniformMatrix4fv( u_modelViewProjectionMatrix, 1, false, pmv.m );
prog_fixed.Unbind();
}
void SetColor(float r, float g, float b, float a)
{
prog_fixed.SaveBind();
glUniform4f( u_color, r, g, b, a);
prog_fixed.Unbind();
}
void EnableTexturing(GLboolean v)
{
prog_fixed.SaveBind();
glUniform1i( u_textureEnable, v);
prog_fixed.Unbind();
}
//protected:
std::stack<OpenGlMatrix> projection;
std::stack<OpenGlMatrix> modelview;
std::stack<OpenGlMatrix>* currentmatrix;
GLenum matrixmode;
float color[4];
GlSlProgram prog_fixed;
GLint u_color;
GLint u_modelViewMatrix;
GLint u_modelViewProjectionMatrix;
GLint u_texture;
GLint u_textureEnable;
};
GlEngine& glEngine();
}
///////////////////////////////////////////////////////////////////////////////
// OpenGL 1.0 compatibility - Emulate fixed pipeline
///////////////////////////////////////////////////////////////////////////////
// Missing defines that we'll be using
#define GL_MODELVIEW 0x1700
#define GL_PROJECTION 0x1701
#define GL_SHADE_MODEL 0x0B54
#define GL_POINT_SIZE 0x0B11
#define GL_MULTISAMPLE 0x809D
#define GL_LIGHTING 0x0B50
#define GL_POINT_SMOOTH 0x0B10
#define GL_LINE_SMOOTH 0x0B20
#define GL_SCISSOR_TEST 0x0C11
#define GL_COLOR_MATERIAL 0x0B57
#define GL_FLAT 0x1D00
#define GL_SMOOTH 0x1D01
#define GL_MODULATE 0x2100
#define GL_DECAL 0x2101
#define GL_ADD 0x0104
#define GL_TEXTURE_ENV_MODE 0x2200
#define GL_TEXTURE_ENV_COLOR 0x2201
#define GL_TEXTURE_ENV 0x2300
#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
#define GL_POINT_SMOOTH_HINT 0x0C51
#define GL_LINE_SMOOTH_HINT 0x0C52
#define GL_VERTEX_ARRAY 0x8074
#define GL_NORMAL_ARRAY 0x8075
#define GL_COLOR_ARRAY 0x8076
#define GL_TEXTURE_COORD_ARRAY 0x8078
inline void glEnableClientState(GLenum cap)
{
pangolin::GlEngine& gl = pangolin::glEngine();
if(cap == GL_VERTEX_ARRAY) {
glEnableVertexAttribArray(pangolin::DEFAULT_LOCATION_POSITION);
}else if(cap == GL_COLOR_ARRAY) {
glEnableVertexAttribArray(pangolin::DEFAULT_LOCATION_COLOUR);
}else if(cap == GL_NORMAL_ARRAY) {
glEnableVertexAttribArray(pangolin::DEFAULT_LOCATION_NORMAL);
}else if(cap == GL_TEXTURE_COORD_ARRAY) {
glEnableVertexAttribArray(pangolin::DEFAULT_LOCATION_TEXCOORD);
gl.EnableTexturing(true);
}else{
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}
}
inline void glDisableClientState(GLenum cap)
{
pangolin::GlEngine& gl = pangolin::glEngine();
if(cap == GL_VERTEX_ARRAY) {
glDisableVertexAttribArray(pangolin::DEFAULT_LOCATION_POSITION);
}else if(cap == GL_COLOR_ARRAY) {
glDisableVertexAttribArray(pangolin::DEFAULT_LOCATION_COLOUR);
}else if(cap == GL_NORMAL_ARRAY) {
glDisableVertexAttribArray(pangolin::DEFAULT_LOCATION_NORMAL);
}else if(cap == GL_TEXTURE_COORD_ARRAY) {
glDisableVertexAttribArray(pangolin::DEFAULT_LOCATION_TEXCOORD);
gl.EnableTexturing(false);
}else{
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}
}
inline void glVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
{
glVertexAttribPointer(pangolin::DEFAULT_LOCATION_POSITION, size, type, GL_FALSE, stride, pointer);
}
inline void glTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)
{
glVertexAttribPointer(pangolin::DEFAULT_LOCATION_TEXCOORD, size, type, GL_FALSE, stride, pointer);
}
inline void glMatrixMode(GLenum mode)
{
pangolin::GlEngine& gl = pangolin::glEngine();
gl.currentmatrix = (mode == pangolin::GlProjectionStack) ? &gl.projection : &gl.modelview;
}
inline void glLoadIdentity()
{
pangolin::GlEngine& gl = pangolin::glEngine();
gl.currentmatrix->top() = pangolin::IdentityMatrix();
gl.UpdateMatrices();
}
inline void glLoadMatrixf(const GLfloat* m)
{
pangolin::GlEngine& gl = pangolin::glEngine();
pangolin::GLprecision* cm = gl.currentmatrix->top().m;
for(int i=0; i<16; ++i) cm[i] = (pangolin::GLprecision)m[i];
gl.UpdateMatrices();
}
inline void glLoadMatrixd(const GLdouble* m)
{
pangolin::GlEngine& gl = pangolin::glEngine();
pangolin::GLprecision* cm = gl.currentmatrix->top().m;
for(int i=0; i<16; ++i) cm[i] = (pangolin::GLprecision)m[i];
gl.UpdateMatrices();
}
inline void glMultMatrixf(const GLfloat* m)
{
// pangolin::GlEngine& gl = pangolin::glEngine();
// float res[16];
// pangolin::MatMul<4,4,4,float>(res, m, gl.currentmatrix->m );
// std::memcpy(gl.currentmatrix->m, res, sizeof(float) * 16 );
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}
inline void glMultMatrixd(const GLdouble* m)
{
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}
inline void glPushMatrix(void)
{
pangolin::GlEngine& gl = pangolin::glEngine();
gl.currentmatrix->push(gl.currentmatrix->top());
}
inline void glPopMatrix(void)
{
pangolin::GlEngine& gl = pangolin::glEngine();
gl.currentmatrix->pop();
gl.UpdateMatrices();
}
inline void glTranslatef(GLfloat x, GLfloat y, GLfloat z )
{
pangolin::GlEngine& gl = pangolin::glEngine();
pangolin::GLprecision* cm = gl.currentmatrix->top().m;
cm[12] += x;
cm[13] += y;
cm[14] += z;
gl.UpdateMatrices();
}
inline void glOrtho(
GLdouble l, GLdouble r,
GLdouble b, GLdouble t,
GLdouble n, GLdouble f)
{
pangolin::GlEngine& gl = pangolin::glEngine();
gl.currentmatrix->top() = pangolin::ProjectionMatrixOrthographic(l,r,b,t,n,f);
gl.UpdateMatrices();
}
inline void glColor4f( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)
{
pangolin::glEngine().SetColor(red,green,blue,alpha);
}
inline void glShadeModel( GLenum mode)
{
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}
inline void glPointSize(GLfloat size)
{
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}
inline void glTexEnvf( GLenum target,
GLenum pname,
GLfloat param)
{
pango_print_error("Not Implemented: %s, %s, %d", __FUNCTION__, __FILE__, __LINE__);
}

Some files were not shown because too many files have changed in this diff Show More