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

Adding CMake-ified, devcontainer-enabled version of ImGuizmo #307

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 52 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.154.0/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",

// Sets the run context to one level up instead of the .devcontainer folder.
"context": "..",

// Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
"dockerFile": "../Dockerfile",

// Set *default* container specific settings.json values on container create.
"settings": {
"terminal.integrated.shell.linux": null
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [ "ms-vscode.cpptools", "twxs.cmake", "ms-vscode.cmake-tools" ],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Uncomment the next line to run commands after the container is created - for example installing curl.
// "postCreateCommand": "apt-get update && apt-get install -y curl",

// Run this command on the host before the container is created
"initializeCommand": "xhost +SI:localuser:root",

// The optional 'runArgs' property can be used to specify additional runtime arguments.
"runArgs": [
"--privileged",
"-e", "DISPLAY=${env:DISPLAY}",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
"--gpus", "all",
// Uncomment the next line to use Docker from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker for details.
// "-v","/var/run/docker.sock:/var/run/docker.sock",

// Uncomment the next line if you will be using a ptrace-based debugger like C++, Go, and Rust.
"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"

// You may want to add a non-root user to your Dockerfile. On Linux, this will prevent
// new files getting created as root. See https://aka.ms/vscode-remote/containers/non-root-user
// for the needed Dockerfile updates and then uncomment the next line.
// "-u", "vscode"
]

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
// "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],

// Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
// "remoteUser": "vscode"
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
build/
.*/
imgui.ini
32 changes: 32 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch example",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/build/example/example_sdl2_opengl3",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "Set Disassembly Flavor to Intel",
"text": "-gdb-set disassembly-flavor intel",
"ignoreFailures": true
}
]
}
]
}
78 changes: 78 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
cmake_minimum_required(VERSION 3.13)

set(CMAKE_CXX_STANDARD 17)

project(imguizmo DESCRIPTION "Immediate mode 3D gizmo for scene editing and other controls based on Dear Imgui")

option(BUILD_SHARED_LIBS "Build shared libs" OFF)

# Create the main target
add_library(${PROJECT_NAME}
GraphEditor.cpp
ImCurveEdit.cpp
ImGradient.cpp
ImGuizmo.cpp
ImSequencer.cpp)

target_include_directories(${PROJECT_NAME}
PUBLIC
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>
$<INSTALL_INTERFACE:ImGuizmo.h>
$<INSTALL_INTERFACE:GraphEditor.h>
$<INSTALL_INTERFACE:ImCurveEdit.h>
$<INSTALL_INTERFACE:ImGradient.h>
$<INSTALL_INTERFACE:ImGuizmo.h>
$<INSTALL_INTERFACE:ImSequencer.h>
$<INSTALL_INTERFACE:ImZoomSlider.h>)

option(IMGUIZMO_BUILD_EXAMPLE "Build example" ON)
if (${IMGUIZMO_BUILD_EXAMPLE})
add_subdirectory(example)
endif()

# Export and install targets and headers
include(GNUInstallDirs)
set(INSTALL_CONFIGDIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

install(EXPORT ${PROJECT_NAME}-targets
FILE
${PROJECT_NAME}Targets.cmake
NAMESPACE
${PROJECT_NAME}::
DESTINATION
${INSTALL_CONFIGDIR})

include(CMakePackageConfigHelpers)

configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}Config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
INSTALL_DESTINATION ${INSTALL_CONFIGDIR}
)

install(FILES
GraphEditor.h
ImCurveEdit.h
ImGradient.h
ImGuizmo.h
ImSequencer.h
ImZoomSlider.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME})

# Install the config, configversion and custom find modules
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
DESTINATION ${INSTALL_CONFIGDIR}
)

export(EXPORT ${PROJECT_NAME}-targets
FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::)

# Register package in user's package registry
export(PACKAGE ${PROJECT_NAME})
36 changes: 36 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

# nvidia docker runtime env
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics,compat32,utility

RUN apt-get update &&\
apt-get install -y \
build-essential \
cmake \
gdb \
git \
libglfw3-dev \
libglew-dev \
libsdl2-dev \
xorg-dev \
apt-utils \
dialog \
x11-apps

WORKDIR /usr/local/src

RUN git clone https://github.com/skaslev/gl3w.git &&\
cd gl3w && mkdir build && cd build &&\
cmake .. && make && make install

RUN git clone https://github.com/aniongithub/imgui-cmake.git &&\
cd imgui-cmake &&\
git submodule update --init --recursive &&\
mkdir build && cd build &&\
cmake -DIMGUI_GLLOADER=gl3w -DIMGUI_GLFW_IMPL=OFF -DBUILD_GLFW_OPENGL3_SAMPLE=OFF -DBUILD_SDL2_OPENGL3_SAMPLE=OFF .. &&\
make && make install
19 changes: 0 additions & 19 deletions Makefile

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Check the sample for the documentation. More to come...
### Graph Editor

Nodes + connections. Custom draw inside nodes is possible with the delegate system in place.
![Image of GraphEditor](Images/nodeeditor.jpg)
![Image of GraphEditor](images/nodeeditor.jpg)

### API doc

Expand Down
Binary file removed bin/ImGuizmoSample.exe
Binary file not shown.
25 changes: 0 additions & 25 deletions bin/imgui.ini

This file was deleted.

10 changes: 10 additions & 0 deletions cmake/imguizmoConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
get_filename_component(@PROJECT_NAME@_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(CMakeFindDependencyMacro)

list(APPEND CMAKE_MODULE_PATH ${@PROJECT_NAME@_CMAKE_DIR})

if(NOT TARGET @PROJECT_NAME@::@PROJECT_NAME@)
include("${@PROJECT_NAME@_CMAKE_DIR}/@[email protected]")
endif()

set(@PROJECT_NAME@_LIBRARIES @PROJECT_NAME@::@PROJECT_NAME@)
28 changes: 28 additions & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
cmake_minimum_required(VERSION 2.8.12)

project(example_sdl2_opengl3)

set(OpenGL_GL_PREFERENCE "GLVND")
find_package(OpenGL REQUIRED)

find_package(imgui QUIET COMPONENTS imgui-core imgui-sdl imgui-opengl3)
find_package(SDL2 REQUIRED CONFIG)

add_executable(${PROJECT_NAME} main.cpp)

target_include_directories(${PROJECT_NAME} PRIVATE
${OPENGL_INCLUDE_DIR}
${SDL2_INCLUDE_DIRS}
imgui)

target_link_libraries(${PROJECT_NAME}
${CMAKE_DL_LIBS}
${SDL2_LIBRARIES}
imgui-core
imgui-sdl
imgui-opengl3
OpenGL::GL
OpenGL::GLX
imguizmo)

install(TARGETS ${PROJECT_NAME} DESTINATION bin)
Loading