Skip to content

Commit

Permalink
Fixes for windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenlovegrove committed Dec 5, 2020
1 parent 15f67b9 commit 193478d
Show file tree
Hide file tree
Showing 14 changed files with 247 additions and 183 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,24 @@ jobs:

strategy:
matrix:
os: [ubuntu-20.04, macos-11.0]
include:
- os: ubuntu-20.04
- os: macos-11.0
- os: windows-2019
cmake_toolchain_file: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"

steps:
- uses: actions/checkout@v2

- name: Install Dependencies
run: $GITHUB_WORKSPACE/scripts/install_prerequisites.sh -v -u -m "apt-get brew" all
run: $GITHUB_WORKSPACE/scripts/install_prerequisites.sh -v -u -m "apt-get brew vcpkg" all

- name: Create Build Directory
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
working-directory: ${{runner.workspace}}/build
run: cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE $GITHUB_WORKSPACE
run: cmake -DCMAKE_TOOLCHAIN_FILE=${{matrix.cmake_toolchain_file}} -DCMAKE_BUILD_TYPE=$BUILD_TYPE $GITHUB_WORKSPACE

- name: Build
working-directory: ${{runner.workspace}}/build
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ CMakeLists.txt.user
build*
_builds
_logs
.vscode
33 changes: 0 additions & 33 deletions cmake/FindLibRealSense.cmake

This file was deleted.

33 changes: 0 additions & 33 deletions cmake/FindLibRealSense2.cmake

This file was deleted.

33 changes: 33 additions & 0 deletions cmake/FindRealSense.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: cmake; -*-
###############################################################################
# Find realsense https://github.com/IntelRealSense/librealsense
#
# This sets the following variables:
# REALSENSE_FOUND - True if RealSense was found.
# REALSENSE_INCLUDE_DIRS - Directories containing the RealSense include files.
# REALSENSE_LIBRARIES - Libraries needed to use RealSense.
# REALSENSE_DEFINITIONS - Compiler flags for RealSense.
#
# 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(REALSENSE_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(REALSENSE_LIBRARY
NAMES realsense
HINTS /usr/lib /usr/local/lib )

set(REALSENSE_INCLUDE_DIRS ${REALSENSE_INCLUDE_DIR})
set(REALSENSE_LIBRARIES ${REALSENSE_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RealSense DEFAULT_MSG
REALSENSE_LIBRARY REALSENSE_INCLUDE_DIR)

mark_as_advanced(REALSENSE_LIBRARY REALSENSE_INCLUDE_DIR)
33 changes: 33 additions & 0 deletions cmake/FindRealSense2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- mode: cmake; -*-
###############################################################################
# Find realsense2 https://github.com/IntelRealSense/librealsense
#
# This sets the following variables:
# REALSENSE2_FOUND - True if REALSENSE2 was found.
# REALSENSE2_INCLUDE_DIRS - Directories containing the REALSENSE2 include files.
# REALSENSE2_LIBRARIES - Libraries needed to use REALSENSE2.
# REALSENSE2_DEFINITIONS - Compiler flags for REALSENSE2.
#
# 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(REALSENSE2_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(REALSENSE2_LIBRARY
NAMES realsense2
HINTS /usr/lib /usr/local/lib )

set(REALSENSE2_INCLUDE_DIRS ${REALSENSE2_INCLUDE_DIR})
set(REALSENSE2_LIBRARIES ${REALSENSE2_LIBRARY})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(RealSense2 DEFAULT_MSG
REALSENSE2_LIBRARY REALSENSE2_INCLUDE_DIR)

mark_as_advanced(REALSENSE2_LIBRARY REALSENSE2_INCLUDE_DIR)
6 changes: 4 additions & 2 deletions components/pango_core/include/pangolin/platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
#ifdef __GNUC__
# define PANGOLIN_DEPRECATED(x) __attribute__((deprecated(x)))
#elif defined(_MSC_VER)
# define PANGOLIN_DEPRECATED __declspec(deprecated(x))
# define PANGOLIN_DEPRECATED(x) __declspec(deprecated(x))
#else
# define PANGOLIN_DEPRECATED
# define PANGOLIN_DEPRECATED(x)
#endif

#ifdef _MSC_VER
# define __thread __declspec(thread)
// TODO: Fix this for shared libs on Windows
# define PANGOLIN_EXPORT
#else
# define PANGOLIN_EXPORT
#endif //_MSVC_
Expand Down
32 changes: 16 additions & 16 deletions components/pango_video/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,27 +89,27 @@ if(BUILD_PANGOLIN_FFMPEG)
endif()
endif()

