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.

126 lines
2.6KB

  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. #define DGL_NAMESPACE DGL
  28. #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
  29. #define END_NAMESPACE_DGL }
  30. #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
  31. #if DGL_OS_WINDOWS
  32. # include <windows.h>
  33. #else
  34. # include <unistd.h>
  35. #endif
  36. #if DGL_OS_MAC
  37. # include <OpenGL/glu.h>
  38. #else
  39. # include <GL/glu.h>
  40. #endif
  41. #if defined(GL_BGR_EXT) && ! defined(GL_BGR)
  42. # define GL_BGR GL_BGR_EXT
  43. #endif
  44. #if defined(GL_BGRA_EXT) && ! defined(GL_BGRA)
  45. # define GL_BGRA GL_BGRA_EXT
  46. #endif
  47. // -------------------------------------------------
  48. START_NAMESPACE_DGL
  49. enum Char {
  50. DGL_CHAR_BACKSPACE = 0x08,
  51. DGL_CHAR_ESCAPE = 0x1B,
  52. DGL_CHAR_DELETE = 0x7F
  53. };
  54. enum Key {
  55. DGL_KEY_F1 = 1,
  56. DGL_KEY_F2,
  57. DGL_KEY_F3,
  58. DGL_KEY_F4,
  59. DGL_KEY_F5,
  60. DGL_KEY_F6,
  61. DGL_KEY_F7,
  62. DGL_KEY_F8,
  63. DGL_KEY_F9,
  64. DGL_KEY_F10,
  65. DGL_KEY_F11,
  66. DGL_KEY_F12,
  67. DGL_KEY_LEFT,
  68. DGL_KEY_UP,
  69. DGL_KEY_RIGHT,
  70. DGL_KEY_DOWN,
  71. DGL_KEY_PAGE_UP,
  72. DGL_KEY_PAGE_DOWN,
  73. DGL_KEY_HOME,
  74. DGL_KEY_END,
  75. DGL_KEY_INSERT,
  76. DGL_KEY_SHIFT,
  77. DGL_KEY_CTRL,
  78. DGL_KEY_ALT,
  79. DGL_KEY_SUPER
  80. };
  81. enum Modifier {
  82. DGL_MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  83. DGL_MODIFIER_CTRL = 1 << 1, /**< Control key */
  84. DGL_MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  85. DGL_MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  86. };
  87. END_NAMESPACE_DGL
  88. // -------------------------------------------------
  89. static inline
  90. void dgl_sleep(unsigned int secs)
  91. {
  92. #ifdef DGL_OS_WINDOWS
  93. Sleep(secs * 1000);
  94. #else
  95. sleep(secs);
  96. #endif
  97. }
  98. static inline
  99. void dgl_msleep(unsigned int msecs)
  100. {
  101. #ifdef DGL_OS_WINDOWS
  102. Sleep(msecs);
  103. #else
  104. usleep(msecs * 1000);
  105. #endif
  106. }
  107. #endif // __DGL_BASE_HPP__