Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Imgui #4

Merged
merged 27 commits into from
Dec 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/ci-emscripten.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Publish web app version to gh-pages

on:
push:
branches:
- "*"
pull_request:
- "*"
paths:
# This action only runs on push when C++ files are changed
- "**.cpp"
- "**.h"
- "**.cmake"
- "**Lists.txt"
- "**-emscripten.yml"
workflow_dispatch:

env:
CPM_SOURCE_CACHE: ${{ github.workspace }}/cpm_modules

jobs:
build:
name: Build and deploy
runs-on: macos-12

steps:
- name: Install dependencies
run: brew install ninja emscripten

- uses: actions/checkout@v3

- uses: actions/cache@v3
with:
path: "**/cpm_modules"
key: ${{ github.workflow }}-cpm-modules-${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}

# Setup caching of build artifacts to reduce total build time (only Linux and MacOS)
- name: ccache
uses: hendrikmuhs/[email protected]

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

- name: Configure CMake
run: |
emcmake cmake -B ${{github.workspace}}/build -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache

- name: Build
run: cmake --build ${{github.workspace}}/build --parallel 4

- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: build-artifacts
path: |
${{github.workspace}}/build

- name: Copy web app
working-directory: ${{github.workspace}}/build
run: |
mkdir deploy
cp Samplin\ Safari.data Samplin\ Safari.html Samplin\ Safari.js Samplin\ Safari.wasm deploy/
mv deploy/Samplin\ Safari.html deploy/index.html

- name: Publish
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ${{github.workspace}}/build/deploy
4 changes: 2 additions & 2 deletions .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build/${{ matrix.buildtype }} --parallel 4 --config ${{ matrix.buildtype }}

- name: Checking that SamplinSafari runs
- name: Checking that Samplin Safari runs
run: |
${{github.workspace}}/build/${{ matrix.buildtype }}/SamplinSafari --help
${{github.workspace}}/build/${{ matrix.buildtype }}/Samplin\ Safari --help

- name: Archive build artifacts
uses: actions/upload-artifact@v3
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,17 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --parallel 4 --config ${{ matrix.buildtype }}

- name: Checking that SamplinSafari runs
- name: Checking that Samplin Safari runs
if: runner.os != 'Windows'
run: |
${{github.workspace}}/build/${{ runner.os == 'macOS' && 'SamplinSafari.app/Contents/MacOS/SamplinSafari' || 'SamplinSafari' }} --help
${{github.workspace}}/build/${{ runner.os == 'macOS' && 'Samplin\ Safari.app/Contents/MacOS/Samplin\ Safari' || 'Samplin\ Safari' }} --help

- name: Creating dmg (macOS)
if: runner.os == 'macOS'
run: |
RESULT="${{github.workspace}}/build/SamplinSafari${{ matrix.config.suffix }}.dmg"
test -f $RESULT && rm $RESULT
create-dmg --window-size 500 300 --icon-size 96 --volname "SamplinSafari Installer" --app-drop-link 360 105 --icon SamplinSafari.app 130 105 $RESULT ${{github.workspace}}/build/SamplinSafari.app
create-dmg --window-size 500 300 --icon-size 96 --volname "Samplin Safari Installer" --app-drop-link 360 105 --icon Samplin\ Safari.app 130 105 $RESULT ${{github.workspace}}/build/Samplin\ Safari.app

- name: Archive dmg (macOS)
if: runner.os == 'macOS'
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
- name: Build
run: cmake --build ${{github.workspace}}/build --parallel --config ${{ matrix.buildtype }} --verbose

- name: Checking that SamplinSafari runs
- name: Checking that Samplin Safari runs
run: |
${{github.workspace}}/build/${{ matrix.buildtype }}/SamplinSafari.exe --help
"${{github.workspace}}/build/${{ matrix.buildtype }}/Samplin Safari.exe --help"

- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: SamplinSafari
name: Samplin Safari
path: |
${{github.workspace}}/build/${{ matrix.buildtype }}/SamplinSafari.exe
"${{github.workspace}}/build/${{ matrix.buildtype }}/Samplin Safari.exe"
188 changes: 85 additions & 103 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,40 @@ cmake_minimum_required(VERSION 3.13)

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/" "${CMAKE_SOURCE_DIR}/resources")

include(VersionFromGit)

string(TIMESTAMP BUILD_TIME "%Y-%m-%d %H:%M")
message(STATUS "Saving build timestamp: ${BUILD_TIME}")

version_from_git(
LOG ON
TIMESTAMP "%Y-%m-%d-%H:%M:%S"
ARG_UTC)

project(
SamplinSafari
DESCRIPTION
"A research tool to visualize and interactively inspect high-dimensional (quasi) Monte Carlo samplers."
# VERSION ${VERSION}
LANGUAGES C CXX)

set(SAMPLINSAFARI_VERSION "${GIT_DESCRIBE}")
VERSION ${VERSION}
LANGUAGES C CXX
)

