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.

143 lines
3.0KB

  1. /*
  2. * DISTRHO Plugin Toolkit (DPT)
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Lesser General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU Lesser General Public License for more details.
  13. *
  14. * For a full copy of the license see the LGPL.txt file
  15. */
  16. #ifndef __DGL_BASE_HPP__
  17. #define __DGL_BASE_HPP__
  18. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  19. # define DGL_OS_WINDOWS 1
  20. #elif defined(__APPLE__)
  21. # define DGL_OS_MAC 1
  22. #elif defined(__HAIKU__)
  23. # define DGL_OS_HAIKU 1
  24. #elif defined(__linux__)
  25. # define DGL_OS_LINUX 1
  26. #endif
  27. #if defined(HAVE_CPP11_SUPPORT)
  28. # define PROPER_CPP11_SUPPORT
  29. #elif defined(__GNUC__) && defined(__GXX_EXPERIMENTAL_CXX0X__)
  30. # if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405
  31. # define PROPER_CPP11_SUPPORT
  32. # if (__GNUC__ * 100 + __GNUC_MINOR__) < 407
  33. # define override // gcc4.7+ only
  34. # endif
  35. # endif
  36. #endif
  37. #ifndef PROPER_CPP11_SUPPORT
  38. # define override
  39. # define noexcept
  40. # define nullptr (0)
  41. #endif
  42. #define DGL_NAMESPACE DGL
  43. #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
  44. #define END_NAMESPACE_DGL }
  45. #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
  46. #if DGL_OS_WINDOWS
  47. # include <windows.h>
  48. #else
  49. # include <unistd.h>
  50. #endif
  51. #if DGL_OS_MAC
  52. # include <OpenGL/glu.h>
  53. #else
  54. # include <GL/glu.h>
  55. #endif
  56. #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
  57. # define GL_BGR GL_BGR_EXT
  58. #endif
  59. #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
  60. # define GL_BGRA GL_BGRA_EXT
  61. #endif
  62. // -------------------------------------------------
  63. START_NAMESPACE_DGL
  64. enum Char {
  65. DGL_CHAR_BACKSPACE = 0x08,
  66. DGL_CHAR_ESCAPE = 0x1B,
  67. DGL_CHAR_DELETE = 0x7F
  68. };
  69. enum Key {
  70. DGL_KEY_F1 = 1,
  71. DGL_KEY_F2,
  72. DGL_KEY_F3,
  73. DGL_KEY_F4,
  74. DGL_KEY_F5,
  75. DGL_KEY_F6,
  76. DGL_KEY_F7,
  77. DGL_KEY_F8,
  78. DGL_KEY_F9,
  79. DGL_KEY_F10,
  80. DGL_KEY_F11,
  81. DGL_KEY_F12,
  82. DGL_KEY_LEFT,
  83. DGL_KEY_UP,
  84. DGL_KEY_RIGHT,
  85. DGL_KEY_DOWN,
  86. DGL_KEY_PAGE_UP,
  87. DGL_KEY_PAGE_DOWN,
  88. DGL_KEY_HOME,
  89. DGL_KEY_END,
  90. DGL_KEY_INSERT,
  91. DGL_KEY_SHIFT,
  92. DGL_KEY_CTRL,
  93. DGL_KEY_ALT,
  94. DGL_KEY_SUPER
  95. };
  96. enum Modifier {
  97. DGL_MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  98. DGL_MODIFIER_CTRL = 1 << 1, /**< Control key */
  99. DGL_MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  100. DGL_MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  101. };
  102. END_NAMESPACE_DGL
  103. // -------------------------------------------------
  104. static inline
  105. void dgl_sleep(unsigned int secs)
  106. {
  107. #ifdef DGL_OS_WINDOWS
  108. Sleep(secs * 1000);
  109. #else
  110. sleep(secs);
  111. #endif
  112. }
  113. static inline
  114. void dgl_msleep(unsigned int msecs)
  115. {
  116. #ifdef DGL_OS_WINDOWS
  117. Sleep(msecs);
  118. #else
  119. usleep(msecs * 1000);
  120. #endif
  121. }
  122. #endif // __DGL_BASE_HPP__