option(BUILD_PANGOLIN_LIBREALSENSE "Build support for LibRealSense video input" ON)
if(BUILD_PANGOLIN_LIBREALSENSE)
find_package(LibRealSense QUIET)
if(LIBREALSENSE_FOUND)
option(BUILD_PANGOLIN_REALSENSE "Build support for RealSense video input" ON)
if(BUILD_PANGOLIN_REALSENSE)
find_package(RealSense QUIET)
if(REALSENSE_FOUND)
target_sources( ${COMPONENT} PRIVATE ${DRIVER_DIR}/realsense.cpp)
target_link_libraries(${COMPONENT} PRIVATE ${LIBREALSENSE_LIBRARIES} )
target_include_directories(${COMPONENT} PRIVATE ${LIBREALSENSE_INCLUDE_DIRS} )
target_link_libraries(${COMPONENT} PRIVATE ${REALSENSE_LIBRARIES} )
target_include_directories(${COMPONENT} PRIVATE ${REALSENSE_INCLUDE_DIRS} )
PangolinRegisterFactory( VideoInterface RealSenseVideo )
message(STATUS "LibRealSense Found and Enabled")
message(STATUS "RealSense Found and Enabled")
endif()
endif()

option(BUILD_PANGOLIN_LIBREALSENSE2 "Build support for LibRealSense2 video input" ON)
if(BUILD_PANGOLIN_LIBREALSENSE2)
find_package(LibRealSense2 QUIET)
if(LIBREALSENSE2_FOUND)
option(BUILD_PANGOLIN_REALSENSE2 "Build support for RealSense2 video input" ON)
if(BUILD_PANGOLIN_REALSENSE2)
find_package(RealSense2 QUIET)
if(REALSENSE2_FOUND)
target_sources( ${COMPONENT} PRIVATE ${DRIVER_DIR}/realsense2.cpp)
target_link_libraries(${COMPONENT} PRIVATE ${LIBREALSENSE2_LIBRARIES} )
target_include_directories(${COMPONENT} PRIVATE ${LIBREALSENSE2_INCLUDE_DIRS} )
target_link_libraries(${COMPONENT} PRIVATE ${REALSENSE2_LIBRARIES} )
target_include_directories(${COMPONENT} PRIVATE ${REALSENSE2_INCLUDE_DIRS} )
PangolinRegisterFactory( VideoInterface RealSense2Video )
message(STATUS "LibRealSense2 Found and Enabled")
message(STATUS "RealSense2 Found and Enabled")
endif()
endif()

