1 /*
2     nanogui/opengl.h -- Pulls in OpenGL, GLAD (if needed), GLFW, and
3     NanoVG header files
4 
5     NanoGUI was developed by Wenzel Jakob <wenzel.jakob@epfl.ch>.
6     The widget drawing code is based on the NanoVG demo application
7     by Mikko Mononen.
8 
9     All rights reserved. Use of this source code is governed by a
10     BSD-style license that can be found in the LICENSE.txt file.
11 */
12 /** \file */
13 
14 #pragma once
15 
16 #include <nanogui/common.h>
17 
18 #ifndef DOXYGEN_SHOULD_SKIP_THIS
19 #if defined(NANOGUI_GLAD)
20     #if defined(NANOGUI_SHARED) && !defined(GLAD_GLAPI_EXPORT)
21         #define GLAD_GLAPI_EXPORT
22     #endif
23 
24     #include <glad/glad.h>
25 #else
26     #if defined(__APPLE__)
27         #define GLFW_INCLUDE_GLCOREARB
28     #else
29         #define GL_GLEXT_PROTOTYPES
30     #endif
31 #endif
32 #endif // DOXYGEN_SHOULD_SKIP_THIS
33 
34 #include <GLFW/glfw3.h>
35 #include <nanovg.h>
36 
NAMESPACE_BEGIN(nanogui)37 NAMESPACE_BEGIN(nanogui)
38 
39 /// Allows for conversion between nanogui::Color and the NanoVG NVGcolor class.
40 inline Color::operator const NVGcolor &() const {
41     return reinterpret_cast<const NVGcolor &>(*this->data());
42 }
43 
44 /// Determine whether an icon ID is a texture loaded via nvgImageIcon
nvgIsImageIcon(int value)45 inline bool nvgIsImageIcon(int value) { return value < 1024; }
46 
47 /// Determine whether an icon ID is a font-based icon (e.g. from the entypo.ttf font)
nvgIsFontIcon(int value)48 inline bool nvgIsFontIcon(int value) { return value >= 1024; }
49 
50 NAMESPACE_END(nanogui)
51