if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(SAMPLINSAFARI_VERSION "${SAMPLINSAFARI_VERSION} (64 bit)")
set(VERSION_LONG "${SEMVER} (64 bit)")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(SAMPLINSAFARI_VERSION "${SAMPLINSAFARI_VERSION} (32 bit)")
set(VERSION_LONG "${SEMVER} (32 bit)")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/common.cpp.in ${CMAKE_CURRENT_BINARY_DIR}/src/common.cpp @ONLY)

include(sanitizers)

# Set ourselves as the startup project in visual studio. Not available until cmake 3.6, but doesn't break older
# versions.
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT SamplinSafari)

set(USE_IWYU OFF CACHE BOOL "INCLUDE WHAT YOU USE")

include(CheckCXXCompilerFlag)

# prevent glfw from changing the directory on macOS bundles
# SET(GLFW_USE_CHDIR OFF CACHE BOOL "Prevent glfwInit from chdir to Contents/Resources" FORCE)

# ============================================================================
# Set a default build configuration (Release)
# ============================================================================
Expand All @@ -50,10 +53,6 @@ if(CMAKE_GENERATOR MATCHES "Visual Studio")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
endif()

if(APPLE)
set(CMAKE_MACOSX_RPATH ON)
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# Prefer libc++ in conjunction with Clang
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
Expand Down Expand Up @@ -126,12 +125,6 @@ endif()
# ============================================================================
include(cmake/CPM.cmake)

cpmaddpackage("gh:mitsuba-renderer/tinyformat#43816c694297a27909da0982f91315fb33d60676")
if(tinyformat_ADDED)
add_library(tinyformat INTERFACE IMPORTED)
target_include_directories(tinyformat INTERFACE "${tinyformat_SOURCE_DIR}")
endif()

cpmaddpackage("gh:wjakob/pcg32#70099eadb86d3999c38cf69d2c55f8adc1f7fe34")
if(pcg32_ADDED)
add_library(pcg32 INTERFACE IMPORTED)
Expand All @@ -143,29 +136,28 @@ if(galois_ADDED)
target_include_directories(galois++ INTERFACE "${galois_SOURCE_DIR}/include")
endif()

set(NANOGUI_BACKEND "OpenGL" CACHE BOOL " " FORCE)
cpmaddpackage("gh:sgorsten/[email protected]")
if(linalg_ADDED)
add_library(linalg INTERFACE IMPORTED)
target_include_directories(linalg INTERFACE "${linalg_SOURCE_DIR}")
endif()

cpmaddpackage("gh:fmtlib/fmt#7.1.3")

cpmaddpackage("gh:samhocevar/portable-file-dialogs#7f852d88a480020d7f91957cbcefe514fc95000c")
if(portable_file_dialogs_ADDED)
add_library(portable_file_dialogs INTERFACE IMPORTED)
target_include_directories(portable_file_dialogs INTERFACE "${portable_file_dialogs_SOURCE_DIR}")
endif()

cpmaddpackage(
NAME
nanogui
GITHUB_REPOSITORY
Tom94/nanogui-1
GIT_TAG
cf8baf7c2a02a0e8443379a6b80f6709139f84a0
NAME hello_imgui
GITHUB_REPOSITORY pthom/hello_imgui
GIT_TAG "c57e60ad898abd79524d073f3801b80d87ce5468"
OPTIONS
"NANOGUI_BACKEND OpenGL"
"NANOGUI_BUILD_EXAMPLES OFF"
"NANOGUI_BUILD_SHARED OFF"
"NANOGUI_BUILD_PYTHON OFF"
"NANOGUI_INSTALL OFF"
"EXCLUDE_FROM_ALL YES")
if(nanogui_ADDED)
add_library(nanogui::nanogui INTERFACE IMPORTED)
target_include_directories(
nanogui::nanogui SYSTEM INTERFACE ${nanogui_SOURCE_DIR}/ext/glfw/include ${nanogui_SOURCE_DIR}/ext/nanovg/src
${nanogui_SOURCE_DIR}/include ${NANOGUI_EXTRA_INCS})
target_link_libraries(nanogui::nanogui INTERFACE "nanogui")
target_compile_definitions(nanogui::nanogui INTERFACE "${NANOGUI_BACKEND_DEFS}")
endif()
"HELLOIMGUI_WITH_GLFW ON"
"HELLOIMGUI_WITH_TEST_ENGINE OFF"
)