Expand Down Expand Up @@ -166,7 +166,7 @@ if (BUILD_PANGOLIN_UVC_MEDIAFOUNDATION)
if (MediaFoundation_FOUND)
target_sources( ${COMPONENT} PRIVATE ${DRIVER_DIR}/uvc_mediafoundation.cpp)
target_link_libraries(${COMPONENT} PRIVATE ${MediaFoundation_LIBRARIES} )
PangolinRegisterFactory( VideoInterface UvcMediaFoundation )
PangolinRegisterFactory( VideoInterface UvcMediaFoundationVideo )
message(STATUS "MediaFoundation Found and Enabled")
endif()
endif()
Expand All @@ -178,7 +178,7 @@ if(BUILD_PANGOLIN_DEPTHSENSE)
target_sources( ${COMPONENT} PRIVATE ${DRIVER_DIR}/depthsense.cpp)
target_link_libraries(${COMPONENT} PRIVATE ${DepthSense_LIBRARIES} )
target_include_directories(${COMPONENT} PRIVATE ${DepthSense_INCLUDE_DIRS} )
PangolinRegisterFactory( VideoInterface DepthSense )
PangolinRegisterFactory( VideoInterface DepthSenseVideo )
message(STATUS "DepthSense Found and Enabled")
endif()
endif()
Expand Down
2 changes: 1 addition & 1 deletion components/pango_video/src/drivers/openni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ PANGOLIN_REGISTER_FACTORY(OpenNiVideo)
struct OpenNiVideoFactory final : public TypedFactoryInterface<VideoInterface> {
std::map<std::string,Precedence> Schemes() const override
{
return {{"openni1",10}, {"openni",100}, {"kinect",100}};
return {{"openni1",10}, {"openni",100}, {"oni",100}};
}
const char* Description() const override
{
Expand Down
33 changes: 29 additions & 4 deletions components/pango_video/src/drivers/openni2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
#include <OniVersion.h>
#include <PS1080.h>

// OpenNI must be including a horrid windows header
// which defines these nasty macros.
#undef max
#undef min

namespace pangolin
{

Expand Down Expand Up @@ -638,6 +643,27 @@ size_t OpenNi2Video::Seek(size_t frameid)
PANGOLIN_REGISTER_FACTORY(OpenNi2Video)
{
struct OpenNI2VideoFactory final : public TypedFactoryInterface<VideoInterface> {
std::map<std::string,Precedence> Schemes() const override
{
return {{"openni2",10}, {"openni",10}, {"oni",10}};
}
const char* Description() const override
{
return "OpenNI v2 Driver to access Kinect / Primesense devices.";
}
ParamSet Params() const override
{
return {{
{"size","640x480","Image dimension"},
{"fps","30","Framerate"},
{"roi","0+0+0x0","Region of interest"},
{"realtime","","If playback rate should be slowed to real-time speed."},
{"img\\d+", "","Device stream for nth image. Choose from [gray,rgb,ir,depth1mm,depth100um,depth_reg,ir8,ir24,ir+,ir8+]"},
{"closerange","false","Use close-range mode (lower projector intensity)"},
{"holefilter","false","Enable hole filter"},
{"fastcrop","false","?"}
}};
}
std::unique_ptr<VideoInterface> Open(const Uri& uri) override {
const bool realtime = uri.Contains("realtime");
const ImageDim default_dim = uri.Get<ImageDim>("size", ImageDim(640,480));
Expand Down Expand Up @@ -681,10 +707,9 @@ PANGOLIN_REGISTER_FACTORY(OpenNi2Video)
}
};

auto factory = std::make_shared<OpenNI2VideoFactory>();
FactoryRegistry::I()->RegisterFactory<VideoInterface>(factory, 10, "openni");
FactoryRegistry::I()->RegisterFactory<VideoInterface>(factory, 10, "openni2");
FactoryRegistry::I()->RegisterFactory<VideoInterface>(factory, 10, "oni");
return FactoryRegistry::I()->RegisterFactory<VideoInterface>(
std::make_shared<OpenNI2VideoFactory>()
);
}

}
4 changes: 2 additions & 2 deletions components/pango_video/src/drivers/uvc_mediafoundation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,7 @@ bool UvcMediaFoundationVideo::SymLinkIDMatches(const std::wstring& symLink, cons

PANGOLIN_REGISTER_FACTORY(UvcMediaFoundationVideo)
{
struct UvcVideoFactory final : public TypedFactoryInterface<VideoInterface>
struct UvcMediaFoundationVideoFactory final : public TypedFactoryInterface<VideoInterface>
{
std::map<std::string,Precedence> Schemes() const override
{
Expand Down Expand Up @@ -1085,7 +1085,7 @@ PANGOLIN_REGISTER_FACTORY(UvcMediaFoundationVideo)
}
};

return FactoryRegistry::I()->RegisterFactory<VideoInterface>(std::make_shared<UvcVideoFactory>());
return FactoryRegistry::I()->RegisterFactory<VideoInterface>(std::make_shared<UvcMediaFoundationVideoFactory>());
}
}

26 changes: 13 additions & 13 deletions components/pango_windowing/include/pangolin/windowing/WinWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,48 +27,45 @@

#pragma once

#include <pangolin/platform.h>
#include <pangolin/display/display_internal.h>

#include <string>

#include <pangolin/platform.h>
#include <pangolin/windowing/window.h>
#include <windowsx.h>

namespace pangolin
{

struct WinWindow : public PangolinGl
struct WinWindow : public WindowInterface
{
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 ShowFullscreen(const TrueFalseToggle on_off) override;

void MakeCurrent() override;

void RemoveCurrent() override;

void SwapBuffers() override;

void ProcessEvents() override;

void SwapBuffers() override;

HGLRC GetGLRenderContext()
{
return hGLRC;
}

private:
void StartFullScreen();
void StopFullScreen();

static LRESULT APIENTRY WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);

LRESULT HandleWinMessages(UINT message, WPARAM wParam, LPARAM lParam);
Expand All @@ -84,6 +81,9 @@ struct WinWindow : public PangolinGl
HDC hDC;
HGLRC hGLRC;
HPALETTE hPalette;
bool bIsFullscreen;
RECT cWindowedRect;
float afLastMousePos[2];
};

}
Loading

0 comments on commit 193478d

Please sign in to comment.