ctxgl_procaddr.cpp 5.0 KB

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