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.

196 lines
4.7KB

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