# ============================================================================
Expand Down Expand Up @@ -211,74 +203,66 @@ add_library(samplerlib OBJECT STATIC
include/sampler/Random.h
include/sampler/RandomPermutation.h
include/sampler/Sobol.h
src/Misc.cpp
src/Halton.cpp
src/Jittered.cpp
src/LP.cpp
src/MultiJittered.cpp
src/NRooks.cpp
src/OA.cpp
src/OAAddelmanKempthorne.cpp
src/OABose.cpp
src/OABoseBush.cpp
src/OABush.cpp
src/OACMJND.cpp
src/SOA.cpp
src/Random.cpp
src/Sobol.cpp
src/SobolMatrices.cpp)
src/sampler/Misc.cpp
src/sampler/Halton.cpp
src/sampler/Jittered.cpp
src/sampler/LP.cpp
src/sampler/MultiJittered.cpp
src/sampler/NRooks.cpp
src/sampler/OA.cpp
src/sampler/OAAddelmanKempthorne.cpp
src/sampler/OABose.cpp
src/sampler/OABoseBush.cpp
src/sampler/OABush.cpp
src/sampler/OACMJND.cpp
src/sampler/SOA.cpp
src/sampler/Random.cpp
src/sampler/Sobol.cpp
src/sampler/SobolMatrices.cpp)

# Link dependencies
target_link_libraries(
samplerlib
PUBLIC galois++ pcg32 tinyformat
)
PUBLIC galois++ pcg32)

set_target_properties(samplerlib PROPERTIES CXX_STANDARD 17)
set_target_properties(samplerlib PROPERTIES
CXX_STANDARD 17)

# Resource file (icons etc.)
set(EXTRA_SOURCE "")
if (APPLE)
set(EXTRA_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/resources/icon.icns")
elseif(WIN32)
#set(EXTRA_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/resources/icon.rc")
endif()

# The following lines build the main executable.
add_executable(SamplinSafari MACOSX_BUNDLE
gui/SampleViewer.cpp
gui/SampleViewer.h
gui/main.cpp
gui/Well.cpp
gui/Well.h
${EXTRA_SOURCE}
)

add_definitions(${NANOGUI_EXTRA_DEFS})
target_link_libraries(
SamplinSafari
PRIVATE nanogui::nanogui
tinyformat
samplerlib)
# Now build the Samplin' Safari viewer app
string(TIMESTAMP YEAR "%Y")

set(output_name "Samplin Safari")
set(HELLO_IMGUI_BUNDLE_IDENTIFIER_URL_PART "com.im.SamplinSafari")
set(HELLO_IMGUI_BUNDLE_IDENTIFIER_NAME_PART ${app_name})
set(HELLO_IMGUI_ICON_DISPLAY_NAME ${output_name})
set(HELLO_IMGUI_BUNDLE_NAME ${output_name})
set(HELLO_IMGUI_BUNDLE_COPYRIGHT "© Wojciech Jarosz, ${YEAR}")
set(HELLO_IMGUI_BUNDLE_EXECUTABLE ${output_name})
set(HELLO_IMGUI_BUNDLE_VERSION ${VERSION})
set(HELLO_IMGUI_BUNDLE_SHORT_VERSION ${VERSION})
set(HELLO_IMGUI_BUNDLE_ICON_FILE icon.icns)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/shell.emscripten.html.in ${CMAKE_CURRENT_SOURCE_DIR}/shell.emscripten.html @ONLY)

hello_imgui_add_app(SamplinSafari
src/app.cpp
${CMAKE_CURRENT_BINARY_DIR}/src/common.cpp
src/shader.cpp
src/export_to_file.cpp
)

set_target_properties(SamplinSafari PROPERTIES
OUTPUT_NAME "SamplinSafari"
CXX_STANDARD 17)
OUTPUT_NAME ${output_name}
CXX_STANDARD 17
)

if (APPLE)
# Build an application bundle on OSX
set_target_properties(SamplinSafari PROPERTIES
MACOSX_BUNDLE_BUNDLE_NAME "Samplin' Safari"
MACOSX_BUNDLE_BUNDLE_GUI_IDENTIFIER "com.im.SamplinSafari"
MACOSX_BUNDLE_ICON_FILE icon.icns
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/MacOSXBundleInfo.plist.in
MACOSX_BUNDLE_INFO_STRING "Samplin' Safari"
MACOSX_BUNDLE_COPYRIGHT "© Wojciech Jarosz")
set_source_files_properties(resources/icon.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
else()
# Insulate from a few types of ABI changes by statically linking against libgcc and libstdc++
set_target_properties(SamplinSafari PROPERTIES LINK_FLAGS "-static-libgcc")
endif()
target_link_libraries(
SamplinSafari
PRIVATE samplerlib
linalg
fmt::fmt
portable_file_dialogs
)

if (UNIX AND NOT ${U_CMAKE_BUILD_TYPE} MATCHES DEBUG)
add_custom_command(TARGET SamplinSafari POST_BUILD COMMAND strip $<TARGET_FILE:SamplinSafari>)
Expand All @@ -294,5 +278,3 @@ if(CMAKE_GENERATOR STREQUAL "Ninja")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color=always")
endif()
endif()

target_compile_features(samplerlib PRIVATE cxx_std_17)
Loading
Loading