Skip to content

Commit

Permalink
Removal of Enoki dependency
Browse files Browse the repository at this point in the history
Nanogui previously relied on the Enoki library for basic vector and
matrix types (and before that, Eigen was used). At this point, Enoki has
become large project in its own right, targeting fairly advanced use
cases such as automatic differentiation on NVIDIA GPUs. Since NanoGUI
merely used a few trivial types (Vector2i/f, and Matrix4f), I decided to
simply provide basic implementations of these types here to make the
project more self-contained.

The vector types here continue to be interoperable with Enoki and e.g.
support implicit conversions.
  • Loading branch information
wjakob committed Feb 12, 2020
1 parent 5e7b78f commit 6b82fb1
Show file tree
Hide file tree
Showing 47 changed files with 1,266 additions and 872 deletions.
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
[submodule "ext/glfw"]
path = ext/glfw
url = https://github.com/wjakob/glfw
[submodule "ext/enoki"]
path = ext/enoki
url = https://github.com/mitsuba-renderer/enoki
[submodule "ext/pybind11"]
path = ext/pybind11
url = https://github.com/pybind/pybind11
31 changes: 8 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ option(NANOGUI_BUILD_PYTHON "Build a Python plugin for NanoGUI?" ${
option(NANOGUI_BUILD_GLAD "Build GLAD OpenGL loader library? (needed on Windows)" ${NANOGUI_BUILD_GLAD_DEFAULT})
option(NANOGUI_BUILD_GLFW "Build GLFW?" ${NANOGUI_BUILD_GLFW_DEFAULT})
option(NANOGUI_INSTALL "Install NanoGUI on `make install`?" ON)
option(NANOGUI_PYTHON_USE_ENOKI_BINDINGS "Advanced: map vector types (e.g. Vector2f) to Enoki's python bindings instead of NumPy?" OFF)

if (NOT NANOGUI_BACKEND)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7" OR
Expand All @@ -77,22 +76,16 @@ endif()

set_property(CACHE NANOGUI_BACKEND PROPERTY STRINGS "OpenGL" "GLES 2" "GLES 3" "Metal")

set(NANOGUI_PYTHON_VERSION "" CACHE STRING "Python version to use for compiling the Python plugin")

# Allow overriding the pybind11 and Enoki version used to compile NanoGUI
set(ENOKI_PYBIND11_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/enoki/ext/pybind11"
CACHE STRING "Path containing the 'pybind11' library used to compile Enoki.")
set(NANOGUI_PYBIND11_DIR "${ENOKI_PYBIND11_DIR}"
# Allow overriding the pybind11 library used to compile NanoGUI
set(NANOGUI_PYBIND11_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/pybind11"
CACHE STRING "Path containing the 'pybind11' library used to compile nanogui.")
set(NANOGUI_ENOKI_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/enoki"
CACHE STRING "Path containing the 'enoki' library used to compile nanogui.")
mark_as_advanced(ENOKI_PYBIND11_DIR NANOGUI_PYBIND11_DIR NANOGUI_ENOKI_DIR)
mark_as_advanced(NANOGUI_PYBIND11_DIR)

if (NANOGUI_BUILD_PYTHON)
# Try to autodetect Python (can be overridden manually if needed)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/ext/enoki/ext/pybind11/tools")
set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6 3.5 3.4)
find_package(PythonLibsNew ${NANOGUI_PYTHON_VERSION})
list(APPEND CMAKE_MODULE_PATH "${NANOGUI_PYBIND11_DIR}/tools")
set(Python_ADDITIONAL_VERSIONS 3.9 3.8 3.7 3.6 3.5 3.4)
find_package(PythonLibsNew)
if (NOT PYTHONLIBS_FOUND)
# Python not found -- disable the plugin
set(NANOGUI_BUILD_PYTHON OFF CACHE BOOL "Build a Python plugin for NanoGUI?" FORCE)
Expand Down Expand Up @@ -144,11 +137,6 @@ macro(CHECK_CXX_COMPILER_AND_LINKER_FLAGS _RESULT _CXX_FLAGS _LINKER_FLAGS)
set(CMAKE_REQUIRED_LIBRARIES "")
endmacro()

add_subdirectory("${NANOGUI_ENOKI_DIR}" "ext_build/enoki")

enoki_set_compile_flags()
enoki_set_native_flags()

# Python support: add NANOGUI_PYTHON flag to all targets
if (NANOGUI_BUILD_PYTHON)
list(APPEND NANOGUI_EXTRA_DEFS -DNANOGUI_PYTHON)
Expand Down Expand Up @@ -507,12 +495,12 @@ add_library(nanogui-obj OBJECT
include/nanogui/texture.h src/texture.cpp
include/nanogui/shader.h src/shader.cpp
include/nanogui/imageview.h src/imageview.cpp
include/nanogui/traits.h src/traits.cpp
include/nanogui/renderpass.h
include/nanogui/formhelper.h
include/nanogui/icons.h
include/nanogui/toolbutton.h
include/nanogui/opengl.h
include/nanogui/arcball.h
include/nanogui/nanogui.h
)

Expand Down Expand Up @@ -608,10 +596,6 @@ if (NANOGUI_BUILD_PYTHON AND (APPLE OR CMAKE_SYSTEM MATCHES "Linux"))
add_definitions(-DCORO_SJLJ)
include_directories(ext/coro)
list(APPEND LIBNANOGUI_PYTHON_EXTRA_SOURCE ext/coro/coro.c)

if (NANOGUI_PYTHON_USE_ENOKI_BINDINGS)
add_definitions(-DNANOGUI_PYTHON_USE_ENOKI_BINDINGS=1)
endif()
endif()

if (NANOGUI_BUILD_PYTHON)
Expand Down Expand Up @@ -641,6 +625,7 @@ if (NANOGUI_BUILD_PYTHON)
python/canvas.cpp
python/nanovg.cpp
python/render.cpp
python/vector.cpp
python/python.h python/py_doc.h
${LIBNANOGUI_PYTHON_EXTRA_SOURCE})

Expand Down
26 changes: 12 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ NanoGUI

.. begin_brief_description
NanoGUI is a minimalistic cross-platform widget library for OpenGL 3+, GLES 2/3,
and Metal. It supports automatic layout generation, stateful C++ lambdas
NanoGUI is a minimalistic cross-platform widget library for OpenGL 3+, GLES
2/3, and Metal. It supports automatic layout generation, stateful C++ lambdas
callbacks, a variety of useful widget types and Retina-capable rendering on
Apple devices thanks to NanoVG_ by Mikko Mononen. Python bindings of all
functionality are provided using pybind11_.

**Note**: This repository contains an Enoki_-compatible port of the original
NanoGUI_.

This repository incorporates a number of additional changes that go beyond the
choice of vector library:
**Note**: This repository contains an improved port of the original NanoGUI_.
The most visible change to developers is that it no longer relies on Eigen or
Enoki and ships with its own (absolutely minimal) vector library. Additionally,
the the repository here incorporates the following changes:

1. A different set of naming conventions is used for function and variable
names that feels more natural in a mixed C++ & Python environment.
(specifically, ``underscore_case`` for methods and variables rather than
``camelCase``).

2. GUI Rendering now provides backends for OpenGL 3+, GLES 2/3, and Metal. GLES 2
support allows NanoGUI to run on ARM devices including the Raspberry Pi
and in browsers via WebGL. The Metal backend supports modern Macs, iPhones, etc.
2. GUI Rendering now provides backends for OpenGL 3+, GLES 2/3, and Metal. GLES
2 support allows NanoGUI to run on ARM devices including the Raspberry Pi
and in browsers via WebGL. The Metal backend supports modern Macs, iPhones,
etc.

NanoGUI includes generic wrappers around shaders and textures that work for
all of these frameworks.
Expand All @@ -58,7 +58,6 @@ choice of vector library:
.. _NanoVG: https://github.com/memononen/NanoVG
.. _pybind11: https://github.com/wjakob/pybind11
.. _NanoGUI: https://github.com/wjakob/nanogui
.. _Enoki: https://github.com/mitsuba-renderer/enoki
.. _Tekari: https://rgl.epfl.ch/tekari?url=%2F%2Frgl.s3.eu-central-1.amazonaws.com%2Fmedia%2Fuploads%2Fwjakob%2F2018%2F08%2F27%2Firidescent-paper.txt&log=1
.. _Entypo: http://www.entypo.com
.. _FontAwesome: https://github.com/FortAwesome/Font-Awesome
Expand All @@ -84,8 +83,8 @@ Description
.. begin_long_description
NanoGUI builds on GLFW_ for cross-platform context creation and event handling,
GLAD_ to access OpenGL functionality on Windows, Enoki_ for basic vector types,
and NanoVG_/MetalNanoVG_ to draw 2D primitives.
GLAD_ to access OpenGL functionality on Windows, and NanoVG_/MetalNanoVG_ to
draw 2D primitives.

Note that the dependency library NanoVG already includes some basic example code to draw
good-looking static widgets; what NanoGUI does is to flesh it out into a complete GUI
Expand All @@ -97,7 +96,6 @@ jointly built using a CMake-based build system.

.. _GLFW: http://www.glfw.org/
.. _GLAD: https://github.com/Dav1dde/glad
.. _Enoki: https://github.com/mitsuba-renderer/enoki
.. _MetalNanoVG: https://github.com/ollix/MetalNanoVG

.. end_long_description
Expand Down
1 change: 0 additions & 1 deletion ext/enoki
Submodule enoki deleted from a8cc11
1 change: 1 addition & 0 deletions ext/pybind11
Submodule pybind11 added at 4f72ef
Loading

0 comments on commit 6b82fb1

Please sign in to comment.