1.. _nanogui_example_programs:
2
3Examples
4========================================================================================
5
6There are example programs available for you to play with / understand how the different
7pieces fit together.  The C++ examples are in ``nanogui/src/``, and the equivalent
8Python examples are in ``nanogui/python``.
9
10.. _nanogui_example_1:
11
12Example 1
13----------------------------------------------------------------------------------------
14
15.. image:: ../resources/screenshot.png
16   :alt: Screenshot of Example 1.
17   :align: center
18
19The first example program is rather long, but not altogether complicated.  It
20is effectively an enumeration of how one would go about adding various different kinds
21of Widgets to the window being displayed.
22
23- `Example 1 in C++ <https://github.com/wjakob/nanogui/blob/master/src/example1.cpp>`_
24- `Example 1 in Python <https://github.com/wjakob/nanogui/blob/master/python/example1.py>`_
25
26.. _nanogui_example_2:
27
28Example 2
29----------------------------------------------------------------------------------------
30
31.. image:: ../resources/screenshot2.png
32   :alt: Screenshot of Example 2.
33   :align: center
34
35The second program demonstrates how simple label/editor widget-type layouts can
36be written in a very concise manner.
37
38- `Example 2 in C++ <https://github.com/wjakob/nanogui/blob/master/src/example2.cpp>`_
39- `Example 2 in Python <https://github.com/wjakob/nanogui/blob/master/python/example2.py>`_
40
41.. _nanogui_example_3:
42
43Example 3
44----------------------------------------------------------------------------------------
45
46The third example program demonstrates how to manage OpenGL / GLFW on your own for the
47C++ side, and how to detach the NanoGUI ``mainloop()`` on the Python side.
48
49- `Example 3 in C++ <https://github.com/wjakob/nanogui/blob/master/src/example3.cpp>`_
50- `Example 3 in Python <https://github.com/wjakob/nanogui/blob/master/python/example3.py>`_
51
52.. _nanogui_example_4:
53
54Example 4
55----------------------------------------------------------------------------------------
56
57The fourth example program demonstrates the GLCanvas widget, which renders an
58arbitrary sequence of OpenGL commands into a NanoGUI widget.
59
60- `Example 4 in C++ <https://github.com/wjakob/nanogui/blob/master/src/example4.cpp>`_
61- `Example 4 in Python <https://github.com/wjakob/nanogui/blob/master/python/example4.py>`_
62
63.. _nanogui_example_icons:
64
65Example Icons
66----------------------------------------------------------------------------------------
67
68NanoGUI includes various icons made available from :ref:`file_nanogui_entypo.h`,
69courtesy of `Daniel Bruce's Entypo <http://www.entypo.com/>`_ glyphs.  The file level
70documentation is useful as a reference for selecting an icon, but the web rendering may
71be misleading --- NanoGUI uses a dark background for widgets by default.
72
73Run the ``exampleIcon`` executable to see what the icons look like in NanoGUI.  The
74setup of this file may also be helpful in understanding how to control the
75:class:`nanogui::VScrollPanel`.
76
77- `Example Icons in C++ <https://github.com/wjakob/nanogui/blob/master/src/example_icons.cpp>`_
78- `Example Icons in Python <https://github.com/wjakob/nanogui/blob/master/python/example_icons.py>`_
79
80
81.. _nanogui_example_repository:
82
83Example Repository
84----------------------------------------------------------------------------------------
85
86Darren Mothersele has put together a compact and informative example repository that
87demonstrates how easy it is to include NanoGUI into your project.  You download / browse
88the source on `GitHub <https://github.com/darrenmothersele/nanogui-test.git>`_.
89