DISTRHO Plugin Framework
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.

188 lines
4.4KB

  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. Special (non-Unicode) keyboard keys.
  106. */
  107. enum Key {
  108. KEY_F1 = 1,
  109. KEY_F2,
  110. KEY_F3,
  111. KEY_F4,
  112. KEY_F5,
  113. KEY_F6,
  114. KEY_F7,
  115. KEY_F8,
  116. KEY_F9,
  117. KEY_F10,
  118. KEY_F11,
  119. KEY_F12,
  120. KEY_LEFT,
  121. KEY_UP,
  122. KEY_RIGHT,
  123. KEY_DOWN,
  124. KEY_PAGE_UP,
  125. KEY_PAGE_DOWN,
  126. KEY_HOME,
  127. KEY_END,
  128. KEY_INSERT,
  129. KEY_SHIFT,
  130. KEY_CTRL,
  131. KEY_ALT,
  132. KEY_SUPER
  133. };
  134. /**
  135. Keyboard modifier flags.
  136. */
  137. enum Modifier {
  138. MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  139. MODIFIER_CTRL = 1 << 1, /**< Control key */
  140. MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  141. MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  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