Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Base.hpp 4.8KB

9 years ago
9 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #ifndef DGL_BASE_HPP_INCLUDED
  17. #define DGL_BASE_HPP_INCLUDED
  18. #include "../distrho/extra/LeakDetector.hpp"
  19. #include "../distrho/extra/ScopedPointer.hpp"
  20. // -----------------------------------------------------------------------
  21. // Define namespace
  22. #ifndef DGL_NAMESPACE
  23. # define DGL_NAMESPACE DGL
  24. #endif
  25. #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
  26. #define END_NAMESPACE_DGL }
  27. #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
  28. #ifdef DISTRHO_OS_WINDOWS
  29. // -----------------------------------------------------------------------
  30. // Fix OpenGL includes for Windows, based on glfw code
  31. #ifndef APIENTRY
  32. # define APIENTRY __stdcall
  33. # define DGL_APIENTRY_DEFINED
  34. #endif // APIENTRY
  35. /* We need WINGDIAPI defined */
  36. #ifndef WINGDIAPI
  37. # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
  38. # define WINGDIAPI __declspec(dllimport)
  39. # elif defined(__LCC__)
  40. # define WINGDIAPI __stdcall
  41. # else
  42. # define WINGDIAPI extern
  43. # endif
  44. # define DGL_WINGDIAPI_DEFINED
  45. #endif // WINGDIAPI
  46. /* Some <GL/glu.h> files also need CALLBACK defined */
  47. #ifndef CALLBACK
  48. # if defined(_MSC_VER)
  49. # if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
  50. # define CALLBACK __stdcall
  51. # else
  52. # define CALLBACK
  53. # endif
  54. # else
  55. # define CALLBACK __stdcall
  56. # endif
  57. # define DGL_CALLBACK_DEFINED
  58. #endif // CALLBACK
  59. /* Most GL/glu.h variants on Windows need wchar_t */
  60. #include <cstddef>
  61. #endif // DISTRHO_OS_WINDOWS
  62. // -----------------------------------------------------------------------
  63. // OpenGL includes
  64. #ifdef DISTRHO_OS_MAC
  65. # include <OpenGL/gl.h>
  66. #else
  67. # ifndef DISTRHO_OS_WINDOWS
  68. # define GL_GLEXT_PROTOTYPES
  69. # endif
  70. # include <GL/gl.h>
  71. # include <GL/glext.h>
  72. #endif
  73. // -----------------------------------------------------------------------
  74. // Missing OpenGL defines
  75. #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
  76. # define GL_BGR GL_BGR_EXT
  77. #endif
  78. #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
  79. # define GL_BGRA GL_BGRA_EXT
  80. #endif
  81. #ifndef GL_CLAMP_TO_BORDER
  82. # define GL_CLAMP_TO_BORDER 0x812D
  83. #endif
  84. #ifdef DISTRHO_OS_WINDOWS
  85. // -----------------------------------------------------------------------
  86. // Fix OpenGL includes for Windows, based on glfw code
  87. #ifdef DGL_APIENTRY_DEFINED
  88. # undef APIENTRY
  89. # undef DGL_APIENTRY_DEFINED
  90. #endif
  91. #ifdef DGL_WINGDIAPI_DEFINED
  92. # undef WINGDIAPI
  93. # undef DGL_WINGDIAPI_DEFINED
  94. #endif
  95. #ifdef DGL_CALLBACK_DEFINED
  96. # undef CALLBACK
  97. # undef DGL_CALLBACK_DEFINED
  98. #endif
  99. #endif // DISTRHO_OS_WINDOWS
  100. START_NAMESPACE_DGL
  101. // -----------------------------------------------------------------------
  102. // Base DGL enums
  103. /**
  104. Convenience symbols for ASCII control characters.
  105. */
  106. enum Char {
  107. kCharBackspace = 0x08,
  108. kCharEscape = 0x1B,
  109. kCharDelete = 0x7F
  110. };
  111. /**
  112. Keyboard modifier flags.
  113. */
  114. enum Modifier {
  115. kModifierShift = 1 << 0, /**< Shift key */
  116. kModifierControl = 1 << 1, /**< Control key */
  117. kModifierAlt = 1 << 2, /**< Alt/Option key */
  118. kModifierSuper = 1 << 3 /**< Mod4/Command/Windows key */
  119. };
  120. /**
  121. Special (non-Unicode) keyboard keys.
  122. */
  123. enum Key {
  124. kKeyF1 = 1,
  125. kKeyF2,
  126. kKeyF3,
  127. kKeyF4,
  128. kKeyF5,
  129. kKeyF6,
  130. kKeyF7,
  131. kKeyF8,
  132. kKeyF9,
  133. kKeyF10,
  134. kKeyF11,
  135. kKeyF12,
  136. kKeyLeft,
  137. kKeyUp,
  138. kKeyRight,
  139. kKeyDown,
  140. kKeyPageUp,
  141. kKeyPageDown,
  142. kKeyHome,
  143. kKeyEnd,
  144. kKeyInsert,
  145. kKeyShift,
  146. kKeyControl,
  147. kKeyAlt,
  148. kKeySuper
  149. };
  150. // -----------------------------------------------------------------------
  151. // Base DGL classes
  152. /**
  153. Idle callback.
  154. */
  155. class IdleCallback
  156. {
  157. public:
  158. virtual ~IdleCallback() {}
  159. virtual void idleCallback() = 0;
  160. };
  161. // -----------------------------------------------------------------------
  162. END_NAMESPACE_DGL
  163. #ifndef DONT_SET_USING_DGL_NAMESPACE
  164. // If your code uses a lot of DGL classes, then this will obviously save you
  165. // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
  166. using namespace DGL_NAMESPACE;
  167. #endif
  168. // -----------------------------------------------------------------------
  169. #endif // DGL_BASE_HPP_INCLUDED