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.

123 lines
3.0KB

  1. /*
  2. * DISTRHO Cardinal Plugin
  3. * Copyright (C) 2021 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 General Public License as
  7. * published by the Free Software Foundation; either version 3 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the LICENSE file.
  16. */
  17. // this file matches the top of `OpenGL.hpp` provided by DPF
  18. #pragma once
  19. /* Check OS */
  20. #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__)
  21. # define DISTRHO_OS_WINDOWS 1
  22. #else
  23. # if defined(__APPLE__)
  24. # define DISTRHO_OS_MAC 1
  25. # endif
  26. #endif
  27. // -----------------------------------------------------------------------
  28. // Fix OpenGL includes for Windows, based on glfw code (part 1)
  29. #undef DGL_CALLBACK_DEFINED
  30. #undef DGL_WINGDIAPI_DEFINED
  31. #ifdef DISTRHO_OS_WINDOWS
  32. #ifndef APIENTRY
  33. # define APIENTRY __stdcall
  34. #endif // APIENTRY
  35. /* We need WINGDIAPI defined */
  36. #ifndef WINGDIAPI
  37. # if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__POCC__)
  38. # define WINGDIAPI __declspec(dllimport)
  39. # elif defined(__LCC__)
  40. # define WINGDIAPI __stdcall
  41. # else
  42. # define WINGDIAPI extern
  43. # endif
  44. # define DGL_WINGDIAPI_DEFINED
  45. #endif // WINGDIAPI
  46. /* Some <GL/glu.h> files also need CALLBACK defined */
  47. #ifndef CALLBACK
  48. # if defined(_MSC_VER)
  49. # if (defined(_M_MRX000) || defined(_M_IX86) || defined(_M_ALPHA) || defined(_M_PPC)) && !defined(MIDL_PASS)
  50. # define CALLBACK __stdcall
  51. # else
  52. # define CALLBACK
  53. # endif
  54. # else
  55. # define CALLBACK __stdcall
  56. # endif
  57. # define DGL_CALLBACK_DEFINED
  58. #endif // CALLBACK
  59. /* Most GL/glu.h variants on Windows need wchar_t */
  60. #include <cstddef>
  61. #endif // DISTRHO_OS_WINDOWS
  62. // -----------------------------------------------------------------------
  63. // OpenGL includes
  64. #ifndef HEADLESS
  65. # ifdef DISTRHO_OS_MAC
  66. # ifdef DGL_USE_OPENGL3
  67. # include <OpenGL/gl3.h>
  68. # include <OpenGL/gl3ext.h>
  69. # else
  70. # include <OpenGL/gl.h>
  71. # endif
  72. # else
  73. # ifdef DISTRHO_OS_WINDOWS
  74. # define GL_GLEXT_PROTOTYPES
  75. # endif
  76. # ifndef __GLEW_H__
  77. # include <GL/gl.h>
  78. # include <GL/glext.h>
  79. # endif
  80. # endif
  81. #endif
  82. // -----------------------------------------------------------------------
  83. // Missing OpenGL defines
  84. #if defined(GL_BGR_EXT) && !defined(GL_BGR)
  85. # define GL_BGR GL_BGR_EXT
  86. #endif
  87. #if defined(GL_BGRA_EXT) && !defined(GL_BGRA)
  88. # define GL_BGRA GL_BGRA_EXT
  89. #endif
  90. #ifndef GL_CLAMP_TO_BORDER
  91. # define GL_CLAMP_TO_BORDER 0x812D
  92. #endif
  93. // -----------------------------------------------------------------------
  94. // Fix OpenGL includes for Windows, based on glfw code (part 2)
  95. #ifdef DGL_CALLBACK_DEFINED
  96. # undef CALLBACK
  97. # undef DGL_CALLBACK_DEFINED
  98. #endif
  99. #ifdef DGL_WINGDIAPI_DEFINED
  100. # undef WINGDIAPI
  101. # undef DGL_WINGDIAPI_DEFINED
  102. #endif