The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
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.

158 lines
9.3KB

  1. /*
  2. ==============================================================================
  3. This file is part of the JUCE library.
  4. Copyright (c) 2015 - ROLI Ltd.
  5. Permission is granted to use this software under the terms of either:
  6. a) the GPL v2 (or any later version)
  7. b) the Affero GPL v3
  8. Details of these licenses can be found at: www.gnu.org/licenses
  9. JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
  10. WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
  11. A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  12. ------------------------------------------------------------------------------
  13. To release a closed-source product which uses JUCE, commercial licenses are
  14. available: visit www.juce.com for more information.
  15. ==============================================================================
  16. */
  17. #ifndef JUCE_OPENGLEXTENSIONS_H_INCLUDED
  18. #define JUCE_OPENGLEXTENSIONS_H_INCLUDED
  19. /** @internal This macro contains a list of GL extension functions that need to be dynamically loaded on Windows/Linux.
  20. @see OpenGLExtensionFunctions
  21. */
  22. #define JUCE_GL_BASE_FUNCTIONS(USE_FUNCTION) \
  23. USE_FUNCTION (glActiveTexture, void, (GLenum p1), (p1))\
  24. USE_FUNCTION (glBindBuffer, void, (GLenum p1, GLuint p2), (p1, p2))\
  25. USE_FUNCTION (glDeleteBuffers, void, (GLsizei p1, const GLuint* p2), (p1, p2))\
  26. USE_FUNCTION (glGenBuffers, void, (GLsizei p1, GLuint* p2), (p1, p2))\
  27. USE_FUNCTION (glBufferData, void, (GLenum p1, GLsizeiptr p2, const GLvoid* p3, GLenum p4), (p1, p2, p3, p4))\
  28. USE_FUNCTION (glBufferSubData, void, (GLenum p1, GLintptr p2, GLsizeiptr p3, const GLvoid* p4), (p1, p2, p3, p4))\
  29. USE_FUNCTION (glCreateProgram, GLuint, (), ())\
  30. USE_FUNCTION (glDeleteProgram, void, (GLuint p1), (p1))\
  31. USE_FUNCTION (glCreateShader, GLuint, (GLenum p1), (p1))\
  32. USE_FUNCTION (glDeleteShader, void, (GLuint p1), (p1))\
  33. USE_FUNCTION (glShaderSource, void, (GLuint p1, GLsizei p2, const GLchar** p3, const GLint* p4), (p1, p2, p3, p4))\
  34. USE_FUNCTION (glCompileShader, void, (GLuint p1), (p1))\
  35. USE_FUNCTION (glAttachShader, void, (GLuint p1, GLuint p2), (p1, p2))\
  36. USE_FUNCTION (glLinkProgram, void, (GLuint p1), (p1))\
  37. USE_FUNCTION (glUseProgram, void, (GLuint p1), (p1))\
  38. USE_FUNCTION (glGetShaderiv, void, (GLuint p1, GLenum p2, GLint* p3), (p1, p2, p3))\
  39. USE_FUNCTION (glGetShaderInfoLog, void, (GLuint p1, GLsizei p2, GLsizei* p3, GLchar* p4), (p1, p2, p3, p4))\
  40. USE_FUNCTION (glGetProgramInfoLog, void, (GLuint p1, GLsizei p2, GLsizei* p3, GLchar* p4), (p1, p2, p3, p4))\
  41. USE_FUNCTION (glGetProgramiv, void, (GLuint p1, GLenum p2, GLint* p3), (p1, p2, p3))\
  42. USE_FUNCTION (glGetUniformLocation, GLint, (GLuint p1, const GLchar* p2), (p1, p2))\
  43. USE_FUNCTION (glGetAttribLocation, GLint, (GLuint p1, const GLchar* p2), (p1, p2))\
  44. USE_FUNCTION (glVertexAttribPointer, void, (GLuint p1, GLint p2, GLenum p3, GLboolean p4, GLsizei p5, const GLvoid* p6), (p1, p2, p3, p4, p5, p6))\
  45. USE_FUNCTION (glEnableVertexAttribArray, void, (GLuint p1), (p1))\
  46. USE_FUNCTION (glDisableVertexAttribArray, void, (GLuint p1), (p1))\
  47. USE_FUNCTION (glUniform1f, void, (GLint p1, GLfloat p2), (p1, p2))\
  48. USE_FUNCTION (glUniform1i, void, (GLint p1, GLint p2), (p1, p2))\
  49. USE_FUNCTION (glUniform2f, void, (GLint p1, GLfloat p2, GLfloat p3), (p1, p2, p3))\
  50. USE_FUNCTION (glUniform3f, void, (GLint p1, GLfloat p2, GLfloat p3, GLfloat p4), (p1, p2, p3, p4))\
  51. USE_FUNCTION (glUniform4f, void, (GLint p1, GLfloat p2, GLfloat p3, GLfloat p4, GLfloat p5), (p1, p2, p3, p4, p5))\
  52. USE_FUNCTION (glUniform4i, void, (GLint p1, GLint p2, GLint p3, GLint p4, GLint p5), (p1, p2, p3, p4, p5))\
  53. USE_FUNCTION (glUniform1fv, void, (GLint p1, GLsizei p2, const GLfloat* p3), (p1, p2, p3))\
  54. USE_FUNCTION (glUniformMatrix2fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))\
  55. USE_FUNCTION (glUniformMatrix3fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))\
  56. USE_FUNCTION (glUniformMatrix4fv, void, (GLint p1, GLsizei p2, GLboolean p3, const GLfloat* p4), (p1, p2, p3, p4))
  57. /** @internal This macro contains a list of GL extension functions that need to be dynamically loaded on Windows/Linux.
  58. @see OpenGLExtensionFunctions
  59. */
  60. #define JUCE_GL_EXTENSION_FUNCTIONS(USE_FUNCTION) \
  61. USE_FUNCTION (glIsRenderbuffer, GLboolean, (GLuint p1), (p1))\
  62. USE_FUNCTION (glBindRenderbuffer, void, (GLenum p1, GLuint p2), (p1, p2))\
  63. USE_FUNCTION (glDeleteRenderbuffers, void, (GLsizei p1, const GLuint* p2), (p1, p2))\
  64. USE_FUNCTION (glGenRenderbuffers, void, (GLsizei p1, GLuint* p2), (p1, p2))\
  65. USE_FUNCTION (glRenderbufferStorage, void, (GLenum p1, GLenum p2, GLsizei p3, GLsizei p4), (p1, p2, p3, p4))\
  66. USE_FUNCTION (glGetRenderbufferParameteriv, void, (GLenum p1, GLenum p2, GLint* p3), (p1, p2, p3))\
  67. USE_FUNCTION (glIsFramebuffer, GLboolean, (GLuint p1), (p1))\
  68. USE_FUNCTION (glBindFramebuffer, void, (GLenum p1, GLuint p2), (p1, p2))\
  69. USE_FUNCTION (glDeleteFramebuffers, void, (GLsizei p1, const GLuint* p2), (p1, p2))\
  70. USE_FUNCTION (glGenFramebuffers, void, (GLsizei p1, GLuint* p2), (p1, p2))\
  71. USE_FUNCTION (glCheckFramebufferStatus, GLenum, (GLenum p1), (p1))\
  72. USE_FUNCTION (glFramebufferTexture2D, void, (GLenum p1, GLenum p2, GLenum p3, GLuint p4, GLint p5), (p1, p2, p3, p4, p5))\
  73. USE_FUNCTION (glFramebufferRenderbuffer, void, (GLenum p1, GLenum p2, GLenum p3, GLuint p4), (p1, p2, p3, p4))\
  74. USE_FUNCTION (glGetFramebufferAttachmentParameteriv, void, (GLenum p1, GLenum p2, GLenum p3, GLint* p4), (p1, p2, p3, p4))
  75. /** @internal This macro contains a list of GL extension functions that need to be dynamically loaded on Windows/Linux.
  76. @see OpenGLExtensionFunctions
  77. */
  78. #define JUCE_GL_VERTEXBUFFER_FUNCTIONS(USE_FUNCTION) \
  79. USE_FUNCTION (glGenVertexArrays, void, (GLsizei p1, GLuint* p2), (p1, p2))\
  80. USE_FUNCTION (glDeleteVertexArrays, void, (GLsizei p1, const GLuint* p2), (p1, p2))\
  81. USE_FUNCTION (glBindVertexArray, void, (GLuint p1), (p1))
  82. /** This class contains a generated list of OpenGL extension functions, which are either dynamically loaded
  83. for a specific GL context, or simply call-through to the appropriate OS function where available.
  84. */
  85. struct OpenGLExtensionFunctions
  86. {
  87. void initialise();
  88. #if JUCE_WINDOWS && ! DOXYGEN
  89. typedef char GLchar;
  90. typedef pointer_sized_int GLsizeiptr;
  91. typedef pointer_sized_int GLintptr;
  92. #endif
  93. //==============================================================================
  94. #if JUCE_WINDOWS
  95. #define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) typedef returnType (__stdcall *type_ ## name) params; type_ ## name name;
  96. JUCE_GL_BASE_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  97. JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  98. #if JUCE_OPENGL3
  99. JUCE_GL_VERTEXBUFFER_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  100. #endif
  101. //==============================================================================
  102. #elif JUCE_LINUX
  103. #define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) typedef returnType (*type_ ## name) params; type_ ## name name;
  104. JUCE_GL_BASE_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  105. JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  106. #if JUCE_OPENGL3
  107. JUCE_GL_VERTEXBUFFER_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  108. #endif
  109. //==============================================================================
  110. #elif JUCE_OPENGL_ES
  111. #define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) static returnType name params noexcept;
  112. JUCE_GL_BASE_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  113. JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  114. JUCE_GL_VERTEXBUFFER_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  115. //==============================================================================
  116. #else
  117. #define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) inline static returnType name params noexcept { return ::name callparams; }
  118. JUCE_GL_BASE_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  119. #ifndef GL3_PROTOTYPES
  120. #undef JUCE_DECLARE_GL_FUNCTION
  121. #define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) inline static returnType name params noexcept { return ::name ## EXT callparams; }
  122. #endif
  123. JUCE_GL_EXTENSION_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  124. #if JUCE_OPENGL3
  125. #ifndef GL3_PROTOTYPES
  126. #undef JUCE_DECLARE_GL_FUNCTION
  127. #define JUCE_DECLARE_GL_FUNCTION(name, returnType, params, callparams) inline static returnType name params noexcept { return ::name ## APPLE callparams; }
  128. #endif
  129. JUCE_GL_VERTEXBUFFER_FUNCTIONS (JUCE_DECLARE_GL_FUNCTION)
  130. #endif
  131. #endif
  132. #undef JUCE_DECLARE_GL_FUNCTION
  133. };
  134. #endif // JUCE_OPENGLEXTENSIONS_H_INCLUDED