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

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #ifndef GL_CLAMP_TO_BORDER
  63. # define GL_CLAMP_TO_BORDER 0x812D
  64. #endif
  65. // -------------------------------------------------
  66. START_NAMESPACE_DGL
  67. enum Char {
  68. DGL_CHAR_BACKSPACE = 0x08,
  69. DGL_CHAR_ESCAPE = 0x1B,
  70. DGL_CHAR_DELETE = 0x7F
  71. };
  72. enum Key {
  73. DGL_KEY_F1 = 1,
  74. DGL_KEY_F2,
  75. DGL_KEY_F3,
  76. DGL_KEY_F4,
  77. DGL_KEY_F5,
  78. DGL_KEY_F6,
  79. DGL_KEY_F7,
  80. DGL_KEY_F8,
  81. DGL_KEY_F9,
  82. DGL_KEY_F10,
  83. DGL_KEY_F11,
  84. DGL_KEY_F12,
  85. DGL_KEY_LEFT,
  86. DGL_KEY_UP,
  87. DGL_KEY_RIGHT,
  88. DGL_KEY_DOWN,
  89. DGL_KEY_PAGE_UP,
  90. DGL_KEY_PAGE_DOWN,
  91. DGL_KEY_HOME,
  92. DGL_KEY_END,
  93. DGL_KEY_INSERT,
  94. DGL_KEY_SHIFT,
  95. DGL_KEY_CTRL,
  96. DGL_KEY_ALT,
  97. DGL_KEY_SUPER
  98. };
  99. enum Modifier {
  100. DGL_MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  101. DGL_MODIFIER_CTRL = 1 << 1, /**< Control key */
  102. DGL_MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  103. DGL_MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  104. };
  105. END_NAMESPACE_DGL
  106. // -------------------------------------------------
  107. static inline
  108. void dgl_sleep(unsigned int secs)
  109. {
  110. #ifdef DGL_OS_WINDOWS
  111. Sleep(secs * 1000);
  112. #else
  113. sleep(secs);
  114. #endif
  115. }
  116. static inline
  117. void dgl_msleep(unsigned int msecs)
  118. {
  119. #ifdef DGL_OS_WINDOWS
  120. Sleep(msecs);
  121. #else
  122. usleep(msecs * 1000);
  123. #endif
  124. }
  125. #endif // __DGL_BASE_HPP__