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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * DISTRHO Plugin Framework (DPF)
  3. * Copyright (C) 2012-2014 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/d_leakdetector.hpp"
  19. #include "../distrho/extra/d_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. CHAR_BACKSPACE = 0x08,
  101. CHAR_ESCAPE = 0x1B,
  102. CHAR_DELETE = 0x7F
  103. };
  104. /**
  105. Keyboard modifier flags.
  106. */
  107. enum Modifier {
  108. MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  109. MODIFIER_CTRL = 1 << 1, /**< Control key */
  110. MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  111. MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  112. };
  113. /**
  114. Special (non-Unicode) keyboard keys.
  115. */
  116. enum Key {
  117. KEY_F1 = 1,
  118. KEY_F2,
  119. KEY_F3,
  120. KEY_F4,
  121. KEY_F5,
  122. KEY_F6,
  123. KEY_F7,
  124. KEY_F8,
  125. KEY_F9,
  126. KEY_F10,
  127. KEY_F11,
  128. KEY_F12,
  129. KEY_LEFT,
  130. KEY_UP,
  131. KEY_RIGHT,
  132. KEY_DOWN,
  133. KEY_PAGE_UP,
  134. KEY_PAGE_DOWN,
  135. KEY_HOME,
  136. KEY_END,
  137. KEY_INSERT,
  138. KEY_SHIFT,
  139. KEY_CTRL,
  140. KEY_ALT,
  141. KEY_SUPER
  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. #endif // DGL_BASE_HPP_INCLUDED