There are effectively two ways that you can use NanoGUI in C++: have NanoGUI initialize and manage the OpenGL context (and GLFW), or you do it manually.
If you are letting NanoGUI take over, you must call
nanogui::init()before trying to do anything else. If you are managing OpenGL / GLFW yourself, make sure you avoid calling this method.
Create an instance of
nanogui::Screen(or a derivative class you have written).
NanoGUI managed OpenGL: call the explicit constructor.
- Self managed OpenGL: call the empty constructor.
You must call the
Add any Widgets, Buttons, etc. you want to the screen instance, and call the
nanogui::Screen::performLayout()methods of your instance.
Now that everything is ready, call
When all windows are closed, this function will exit, and you should follow it up with a call to
- NanoGUI Managed OpenGL / GLFW
Refer to Example 2 for a concise example of what that all looks like.
- Self Managed OpenGL / GLFW
Refer to Example 3 for an as concise as possible example of what you will need to do to get the
The Python interface is very similar to the C++ API. When you build NanoGUI with CMake,
python folder is created with the library you
import nanogui from. Though
there are implementation details that differ greatly, the documentation and build
process for the Python side is roughly the same. Refer to the
Examples and compare the source code for the two.
Example 3 highlights the more notable differences between the APIs. Specifically, that managing GLFW from Python has no meaning, as well as the main loop for Python can easily be detached.