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.7KB

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