DISTRHO Plugin Framework
Base.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2015 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 # define GL_GLEXT_PROTOTYPES
80 # include "GL/gl.h"
81 # include "GL/glext.h"
82 #endif
83 
84 // -----------------------------------------------------------------------
85 // Missing OpenGL defines
86 
87 #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
88 # define GL_BGR GL_BGR_EXT
89 #endif
90 
91 #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
92 # define GL_BGRA GL_BGRA_EXT
93 #endif
94 
95 #ifndef GL_CLAMP_TO_BORDER
96 # define GL_CLAMP_TO_BORDER 0x812D
97 #endif
98 
99 #ifdef DISTRHO_OS_WINDOWS
100 // -----------------------------------------------------------------------
101 // Fix OpenGL includes for Windows, based on glfw code
102 
103 #ifdef DGL_WINGDIAPI_DEFINED
104 # undef WINGDIAPI
105 # undef DGL_WINGDIAPI_DEFINED
106 #endif
107 
108 #ifdef DGL_CALLBACK_DEFINED
109 # undef CALLBACK
110 # undef DGL_CALLBACK_DEFINED
111 #endif
112 
113 #endif // DISTRHO_OS_WINDOWS
114 
115 START_NAMESPACE_DGL
116 
117 // -----------------------------------------------------------------------
118 // Base DGL enums
119 
120 /**
121  Convenience symbols for ASCII control characters.
122  */
123 enum Char {
124  kCharBackspace = 0x08,
125  kCharEscape = 0x1B,
126  kCharDelete = 0x7F
127 };
128 
129 /**
130  Keyboard modifier flags.
131  */
132 enum Modifier {
133  kModifierShift = 1 << 0, /**< Shift key */
134  kModifierControl = 1 << 1, /**< Control key */
135  kModifierAlt = 1 << 2, /**< Alt/Option key */
136  kModifierSuper = 1 << 3 /**< Mod4/Command/Windows key */
137 };
138 
139 /**
140  Special (non-Unicode) keyboard keys.
141  */
142 enum Key {
143  kKeyF1 = 1,
144  kKeyF2,
145  kKeyF3,
146  kKeyF4,
147  kKeyF5,
148  kKeyF6,
149  kKeyF7,
150  kKeyF8,
151  kKeyF9,
152  kKeyF10,
153  kKeyF11,
154  kKeyF12,
155  kKeyLeft,
156  kKeyUp,
157  kKeyRight,
158  kKeyDown,
159  kKeyPageUp,
160  kKeyPageDown,
161  kKeyHome,
162  kKeyEnd,
163  kKeyInsert,
164  kKeyShift,
165  kKeyControl,
166  kKeyAlt,
167  kKeySuper
168 };
169 
170 // -----------------------------------------------------------------------
171 // Base DGL classes
172 
173 /**
174  Idle callback.
175  */
177 {
178 public:
179  virtual ~IdleCallback() {}
180  virtual void idleCallback() = 0;
181 };
182 
183 // -----------------------------------------------------------------------
184 
185 END_NAMESPACE_DGL
186 
187 #ifndef DONT_SET_USING_DGL_NAMESPACE
188  // If your code uses a lot of DGL classes, then this will obviously save you
189  // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
190  using namespace DGL_NAMESPACE;
191 #endif
192 
193 // -----------------------------------------------------------------------
194 
195 #endif // DGL_BASE_HPP_INCLUDED
Definition: Base.hpp:176