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

11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. enum Char {
  49. DGL_CHAR_BACKSPACE = 0x08,
  50. DGL_CHAR_ESCAPE = 0x1B,
  51. DGL_CHAR_DELETE = 0x7F
  52. };
  53. enum Key {
  54. DGL_KEY_F1 = 1,
  55. DGL_KEY_F2,
  56. DGL_KEY_F3,
  57. DGL_KEY_F4,
  58. DGL_KEY_F5,
  59. DGL_KEY_F6,
  60. DGL_KEY_F7,
  61. DGL_KEY_F8,
  62. DGL_KEY_F9,
  63. DGL_KEY_F10,
  64. DGL_KEY_F11,
  65. DGL_KEY_F12,
  66. DGL_KEY_LEFT,
  67. DGL_KEY_UP,
  68. DGL_KEY_RIGHT,
  69. DGL_KEY_DOWN,
  70. DGL_KEY_PAGE_UP,
  71. DGL_KEY_PAGE_DOWN,
  72. DGL_KEY_HOME,
  73. DGL_KEY_END,
  74. DGL_KEY_INSERT,
  75. DGL_KEY_SHIFT,
  76. DGL_KEY_CTRL,
  77. DGL_KEY_ALT,
  78. DGL_KEY_SUPER
  79. };
  80. enum Modifier {
  81. DGL_MODIFIER_SHIFT = 1 << 0, /**< Shift key */
  82. DGL_MODIFIER_CTRL = 1 << 1, /**< Control key */
  83. DGL_MODIFIER_ALT = 1 << 2, /**< Alt/Option key */
  84. DGL_MODIFIER_SUPER = 1 << 3 /**< Mod4/Command/Windows key */
  85. };
  86. static inline
  87. void dgl_sleep(unsigned int secs)
  88. {
  89. #ifdef DGL_OS_WINDOWS
  90. Sleep(secs * 1000);
  91. #else
  92. sleep(secs);
  93. #endif
  94. }
  95. static inline
  96. void dgl_msleep(unsigned int msecs)
  97. {
  98. #ifdef DGL_OS_WINDOWS
  99. Sleep(msecs);
  100. #else
  101. usleep(msecs * 1000);
  102. #endif
  103. }
  104. #endif // __DGL_BASE_HPP__