ctxgl_procaddr.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. /*************************************************************************/
  2. /* ctxgl_procaddr.cpp */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2019 Godot Engine contributors (cf. AUTHORS.md) */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /*************************************************************************/
  30. #ifdef OPENGL_ENABLED
  31. #include "ctxgl_procaddr.h"
  32. #include <GL/gl.h>
  33. #include <stdio.h>
  34. static PROC _gl_procs[] = {
  35. (PROC)glCullFace,
  36. (PROC)glFrontFace,
  37. (PROC)glHint,
  38. (PROC)glLineWidth,
  39. (PROC)glPointSize,
  40. (PROC)glPolygonMode,
  41. (PROC)glScissor,
  42. (PROC)glTexParameterf,
  43. (PROC)glTexParameterfv,
  44. (PROC)glTexParameteri,
  45. (PROC)glTexParameteriv,
  46. (PROC)glTexImage1D,
  47. (PROC)glTexImage2D,
  48. (PROC)glDrawBuffer,
  49. (PROC)glClear,
  50. (PROC)glClearColor,
  51. (PROC)glClearStencil,
  52. (PROC)glClearDepth,
  53. (PROC)glStencilMask,
  54. (PROC)glColorMask,
  55. (PROC)glDepthMask,
  56. (PROC)glDisable,
  57. (PROC)glEnable,
  58. (PROC)glFinish,
  59. (PROC)glFlush,
  60. (PROC)glBlendFunc,
  61. (PROC)glLogicOp,
  62. (PROC)glStencilFunc,
  63. (PROC)glStencilOp,
  64. (PROC)glDepthFunc,
  65. (PROC)glPixelStoref,
  66. (PROC)glPixelStorei,
  67. (PROC)glReadBuffer,
  68. (PROC)glReadPixels,
  69. (PROC)glGetBooleanv,
  70. (PROC)glGetDoublev,
  71. (PROC)glGetError,
  72. (PROC)glGetFloatv,
  73. (PROC)glGetIntegerv,
  74. (PROC)glGetString,
  75. (PROC)glGetTexImage,
  76. (PROC)glGetTexParameterfv,
  77. (PROC)glGetTexParameteriv,
  78. (PROC)glGetTexLevelParameterfv,
  79. (PROC)glGetTexLevelParameteriv,
  80. (PROC)glIsEnabled,
  81. (PROC)glDepthRange,
  82. (PROC)glViewport,
  83. /* not detected in ATI */
  84. (PROC)glDrawArrays,
  85. (PROC)glDrawElements,
  86. (PROC)glGetPointerv,
  87. (PROC)glPolygonOffset,
  88. (PROC)glCopyTexImage1D,
  89. (PROC)glCopyTexImage2D,
  90. (PROC)glCopyTexSubImage1D,
  91. (PROC)glCopyTexSubImage2D,
  92. (PROC)glTexSubImage1D,
  93. (PROC)glTexSubImage2D,
  94. (PROC)glBindTexture,
  95. (PROC)glDeleteTextures,
  96. (PROC)glGenTextures,
  97. (PROC)glIsTexture,
  98. 0
  99. };
  100. static const char *_gl_proc_names[] = {
  101. "glCullFace",
  102. "glFrontFace",
  103. "glHint",
  104. "glLineWidth",
  105. "glPointSize",
  106. "glPolygonMode",
  107. "glScissor",
  108. "glTexParameterf",
  109. "glTexParameterfv",
  110. "glTexParameteri",
  111. "glTexParameteriv",
  112. "glTexImage1D",
  113. "glTexImage2D",
  114. "glDrawBuffer",
  115. "glClear",
  116. "glClearColor",
  117. "glClearStencil",
  118. "glClearDepth",
  119. "glStencilMask",
  120. "glColorMask",
  121. "glDepthMask",
  122. "glDisable",
  123. "glEnable",
  124. "glFinish",
  125. "glFlush",
  126. "glBlendFunc",
  127. "glLogicOp",
  128. "glStencilFunc",
  129. "glStencilOp",
  130. "glDepthFunc",
  131. "glPixelStoref",
  132. "glPixelStorei",
  133. "glReadBuffer",
  134. "glReadPixels",
  135. "glGetBooleanv",
  136. "glGetDoublev",
  137. "glGetError",
  138. "glGetFloatv",
  139. "glGetIntegerv",
  140. "glGetString",
  141. "glGetTexImage",
  142. "glGetTexParameterfv",
  143. "glGetTexParameteriv",
  144. "glGetTexLevelParameterfv",
  145. "glGetTexLevelParameteriv",
  146. "glIsEnabled",
  147. "glDepthRange",
  148. "glViewport",
  149. /* not detected in ati */
  150. "glDrawArrays",
  151. "glDrawElements",
  152. "glGetPointerv",
  153. "glPolygonOffset",
  154. "glCopyTexImage1D",
  155. "glCopyTexImage2D",
  156. "glCopyTexSubImage1D",
  157. "glCopyTexSubImage2D",
  158. "glTexSubImage1D",
  159. "glTexSubImage2D",
  160. "glBindTexture",
  161. "glDeleteTextures",
  162. "glGenTextures",
  163. "glIsTexture",
  164. 0
  165. };
  166. PROC get_gl_proc_address(const char *p_address) {
  167. PROC proc = wglGetProcAddress((const CHAR *)p_address);
  168. if (!proc) {
  169. int i = 0;
  170. while (_gl_procs[i]) {
  171. if (strcmp(p_address, _gl_proc_names[i]) == 0) {
  172. return _gl_procs[i];
  173. }
  174. i++;
  175. }
  176. }
  177. return proc;
  178. }
  179. #endif