DISTRHO Plugin Framework
Base.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2016 Filipe Coelho <falktx@falktx.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
6  * or without fee is hereby granted, provided that the above copyright notice and this
7  * permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef DGL_BASE_HPP_INCLUDED
18 #define DGL_BASE_HPP_INCLUDED
19 
20 #include "../distrho/extra/LeakDetector.hpp"
21 #include "../distrho/extra/ScopedPointer.hpp"
22 
23 // -----------------------------------------------------------------------
24 // Define namespace
25 
26 #ifndef DGL_NAMESPACE
27 # define DGL_NAMESPACE DGL
28 #endif
29 
30 #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
31 #define END_NAMESPACE_DGL }
32 #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
33 
34 #ifdef DISTRHO_OS_WINDOWS
35 // -----------------------------------------------------------------------
36 // Fix OpenGL includes for Windows, based on glfw code
37 
38 #ifndef APIENTRY
39 # define APIENTRY __stdcall
40 #endif // APIENTRY
41 
42 /* We need WINGDIAPI defined */
43 #ifndef WINGDIAPI
44 # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
45 # define WINGDIAPI __declspec(dllimport)
46 # elif defined(__LCC__)
47 # define WINGDIAPI __stdcall
48 # else
49 # define WINGDIAPI extern
50 # endif
51 # define DGL_WINGDIAPI_DEFINED
52 #endif // WINGDIAPI
53 
54 /* Some <GL/glu.h> files also need CALLBACK defined */
55 #ifndef CALLBACK
56 # if defined(_MSC_VER)
57 # if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
58 # define CALLBACK __stdcall
59 # else
60 # define CALLBACK
61 # endif
62 # else
63 # define CALLBACK __stdcall
64 # endif
65 # define DGL_CALLBACK_DEFINED
66 #endif // CALLBACK
67 
68 /* Most GL/glu.h variants on Windows need wchar_t */
69 #include <cstddef>
70 
71 #endif // DISTRHO_OS_WINDOWS
72 
73 // -----------------------------------------------------------------------
74 // OpenGL includes
75 
76 #ifdef DISTRHO_OS_MAC
77 # include <OpenGL/gl.h>
78 #else
79 # ifndef DISTRHO_OS_WINDOWS
80 # define GL_GLEXT_PROTOTYPES
81 # endif
82 # include <GL/gl.h>
83 # include <GL/glext.h>
84 #endif
85 
86 // -----------------------------------------------------------------------
87 // Missing OpenGL defines
88 
89 #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
90 # define GL_BGR GL_BGR_EXT
91 #endif
92 
93 #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
94 # define GL_BGRA GL_BGRA_EXT
95 #endif
96 
97 #ifndef GL_CLAMP_TO_BORDER
98 # define GL_CLAMP_TO_BORDER 0x812D
99 #endif
100 
101 #ifdef DISTRHO_OS_WINDOWS
102 // -----------------------------------------------------------------------
103 // Fix OpenGL includes for Windows, based on glfw code
104 
105 #ifdef DGL_WINGDIAPI_DEFINED
106 # undef WINGDIAPI
107 # undef DGL_WINGDIAPI_DEFINED
108 #endif
109 
110 #ifdef DGL_CALLBACK_DEFINED
111 # undef CALLBACK
112 # undef DGL_CALLBACK_DEFINED
113 #endif
114 
115 #endif // DISTRHO_OS_WINDOWS
116 
117 START_NAMESPACE_DGL
118 
119 // -----------------------------------------------------------------------
120 // Base DGL enums
121 
122 /**
123  Convenience symbols for ASCII control characters.
124  */
125 enum Char {
126  kCharBackspace = 0x08,
127  kCharEscape = 0x1B,
128  kCharDelete = 0x7F
129 };
130 
131 /**
132  Keyboard modifier flags.
133  */
134 enum Modifier {
135  kModifierShift = 1 << 0, /**< Shift key */
136  kModifierControl = 1 << 1, /**< Control key */
137  kModifierAlt = 1 << 2, /**< Alt/Option key */
138  kModifierSuper = 1 << 3 /**< Mod4/Command/Windows key */
139 };
140 
141 /**
142  Special (non-Unicode) keyboard keys.
143  */
144 enum Key {
145  kKeyF1 = 1,
146  kKeyF2,
147  kKeyF3,
148  kKeyF4,
149  kKeyF5,
150  kKeyF6,
151  kKeyF7,
152  kKeyF8,
153  kKeyF9,
154  kKeyF10,
155  kKeyF11,
156  kKeyF12,
157  kKeyLeft,
158  kKeyUp,
159  kKeyRight,
160  kKeyDown,
161  kKeyPageUp,
162  kKeyPageDown,
163  kKeyHome,
164  kKeyEnd,
165  kKeyInsert,
166  kKeyShift,
167  kKeyControl,
168  kKeyAlt,
169  kKeySuper
170 };
171 
172 // -----------------------------------------------------------------------
173 // Base DGL classes
174 
175 /**
176  Idle callback.
177  */
179 {
180 public:
181  virtual ~IdleCallback() {}
182  virtual void idleCallback() = 0;
183 };
184 
185 // -----------------------------------------------------------------------
186 
187 END_NAMESPACE_DGL
188 
189 #ifndef DONT_SET_USING_DGL_NAMESPACE
190  // If your code uses a lot of DGL classes, then this will obviously save you
191  // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
192  using namespace DGL_NAMESPACE;
193 #endif
194 
195 // -----------------------------------------------------------------------
196 
197 #endif // DGL_BASE_HPP_INCLUDED
Definition: Base.hpp:178