OpenGLNative.cs 90 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace Veldrid.OpenGLBinding
  4. {
  5. // uint = uint
  6. // GLuint = uint
  7. // GLuint64 = uint64
  8. // GLenum = uint
  9. // Glclampf = 32-bit float, [0, 1]
  10. public static unsafe class OpenGLNative
  11. {
  12. private static Func<string, IntPtr> s_getProcAddress;
  13. private const CallingConvention CallConv = CallingConvention.Winapi;
  14. [UnmanagedFunctionPointer(CallConv)]
  15. private delegate void glGenVertexArrays_t(uint n, out uint arrays);
  16. private static glGenVertexArrays_t p_glGenVertexArrays;
  17. public static void glGenVertexArrays(uint n, out uint arrays) => p_glGenVertexArrays(n, out arrays);
  18. [UnmanagedFunctionPointer(CallConv)]
  19. private delegate uint glGetError_t();
  20. private static glGetError_t p_glGetError;
  21. public static uint glGetError() => p_glGetError();
  22. [UnmanagedFunctionPointer(CallConv)]
  23. private delegate void glBindVertexArray_t(uint array);
  24. private static glBindVertexArray_t p_glBindVertexArray;
  25. public static void glBindVertexArray(uint array) => p_glBindVertexArray(array);
  26. [UnmanagedFunctionPointer(CallConv)]
  27. private delegate void glClearColor_t(float red, float green, float blue, float alpha);
  28. private static glClearColor_t p_glClearColor;
  29. public static void glClearColor(float red, float green, float blue, float alpha)
  30. => p_glClearColor(red, green, blue, alpha);
  31. [UnmanagedFunctionPointer(CallConv)]
  32. private delegate void glDrawBuffer_t(DrawBufferMode mode);
  33. private static glDrawBuffer_t p_glDrawBuffer;
  34. public static void glDrawBuffer(DrawBufferMode mode) => p_glDrawBuffer(mode);
  35. [UnmanagedFunctionPointer(CallConv)]
  36. private delegate void glDrawBuffers_t(uint n, DrawBuffersEnum* bufs);
  37. private static glDrawBuffers_t p_glDrawBuffers;
  38. public static void glDrawBuffers(uint n, DrawBuffersEnum* bufs) => p_glDrawBuffers(n, bufs);
  39. [UnmanagedFunctionPointer(CallConv)]
  40. private delegate void glClear_t(ClearBufferMask mask);
  41. private static glClear_t p_glClear;
  42. public static void glClear(ClearBufferMask mask) => p_glClear(mask);
  43. [UnmanagedFunctionPointer(CallConv)]
  44. private delegate void glClearDepth_t(double depth);
  45. private static glClearDepth_t p_glClearDepth;
  46. public static void glClearDepth(double depth) => p_glClearDepth(depth);
  47. [UnmanagedFunctionPointer(CallConv)]
  48. private delegate void glClearDepthf_t(float depth);
  49. private static glClearDepthf_t p_glClearDepthf;
  50. public static void glClearDepthf(float depth) => p_glClearDepthf(depth);
  51. private static glClearDepthf_t p_glClearDepthf_Compat;
  52. public static void glClearDepth_Compat(float depth) => p_glClearDepthf_Compat(depth);
  53. [UnmanagedFunctionPointer(CallConv)]
  54. private delegate void glDrawElements_t(PrimitiveType mode, uint count, DrawElementsType type, void* indices);
  55. private static glDrawElements_t p_glDrawElements;
  56. public static void glDrawElements(PrimitiveType mode, uint count, DrawElementsType type, void* indices)
  57. => p_glDrawElements(mode, count, type, indices);
  58. [UnmanagedFunctionPointer(CallConv)]
  59. private delegate void glDrawElementsBaseVertex_t(
  60. PrimitiveType mode,
  61. uint count,
  62. DrawElementsType type,
  63. void* indices,
  64. int basevertex);
  65. private static glDrawElementsBaseVertex_t p_glDrawElementsBaseVertex;
  66. public static void glDrawElementsBaseVertex(
  67. PrimitiveType mode,
  68. uint count,
  69. DrawElementsType type,
  70. void* indices,
  71. int basevertex) => p_glDrawElementsBaseVertex(mode, count, type, indices, basevertex);
  72. [UnmanagedFunctionPointer(CallConv)]
  73. private delegate void glDrawElementsInstanced_t(
  74. PrimitiveType mode,
  75. uint count,
  76. DrawElementsType type,
  77. void* indices,
  78. uint primcount);
  79. private static glDrawElementsInstanced_t p_glDrawElementsInstanced;
  80. public static void glDrawElementsInstanced(
  81. PrimitiveType mode,
  82. uint count,
  83. DrawElementsType type,
  84. void* indices,
  85. uint primcount) => p_glDrawElementsInstanced(mode, count, type, indices, primcount);
  86. [UnmanagedFunctionPointer(CallConv)]
  87. private delegate void glDrawElementsInstancedBaseVertex_t(
  88. PrimitiveType mode,
  89. uint count,
  90. DrawElementsType type,
  91. void* indices,
  92. uint primcount,
  93. int basevertex);
  94. private static glDrawElementsInstancedBaseVertex_t p_glDrawElementsInstancedBaseVertex;
  95. public static void glDrawElementsInstancedBaseVertex(
  96. PrimitiveType mode,
  97. uint count,
  98. DrawElementsType type,
  99. void* indices,
  100. uint primcount,
  101. int basevertex) => p_glDrawElementsInstancedBaseVertex(mode, count, type, indices, primcount, basevertex);
  102. [UnmanagedFunctionPointer(CallConv)]
  103. private delegate void glDrawElementsInstancedBaseVertexBaseInstance_t(
  104. PrimitiveType mode,
  105. uint count,
  106. DrawElementsType type,
  107. void* indices,
  108. uint primcount,
  109. int basevertex,
  110. uint baseinstance);
  111. private static glDrawElementsInstancedBaseVertexBaseInstance_t p_glDrawElementsInstancedBaseVertexBaseInstance;
  112. public static void glDrawElementsInstancedBaseVertexBaseInstance(
  113. PrimitiveType mode,
  114. uint count,
  115. DrawElementsType type,
  116. void* indices,
  117. uint primcount,
  118. int basevertex,
  119. uint baseinstance)
  120. => p_glDrawElementsInstancedBaseVertexBaseInstance(
  121. mode, count, type, indices, primcount, basevertex, baseinstance);
  122. [UnmanagedFunctionPointer(CallConv)]
  123. private delegate void glDrawArrays_t(PrimitiveType mode, int first, uint count);
  124. private static glDrawArrays_t p_glDrawArrays;
  125. public static void glDrawArrays(PrimitiveType mode, int first, uint count) => p_glDrawArrays(mode, first, count);
  126. [UnmanagedFunctionPointer(CallConv)]
  127. private delegate void glDrawArraysInstanced_t(PrimitiveType mode, int first, uint count, uint primcount);
  128. private static glDrawArraysInstanced_t p_glDrawArraysInstanced;
  129. public static void glDrawArraysInstanced(PrimitiveType mode, int first, uint count, uint primcount)
  130. => p_glDrawArraysInstanced(mode, first, count, primcount);
  131. [UnmanagedFunctionPointer(CallConv)]
  132. private delegate void glDrawArraysInstancedBaseInstance_t(
  133. PrimitiveType mode,
  134. int first,
  135. uint count,
  136. uint primcount,
  137. uint baseinstance);
  138. private static glDrawArraysInstancedBaseInstance_t p_glDrawArraysInstancedBaseInstance;
  139. public static void glDrawArraysInstancedBaseInstance(
  140. PrimitiveType mode,
  141. int first,
  142. uint count,
  143. uint primcount,
  144. uint baseinstance) => p_glDrawArraysInstancedBaseInstance(mode, first, count, primcount, baseinstance);
  145. [UnmanagedFunctionPointer(CallConv)]
  146. private delegate void glGenBuffers_t(uint n, out uint buffers);
  147. private static glGenBuffers_t p_glGenBuffers;
  148. public static void glGenBuffers(uint n, out uint buffers) => p_glGenBuffers(n, out buffers);
  149. [UnmanagedFunctionPointer(CallConv)]
  150. private delegate void glDeleteBuffers_t(uint n, ref uint buffers);
  151. private static glDeleteBuffers_t p_glDeleteBuffers;
  152. public static void glDeleteBuffers(uint n, ref uint buffers) => p_glDeleteBuffers(n, ref buffers);
  153. [UnmanagedFunctionPointer(CallConv)]
  154. private delegate void glGenFramebuffers_t(uint n, out uint ids);
  155. private static glGenFramebuffers_t p_glGenFramebuffers;
  156. public static void glGenFramebuffers(uint n, out uint ids) => p_glGenFramebuffers(n, out ids);
  157. [UnmanagedFunctionPointer(CallConv)]
  158. private delegate void glActiveTexture_t(TextureUnit texture);
  159. private static glActiveTexture_t p_glActiveTexture;
  160. public static void glActiveTexture(TextureUnit texture) => p_glActiveTexture(texture);
  161. [UnmanagedFunctionPointer(CallConv)]
  162. private delegate void glFramebufferTexture1D_t(
  163. FramebufferTarget target,
  164. GLFramebufferAttachment attachment,
  165. TextureTarget textarget,
  166. uint texture,
  167. int level);
  168. private static glFramebufferTexture1D_t p_glFramebufferTexture1D;
  169. public static void glFramebufferTexture1D(
  170. FramebufferTarget target,
  171. GLFramebufferAttachment attachment,
  172. TextureTarget textarget,
  173. uint texture,
  174. int level) => p_glFramebufferTexture1D(target, attachment, textarget, texture, level);
  175. [UnmanagedFunctionPointer(CallConv)]
  176. private delegate void glFramebufferTexture2D_t(
  177. FramebufferTarget target,
  178. GLFramebufferAttachment attachment,
  179. TextureTarget textarget,
  180. uint texture,
  181. int level);
  182. private static glFramebufferTexture2D_t p_glFramebufferTexture2D;
  183. public static void glFramebufferTexture2D(
  184. FramebufferTarget target,
  185. GLFramebufferAttachment attachment,
  186. TextureTarget textarget,
  187. uint texture,
  188. int level) => p_glFramebufferTexture2D(target, attachment, textarget, texture, level);
  189. [UnmanagedFunctionPointer(CallConv)]
  190. private delegate void glBindTexture_t(TextureTarget target, uint texture);
  191. private static glBindTexture_t p_glBindTexture;
  192. public static void glBindTexture(TextureTarget target, uint texture) => p_glBindTexture(target, texture);
  193. [UnmanagedFunctionPointer(CallConv)]
  194. private delegate void glBindFramebuffer_t(FramebufferTarget target, uint framebuffer);
  195. private static glBindFramebuffer_t p_glBindFramebuffer;
  196. public static void glBindFramebuffer(FramebufferTarget target, uint framebuffer)
  197. => p_glBindFramebuffer(target, framebuffer);
  198. [UnmanagedFunctionPointer(CallConv)]
  199. private delegate void glDeleteFramebuffers_t(uint n, ref uint framebuffers);
  200. private static glDeleteFramebuffers_t p_glDeleteFramebuffers;
  201. public static void glDeleteFramebuffers(uint n, ref uint framebuffers) => p_glDeleteFramebuffers(n, ref framebuffers);
  202. [UnmanagedFunctionPointer(CallConv)]
  203. private delegate void glGenTextures_t(uint n, out uint textures);
  204. private static glGenTextures_t p_glGenTextures;
  205. public static void glGenTextures(uint n, out uint textures) => p_glGenTextures(n, out textures);
  206. [UnmanagedFunctionPointer(CallConv)]
  207. private delegate void glDeleteTextures_t(uint n, ref uint textures);
  208. private static glDeleteTextures_t p_glDeleteTextures;
  209. public static void glDeleteTextures(uint n, ref uint textures) => p_glDeleteTextures(n, ref textures);
  210. [UnmanagedFunctionPointer(CallConv)]
  211. private delegate FramebufferErrorCode glCheckFramebufferStatus_t(FramebufferTarget target);
  212. private static glCheckFramebufferStatus_t p_glCheckFramebufferStatus;
  213. public static FramebufferErrorCode glCheckFramebufferStatus(FramebufferTarget target)
  214. => p_glCheckFramebufferStatus(target);
  215. [UnmanagedFunctionPointer(CallConv)]
  216. private delegate void glBindBuffer_t(BufferTarget target, uint buffer);
  217. private static glBindBuffer_t p_glBindBuffer;
  218. public static void glBindBuffer(BufferTarget target, uint buffer) => p_glBindBuffer(target, buffer);
  219. [UnmanagedFunctionPointer(CallConv)]
  220. private delegate void glViewportIndexedf_t(uint index, float x, float y, float w, float h);
  221. private static glViewportIndexedf_t p_glViewportIndexedf;
  222. public static void glViewportIndexed(uint index, float x, float y, float w, float h)
  223. => p_glViewportIndexedf(index, x, y, w, h);
  224. [UnmanagedFunctionPointer(CallConv)]
  225. private delegate void glViewport_t(int x, int y, uint width, uint height);
  226. private static glViewport_t p_glViewport;
  227. public static void glViewport(int x, int y, uint width, uint height) => p_glViewport(x, y, width, height);
  228. [UnmanagedFunctionPointer(CallConv)]
  229. private delegate void glDepthRangeIndexed_t(uint index, double nearVal, double farVal);
  230. private static glDepthRangeIndexed_t p_glDepthRangeIndexed;
  231. public static void glDepthRangeIndexed(uint index, double nearVal, double farVal)
  232. => p_glDepthRangeIndexed(index, nearVal, farVal);
  233. [UnmanagedFunctionPointer(CallConv)]
  234. private delegate void glDepthRangef_t(float n, float f);
  235. private static glDepthRangef_t p_glDepthRangef;
  236. public static void glDepthRangef(float n, float f) => p_glDepthRangef(n, f);
  237. [UnmanagedFunctionPointer(CallConv)]
  238. private delegate void glBufferSubData_t(BufferTarget target, IntPtr offset, UIntPtr size, void* data);
  239. private static glBufferSubData_t p_glBufferSubData;
  240. public static void glBufferSubData(BufferTarget target, IntPtr offset, UIntPtr size, void* data)
  241. => p_glBufferSubData(target, offset, size, data);
  242. [UnmanagedFunctionPointer(CallConv)]
  243. private delegate void glNamedBufferSubData_t(uint buffer, IntPtr offset, uint size, void* data);
  244. private static glNamedBufferSubData_t p_glNamedBufferSubData;
  245. public static void glNamedBufferSubData(uint buffer, IntPtr offset, uint size, void* data)
  246. => p_glNamedBufferSubData(buffer, offset, size, data);
  247. [UnmanagedFunctionPointer(CallConv)]
  248. private delegate void glScissorIndexed_t(uint index, int left, int bottom, uint width, uint height);
  249. private static glScissorIndexed_t p_glScissorIndexed;
  250. public static void glScissorIndexed(uint index, int left, int bottom, uint width, uint height)
  251. => p_glScissorIndexed(index, left, bottom, width, height);
  252. [UnmanagedFunctionPointer(CallConv)]
  253. private delegate void glScissor_t(int x, int y, uint width, uint height);
  254. private static glScissor_t p_glScissor;
  255. public static void glScissor(int x, int y, uint width, uint height) => p_glScissor(x, y, width, height);
  256. [UnmanagedFunctionPointer(CallConv)]
  257. private delegate void glPixelStorei_t(PixelStoreParameter pname, int param);
  258. private static glPixelStorei_t p_glPixelStorei;
  259. public static void glPixelStorei(PixelStoreParameter pname, int param) => p_glPixelStorei(pname, param);
  260. [UnmanagedFunctionPointer(CallConv)]
  261. private delegate void glTexSubImage1D_t(
  262. TextureTarget target,
  263. int level,
  264. int xoffset,
  265. uint width,
  266. GLPixelFormat format,
  267. GLPixelType type,
  268. void* pixels);
  269. private static glTexSubImage1D_t p_glTexSubImage1D;
  270. public static void glTexSubImage1D(
  271. TextureTarget target,
  272. int level,
  273. int xoffset,
  274. uint width,
  275. GLPixelFormat format,
  276. GLPixelType type,
  277. void* pixels) => p_glTexSubImage1D(target, level, xoffset, width, format, type, pixels);
  278. [UnmanagedFunctionPointer(CallConv)]
  279. private delegate void glTexSubImage2D_t(
  280. TextureTarget target,
  281. int level,
  282. int xoffset,
  283. int yoffset,
  284. uint width,
  285. uint height,
  286. GLPixelFormat format,
  287. GLPixelType type,
  288. void* pixels);
  289. private static glTexSubImage2D_t p_glTexSubImage2D;
  290. public static void glTexSubImage2D(
  291. TextureTarget target,
  292. int level,
  293. int xoffset,
  294. int yoffset,
  295. uint width,
  296. uint height,
  297. GLPixelFormat format,
  298. GLPixelType type,
  299. void* pixels) => p_glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
  300. [UnmanagedFunctionPointer(CallConv)]
  301. private delegate void glTexSubImage3D_t(
  302. TextureTarget target,
  303. int level,
  304. int xoffset,
  305. int yoffset,
  306. int zoffset,
  307. uint width,
  308. uint height,
  309. uint depth,
  310. GLPixelFormat format,
  311. GLPixelType type,
  312. void* pixels);
  313. private static glTexSubImage3D_t p_glTexSubImage3D;
  314. public static void glTexSubImage3D(
  315. TextureTarget target,
  316. int level,
  317. int xoffset,
  318. int yoffset,
  319. int zoffset,
  320. uint width,
  321. uint height,
  322. uint depth,
  323. GLPixelFormat format,
  324. GLPixelType type,
  325. void* pixels)
  326. => p_glTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels);
  327. [UnmanagedFunctionPointer(CallConv)]
  328. private delegate void glShaderSource_t(uint shader, uint count, byte** @string, int* length);
  329. private static glShaderSource_t p_glShaderSource;
  330. public static void glShaderSource(uint shader, uint count, byte** @string, int* length)
  331. => p_glShaderSource(shader, count, @string, length);
  332. [UnmanagedFunctionPointer(CallConv)]
  333. private delegate uint glCreateShader_t(ShaderType shaderType);
  334. private static glCreateShader_t p_glCreateShader;
  335. public static uint glCreateShader(ShaderType shaderType) => p_glCreateShader(shaderType);
  336. [UnmanagedFunctionPointer(CallConv)]
  337. private delegate void glCompileShader_t(uint shader);
  338. private static glCompileShader_t p_glCompileShader;
  339. public static void glCompileShader(uint shader) => p_glCompileShader(shader);
  340. [UnmanagedFunctionPointer(CallConv)]
  341. private delegate void glGetShaderiv_t(uint shader, ShaderParameter pname, int* @params);
  342. private static glGetShaderiv_t p_glGetShaderiv;
  343. public static void glGetShaderiv(uint shader, ShaderParameter pname, int* @params)
  344. => p_glGetShaderiv(shader, pname, @params);
  345. [UnmanagedFunctionPointer(CallConv)]
  346. private delegate void glGetShaderInfoLog_t(uint shader, uint maxLength, uint* length, byte* infoLog);
  347. private static glGetShaderInfoLog_t p_glGetShaderInfoLog;
  348. public static void glGetShaderInfoLog(uint shader, uint maxLength, uint* length, byte* infoLog)
  349. => p_glGetShaderInfoLog(shader, maxLength, length, infoLog);
  350. [UnmanagedFunctionPointer(CallConv)]
  351. private delegate void glDeleteShader_t(uint shader);
  352. private static glDeleteShader_t p_glDeleteShader;
  353. public static void glDeleteShader(uint shader) => p_glDeleteShader(shader);
  354. [UnmanagedFunctionPointer(CallConv)]
  355. private delegate void glGenSamplers_t(uint n, out uint samplers);
  356. private static glGenSamplers_t p_glGenSamplers;
  357. public static void glGenSamplers(uint n, out uint samplers) => p_glGenSamplers(n, out samplers);
  358. [UnmanagedFunctionPointer(CallConv)]
  359. private delegate void glSamplerParameterf_t(uint sampler, SamplerParameterName pname, float param);
  360. private static glSamplerParameterf_t p_glSamplerParameterf;
  361. public static void glSamplerParameterf(uint sampler, SamplerParameterName pname, float param)
  362. => p_glSamplerParameterf(sampler, pname, param);
  363. [UnmanagedFunctionPointer(CallConv)]
  364. private delegate void glSamplerParameteri_t(uint sampler, SamplerParameterName pname, int param);
  365. private static glSamplerParameteri_t p_glSamplerParameteri;
  366. public static void glSamplerParameteri(uint sampler, SamplerParameterName pname, int param)
  367. => p_glSamplerParameteri(sampler, pname, param);
  368. [UnmanagedFunctionPointer(CallConv)]
  369. private delegate void glSamplerParameterfv_t(uint sampler, SamplerParameterName pname, float* @params);
  370. private static glSamplerParameterfv_t p_glSamplerParameterfv;
  371. public static void glSamplerParameterfv(uint sampler, SamplerParameterName pname, float* @params)
  372. => p_glSamplerParameterfv(sampler, pname, @params);
  373. [UnmanagedFunctionPointer(CallConv)]
  374. private delegate void glBindSampler_t(uint unit, uint sampler);
  375. private static glBindSampler_t p_glBindSampler;
  376. public static void glBindSampler(uint unit, uint sampler) => p_glBindSampler(unit, sampler);
  377. [UnmanagedFunctionPointer(CallConv)]
  378. private delegate void glDeleteSamplers_t(uint n, ref uint samplers);
  379. private static glDeleteSamplers_t p_glDeleteSamplers;
  380. public static void glDeleteSamplers(uint n, ref uint samplers) => p_glDeleteSamplers(n, ref samplers);
  381. [UnmanagedFunctionPointer(CallConv)]
  382. private delegate void glColorMask_t(
  383. GLboolean red,
  384. GLboolean green,
  385. GLboolean blue,
  386. GLboolean alpha);
  387. private static glColorMask_t p_glColorMask;
  388. public static void glColorMask(
  389. GLboolean red,
  390. GLboolean green,
  391. GLboolean blue,
  392. GLboolean alpha) => p_glColorMask(red, green, blue, alpha);
  393. [UnmanagedFunctionPointer(CallConv)]
  394. private delegate void glColorMaski_t(
  395. uint buf,
  396. GLboolean red,
  397. GLboolean green,
  398. GLboolean blue,
  399. GLboolean alpha);
  400. private static glColorMaski_t p_glColorMaski;
  401. public static void glColorMaski(
  402. uint buf,
  403. GLboolean red,
  404. GLboolean green,
  405. GLboolean blue,
  406. GLboolean alpha) => p_glColorMaski(buf, red, green, blue, alpha);
  407. [UnmanagedFunctionPointer(CallConv)]
  408. private delegate void glBlendFuncSeparatei_t(
  409. uint buf,
  410. BlendingFactorSrc srcRGB,
  411. BlendingFactorDest dstRGB,
  412. BlendingFactorSrc srcAlpha,
  413. BlendingFactorDest dstAlpha);
  414. private static glBlendFuncSeparatei_t p_glBlendFuncSeparatei;
  415. public static void glBlendFuncSeparatei(
  416. uint buf,
  417. BlendingFactorSrc srcRGB,
  418. BlendingFactorDest dstRGB,
  419. BlendingFactorSrc srcAlpha,
  420. BlendingFactorDest dstAlpha) => p_glBlendFuncSeparatei(buf, srcRGB, dstRGB, srcAlpha, dstAlpha);
  421. [UnmanagedFunctionPointer(CallConv)]
  422. private delegate void glBlendFuncSeparate_t(
  423. BlendingFactorSrc srcRGB,
  424. BlendingFactorDest dstRGB,
  425. BlendingFactorSrc srcAlpha,
  426. BlendingFactorDest dstAlpha);
  427. private static glBlendFuncSeparate_t p_glBlendFuncSeparate;
  428. public static void glBlendFuncSeparate(
  429. BlendingFactorSrc srcRGB,
  430. BlendingFactorDest dstRGB,
  431. BlendingFactorSrc srcAlpha,
  432. BlendingFactorDest dstAlpha) => p_glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
  433. [UnmanagedFunctionPointer(CallConv)]
  434. private delegate void glEnable_t(EnableCap cap);
  435. private static glEnable_t p_glEnable;
  436. public static void glEnable(EnableCap cap) => p_glEnable(cap);
  437. [UnmanagedFunctionPointer(CallConv)]
  438. private delegate void glEnablei_t(EnableCap cap, uint index);
  439. private static glEnablei_t p_glEnablei;
  440. public static void glEnablei(EnableCap cap, uint index) => p_glEnablei(cap, index);
  441. [UnmanagedFunctionPointer(CallConv)]
  442. private delegate void glDisable_t(EnableCap cap);
  443. private static glDisable_t p_glDisable;
  444. public static void glDisable(EnableCap cap) => p_glDisable(cap);
  445. [UnmanagedFunctionPointer(CallConv)]
  446. private delegate void glDisablei_t(EnableCap cap, uint index);
  447. private static glDisablei_t p_glDisablei;
  448. public static void glDisablei(EnableCap cap, uint index) => p_glDisablei(cap, index);
  449. [UnmanagedFunctionPointer(CallConv)]
  450. private delegate void glBlendEquationSeparatei_t(uint buf, BlendEquationMode modeRGB, BlendEquationMode modeAlpha);
  451. private static glBlendEquationSeparatei_t p_glBlendEquationSeparatei;
  452. public static void glBlendEquationSeparatei(uint buf, BlendEquationMode modeRGB, BlendEquationMode modeAlpha)
  453. => p_glBlendEquationSeparatei(buf, modeRGB, modeAlpha);
  454. [UnmanagedFunctionPointer(CallConv)]
  455. private delegate void glBlendEquationSeparate_t(BlendEquationMode modeRGB, BlendEquationMode modeAlpha);
  456. private static glBlendEquationSeparate_t p_glBlendEquationSeparate;
  457. public static void glBlendEquationSeparate(BlendEquationMode modeRGB, BlendEquationMode modeAlpha)
  458. => p_glBlendEquationSeparate(modeRGB, modeAlpha);
  459. [UnmanagedFunctionPointer(CallConv)]
  460. private delegate void glBlendColor_t(float red, float green, float blue, float alpha);
  461. private static glBlendColor_t p_glBlendColor;
  462. public static void glBlendColor(float red, float green, float blue, float alpha)
  463. => p_glBlendColor(red, green, blue, alpha);
  464. [UnmanagedFunctionPointer(CallConv)]
  465. private delegate void glDepthFunc_t(DepthFunction func);
  466. private static glDepthFunc_t p_glDepthFunc;
  467. public static void glDepthFunc(DepthFunction func) => p_glDepthFunc(func);
  468. [UnmanagedFunctionPointer(CallConv)]
  469. private delegate void glDepthMask_t(GLboolean flag);
  470. private static glDepthMask_t p_glDepthMask;
  471. public static void glDepthMask(GLboolean flag) => p_glDepthMask(flag);
  472. [UnmanagedFunctionPointer(CallConv)]
  473. private delegate void glCullFace_t(CullFaceMode mode);
  474. private static glCullFace_t p_glCullFace;
  475. public static void glCullFace(CullFaceMode mode) => p_glCullFace(mode);
  476. [UnmanagedFunctionPointer(CallConv)]
  477. private delegate void glPolygonMode_t(MaterialFace face, PolygonMode mode);
  478. private static glPolygonMode_t p_glPolygonMode;
  479. public static void glPolygonMode(MaterialFace face, PolygonMode mode) => p_glPolygonMode(face, mode);
  480. [UnmanagedFunctionPointer(CallConv)]
  481. private delegate uint glCreateProgram_t();
  482. private static glCreateProgram_t p_glCreateProgram;
  483. public static uint glCreateProgram() => p_glCreateProgram();
  484. [UnmanagedFunctionPointer(CallConv)]
  485. private delegate void glAttachShader_t(uint program, uint shader);
  486. private static glAttachShader_t p_glAttachShader;
  487. public static void glAttachShader(uint program, uint shader) => p_glAttachShader(program, shader);
  488. [UnmanagedFunctionPointer(CallConv)]
  489. private delegate void glBindAttribLocation_t(uint program, uint index, byte* name);
  490. private static glBindAttribLocation_t p_glBindAttribLocation;
  491. public static void glBindAttribLocation(uint program, uint index, byte* name)
  492. => p_glBindAttribLocation(program, index, name);
  493. [UnmanagedFunctionPointer(CallConv)]
  494. private delegate void glLinkProgram_t(uint program);
  495. private static glLinkProgram_t p_glLinkProgram;
  496. public static void glLinkProgram(uint program) => p_glLinkProgram(program);
  497. [UnmanagedFunctionPointer(CallConv)]
  498. private delegate void glGetProgramiv_t(uint program, GetProgramParameterName pname, int* @params);
  499. private static glGetProgramiv_t p_glGetProgramiv;
  500. public static void glGetProgramiv(uint program, GetProgramParameterName pname, int* @params)
  501. => p_glGetProgramiv(program, pname, @params);
  502. [UnmanagedFunctionPointer(CallConv)]
  503. private delegate void glGetProgramInfoLog_t(uint program, uint maxLength, uint* length, byte* infoLog);
  504. private static glGetProgramInfoLog_t p_glGetProgramInfoLog;
  505. public static void glGetProgramInfoLog(uint program, uint maxLength, uint* length, byte* infoLog)
  506. => p_glGetProgramInfoLog(program, maxLength, length, infoLog);
  507. [UnmanagedFunctionPointer(CallConv)]
  508. private delegate void glUniformBlockBinding_t(uint program, uint uniformBlockIndex, uint uniformBlockBinding);
  509. private static glUniformBlockBinding_t p_glUniformBlockBinding;
  510. public static void glUniformBlockBinding(uint program, uint uniformBlockIndex, uint uniformBlockBinding)
  511. => p_glUniformBlockBinding(program, uniformBlockIndex, uniformBlockBinding);
  512. [UnmanagedFunctionPointer(CallConv)]
  513. private delegate void glDeleteProgram_t(uint program);
  514. private static glDeleteProgram_t p_glDeleteProgram;
  515. public static void glDeleteProgram(uint program) => p_glDeleteProgram(program);
  516. [UnmanagedFunctionPointer(CallConv)]
  517. private delegate void glUniform1i_t(int location, int v0);
  518. private static glUniform1i_t p_glUniform1i;
  519. public static void glUniform1i(int location, int v0) => p_glUniform1i(location, v0);
  520. [UnmanagedFunctionPointer(CallConv)]
  521. private delegate uint glGetUniformBlockIndex_t(uint program, byte* uniformBlockName);
  522. private static glGetUniformBlockIndex_t p_glGetUniformBlockIndex;
  523. public static uint glGetUniformBlockIndex(uint program, byte* uniformBlockName)
  524. => p_glGetUniformBlockIndex(program, uniformBlockName);
  525. [UnmanagedFunctionPointer(CallConv)]
  526. private delegate int glGetUniformLocation_t(uint program, byte* name);
  527. private static glGetUniformLocation_t p_glGetUniformLocation;
  528. public static int glGetUniformLocation(uint program, byte* name) => p_glGetUniformLocation(program, name);
  529. [UnmanagedFunctionPointer(CallConv)]
  530. private delegate int glGetAttribLocation_t(uint program, byte* name);
  531. private static glGetAttribLocation_t p_glGetAttribLocation;
  532. public static int glGetAttribLocation(uint program, byte* name) => p_glGetAttribLocation(program, name);
  533. [UnmanagedFunctionPointer(CallConv)]
  534. private delegate void glUseProgram_t(uint program);
  535. private static glUseProgram_t p_glUseProgram;
  536. public static void glUseProgram(uint program) => p_glUseProgram(program);
  537. [UnmanagedFunctionPointer(CallConv)]
  538. private delegate void glBindBufferRange_t(
  539. BufferRangeTarget target,
  540. uint index,
  541. uint buffer,
  542. IntPtr offset,
  543. UIntPtr size);
  544. private static glBindBufferRange_t p_glBindBufferRange;
  545. public static void glBindBufferRange(
  546. BufferRangeTarget target,
  547. uint index,
  548. uint buffer,
  549. IntPtr offset,
  550. UIntPtr size) => p_glBindBufferRange(target, index, buffer, offset, size);
  551. [UnmanagedFunctionPointer(CallingConvention.Winapi)]
  552. public delegate void DebugProc(
  553. DebugSource source,
  554. DebugType type,
  555. uint id,
  556. DebugSeverity severity,
  557. uint length,
  558. byte* message,
  559. void* userParam);
  560. [UnmanagedFunctionPointer(CallConv)]
  561. private delegate void glDebugMessageCallback_t(DebugProc callback, void* userParam);
  562. private static glDebugMessageCallback_t p_glDebugMessageCallback;
  563. public static void glDebugMessageCallback(DebugProc callback, void* userParam)
  564. => p_glDebugMessageCallback(callback, userParam);
  565. [UnmanagedFunctionPointer(CallConv)]
  566. private delegate void glBufferData_t(BufferTarget target, UIntPtr size, void* data, BufferUsageHint usage);
  567. private static glBufferData_t p_glBufferData;
  568. public static void glBufferData(BufferTarget target, UIntPtr size, void* data, BufferUsageHint usage)
  569. => p_glBufferData(target, size, data, usage);
  570. [UnmanagedFunctionPointer(CallConv)]
  571. private delegate void glNamedBufferData_t(uint buffer, uint size, void* data, BufferUsageHint usage);
  572. private static glNamedBufferData_t p_glNamedBufferData;
  573. public static void glNamedBufferData(uint buffer, uint size, void* data, BufferUsageHint usage)
  574. => p_glNamedBufferData(buffer, size, data, usage);
  575. [UnmanagedFunctionPointer(CallConv)]
  576. private delegate void glTexImage1D_t(
  577. TextureTarget target,
  578. int level,
  579. PixelInternalFormat internalFormat,
  580. uint width,
  581. int border,
  582. GLPixelFormat format,
  583. GLPixelType type,
  584. void* data);
  585. private static glTexImage1D_t p_glTexImage1D;
  586. public static void glTexImage1D(
  587. TextureTarget target,
  588. int level,
  589. PixelInternalFormat internalFormat,
  590. uint width,
  591. int border,
  592. GLPixelFormat format,
  593. GLPixelType type,
  594. void* data) => p_glTexImage1D(target, level, internalFormat, width, border, format, type, data);
  595. [UnmanagedFunctionPointer(CallConv)]
  596. private delegate void glTexImage2D_t(
  597. TextureTarget target,
  598. int level,
  599. PixelInternalFormat internalFormat,
  600. uint width,
  601. uint height,
  602. int border,
  603. GLPixelFormat format,
  604. GLPixelType type,
  605. void* data);
  606. private static glTexImage2D_t p_glTexImage2D;
  607. public static void glTexImage2D(
  608. TextureTarget target,
  609. int level,
  610. PixelInternalFormat internalFormat,
  611. uint width,
  612. uint height,
  613. int border,
  614. GLPixelFormat format,
  615. GLPixelType type,
  616. void* data) => p_glTexImage2D(target, level, internalFormat, width, height, border, format, type, data);
  617. [UnmanagedFunctionPointer(CallConv)]
  618. private delegate void glTexImage3D_t(
  619. TextureTarget target,
  620. int level,
  621. PixelInternalFormat internalFormat,
  622. uint width,
  623. uint height,
  624. uint depth,
  625. int border,
  626. GLPixelFormat format,
  627. GLPixelType type,
  628. void* data);
  629. private static glTexImage3D_t p_glTexImage3D;
  630. public static void glTexImage3D(
  631. TextureTarget target,
  632. int level,
  633. PixelInternalFormat internalFormat,
  634. uint width,
  635. uint height,
  636. uint depth,
  637. int border,
  638. GLPixelFormat format,
  639. GLPixelType type,
  640. void* data) => p_glTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, data);
  641. [UnmanagedFunctionPointer(CallConv)]
  642. private delegate void glEnableVertexAttribArray_t(uint index);
  643. private static glEnableVertexAttribArray_t p_glEnableVertexAttribArray;
  644. public static void glEnableVertexAttribArray(uint index) => p_glEnableVertexAttribArray(index);
  645. [UnmanagedFunctionPointer(CallConv)]
  646. private delegate void glDisableVertexAttribArray_t(uint index);
  647. private static glDisableVertexAttribArray_t p_glDisableVertexAttribArray;
  648. public static void glDisableVertexAttribArray(uint index) => p_glDisableVertexAttribArray(index);
  649. [UnmanagedFunctionPointer(CallConv)]
  650. private delegate void glVertexAttribPointer_t(
  651. uint index,
  652. int size,
  653. VertexAttribPointerType type,
  654. GLboolean normalized,
  655. uint stride,
  656. void* pointer);
  657. private static glVertexAttribPointer_t p_glVertexAttribPointer;
  658. public static void glVertexAttribPointer(
  659. uint index,
  660. int size,
  661. VertexAttribPointerType type,
  662. GLboolean normalized,
  663. uint stride,
  664. void* pointer) => p_glVertexAttribPointer(index, size, type, normalized, stride, pointer);
  665. [UnmanagedFunctionPointer(CallConv)]
  666. private delegate void glVertexAttribIPointer_t(
  667. uint index,
  668. int size,
  669. VertexAttribPointerType type,
  670. uint stride,
  671. void* pointer);
  672. private static glVertexAttribIPointer_t p_glVertexAttribIPointer;
  673. public static void glVertexAttribIPointer(
  674. uint index,
  675. int size,
  676. VertexAttribPointerType type,
  677. uint stride,
  678. void* pointer) => p_glVertexAttribIPointer(index, size, type, stride, pointer);
  679. [UnmanagedFunctionPointer(CallConv)]
  680. private delegate void glVertexAttribDivisor_t(uint index, uint divisor);
  681. private static glVertexAttribDivisor_t p_glVertexAttribDivisor;
  682. public static void glVertexAttribDivisor(uint index, uint divisor) => p_glVertexAttribDivisor(index, divisor);
  683. [UnmanagedFunctionPointer(CallConv)]
  684. private delegate void glFrontFace_t(FrontFaceDirection mode);
  685. private static glFrontFace_t p_glFrontFace;
  686. public static void glFrontFace(FrontFaceDirection mode) => p_glFrontFace(mode);
  687. [UnmanagedFunctionPointer(CallConv)]
  688. private delegate void glGetIntegerv_t(GetPName pname, int* data);
  689. private static glGetIntegerv_t p_glGetIntegerv;
  690. public static void glGetIntegerv(GetPName pname, int* data) => p_glGetIntegerv(pname, data);
  691. [UnmanagedFunctionPointer(CallConv)]
  692. private delegate void glBindTextureUnit_t(uint unit, uint texture);
  693. private static glBindTextureUnit_t p_glBindTextureUnit;
  694. public static void glBindTextureUnit(uint unit, uint texture) => p_glBindTextureUnit(unit, texture);
  695. [UnmanagedFunctionPointer(CallConv)]
  696. private delegate void glTexParameteri_t(TextureTarget target, TextureParameterName pname, int param);
  697. private static glTexParameteri_t p_glTexParameteri;
  698. public static void glTexParameteri(TextureTarget target, TextureParameterName pname, int param)
  699. => p_glTexParameteri(target, pname, param);
  700. [UnmanagedFunctionPointer(CallConv)]
  701. private delegate byte* glGetString_t(StringName name);
  702. private static glGetString_t p_glGetString;
  703. public static byte* glGetString(StringName name) => p_glGetString(name);
  704. [UnmanagedFunctionPointer(CallConv)]
  705. private delegate byte* glGetStringi_t(StringNameIndexed name, uint index);
  706. private static glGetStringi_t p_glGetStringi;
  707. public static byte* glGetStringi(StringNameIndexed name, uint index) => p_glGetStringi(name, index);
  708. [UnmanagedFunctionPointer(CallConv)]
  709. private delegate void glObjectLabel_t(ObjectLabelIdentifier identifier, uint name, uint length, byte* label);
  710. private static glObjectLabel_t p_glObjectLabel;
  711. public static void glObjectLabel(ObjectLabelIdentifier identifier, uint name, uint length, byte* label)
  712. => p_glObjectLabel(identifier, name, length, label);
  713. /// <summary>
  714. /// Indicates whether the glObjectLabel function was successfully loaded.
  715. /// Some drivers advertise KHR_Debug support, but return null for this function pointer.
  716. /// </summary>
  717. public static bool HasGlObjectLabel => p_glObjectLabel != null;
  718. [UnmanagedFunctionPointer(CallConv)]
  719. private delegate void glTexImage2DMultisample_t(
  720. TextureTarget target,
  721. uint samples,
  722. PixelInternalFormat internalformat,
  723. uint width,
  724. uint height,
  725. GLboolean fixedsamplelocations);
  726. private static glTexImage2DMultisample_t p_glTexImage2DMultisample;
  727. public static void glTexImage2DMultiSample(
  728. TextureTarget target,
  729. uint samples,
  730. PixelInternalFormat internalformat,
  731. uint width,
  732. uint height,
  733. GLboolean fixedsamplelocations) => p_glTexImage2DMultisample(
  734. target,
  735. samples,
  736. internalformat,
  737. width,
  738. height,
  739. fixedsamplelocations);
  740. [UnmanagedFunctionPointer(CallConv)]
  741. private delegate void glTexImage3DMultisample_t(
  742. TextureTarget target,
  743. uint samples,
  744. PixelInternalFormat internalformat,
  745. uint width,
  746. uint height,
  747. uint depth,
  748. GLboolean fixedsamplelocations);
  749. private static glTexImage3DMultisample_t p_glTexImage3DMultisample;
  750. public static void glTexImage3DMultisample(
  751. TextureTarget target,
  752. uint samples,
  753. PixelInternalFormat internalformat,
  754. uint width,
  755. uint height,
  756. uint depth,
  757. GLboolean fixedsamplelocations) => p_glTexImage3DMultisample(
  758. target,
  759. samples,
  760. internalformat,
  761. width,
  762. height,
  763. depth,
  764. fixedsamplelocations);
  765. [UnmanagedFunctionPointer(CallConv)]
  766. private delegate void glBlitFramebuffer_t(
  767. int srcX0,
  768. int srcY0,
  769. int srcX1,
  770. int srcY1,
  771. int dstX0,
  772. int dstY0,
  773. int dstX1,
  774. int dstY1,
  775. ClearBufferMask mask,
  776. BlitFramebufferFilter filter);
  777. private static glBlitFramebuffer_t p_glBlitFramebuffer;
  778. public static void glBlitFramebuffer(
  779. int srcX0,
  780. int srcY0,
  781. int srcX1,
  782. int srcY1,
  783. int dstX0,
  784. int dstY0,
  785. int dstX1,
  786. int dstY1,
  787. ClearBufferMask mask,
  788. BlitFramebufferFilter filter)
  789. => p_glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter);
  790. [UnmanagedFunctionPointer(CallConv)]
  791. private delegate void glFramebufferTextureLayer_t(
  792. FramebufferTarget target,
  793. GLFramebufferAttachment attachment,
  794. uint texture,
  795. int level,
  796. int layer);
  797. private static glFramebufferTextureLayer_t p_glFramebufferTextureLayer;
  798. public static void glFramebufferTextureLayer(
  799. FramebufferTarget target,
  800. GLFramebufferAttachment attachment,
  801. uint texture,
  802. int level,
  803. int layer) => p_glFramebufferTextureLayer(target, attachment, texture, level, layer);
  804. [UnmanagedFunctionPointer(CallConv)]
  805. private delegate void glDispatchCompute_t(uint num_groups_x, uint num_groups_y, uint num_groups_z);
  806. private static glDispatchCompute_t p_glDispatchCompute;
  807. public static void glDispatchCompute(uint num_groups_x, uint num_groups_y, uint num_groups_z)
  808. => p_glDispatchCompute(num_groups_x, num_groups_y, num_groups_z);
  809. [UnmanagedFunctionPointer(CallConv)]
  810. private delegate uint glGetProgramResourceIndex_t(uint program, ProgramInterface programInterface, byte* name);
  811. private static glGetProgramResourceIndex_t p_glGetProgramResourceIndex;
  812. public static uint glGetProgramResourceIndex(uint program, ProgramInterface programInterface, byte* name)
  813. => p_glGetProgramResourceIndex(program, programInterface, name);
  814. [UnmanagedFunctionPointer(CallConv)]
  815. private delegate void glShaderStorageBlockBinding_t(uint program, uint storageBlockIndex, uint storageBlockBinding);
  816. private static glShaderStorageBlockBinding_t p_glShaderStorageBlockBinding;
  817. public static void glShaderStorageBlockBinding(uint program, uint storageBlockIndex, uint storageBlockBinding)
  818. => p_glShaderStorageBlockBinding(program, storageBlockIndex, storageBlockBinding);
  819. [UnmanagedFunctionPointer(CallConv)]
  820. private delegate void glDrawElementsIndirect_t(PrimitiveType mode, DrawElementsType type, IntPtr indirect);
  821. private static glDrawElementsIndirect_t p_glDrawElementsIndirect;
  822. public static void glDrawElementsIndirect(PrimitiveType mode, DrawElementsType type, IntPtr indirect)
  823. => p_glDrawElementsIndirect(mode, type, indirect);
  824. [UnmanagedFunctionPointer(CallConv)]
  825. private delegate void glMultiDrawElementsIndirect_t(
  826. PrimitiveType mode,
  827. DrawElementsType type,
  828. IntPtr indirect,
  829. uint drawcount,
  830. uint stride);
  831. private static glMultiDrawElementsIndirect_t p_glMultiDrawElementsIndirect;
  832. public static void glMultiDrawElementsIndirect(
  833. PrimitiveType mode,
  834. DrawElementsType type,
  835. IntPtr indirect,
  836. uint drawcount,
  837. uint stride) => p_glMultiDrawElementsIndirect(mode, type, indirect, drawcount, stride);
  838. [UnmanagedFunctionPointer(CallConv)]
  839. private delegate void glDrawArraysIndirect_t(PrimitiveType mode, IntPtr indirect);
  840. private static glDrawArraysIndirect_t p_glDrawArraysIndirect;
  841. public static void glDrawArraysIndirect(PrimitiveType mode, IntPtr indirect)
  842. => p_glDrawArraysIndirect(mode, indirect);
  843. [UnmanagedFunctionPointer(CallConv)]
  844. private delegate void glMultiDrawArraysIndirect_t(PrimitiveType mode, IntPtr indirect, uint drawcount, uint stride);
  845. private static glMultiDrawArraysIndirect_t p_glMultiDrawArraysIndirect;
  846. public static void glMultiDrawArraysIndirect(PrimitiveType mode, IntPtr indirect, uint drawcount, uint stride)
  847. => p_glMultiDrawArraysIndirect(mode, indirect, drawcount, stride);
  848. [UnmanagedFunctionPointer(CallConv)]
  849. private delegate void glDispatchComputeIndirect_t(IntPtr indirect);
  850. private static glDispatchComputeIndirect_t p_glDispatchComputeIndirect;
  851. public static void glDispatchComputeIndirect(IntPtr indirect) => p_glDispatchComputeIndirect(indirect);
  852. [UnmanagedFunctionPointer(CallConv)]
  853. private delegate void glBindImageTexture_t(
  854. uint unit​,
  855. uint texture​,
  856. int level​,
  857. GLboolean layered​,
  858. int layer​,
  859. TextureAccess access​,
  860. SizedInternalFormat format​);
  861. private static glBindImageTexture_t p_glBindImageTexture;
  862. public static void glBindImageTexture(
  863. uint unit​,
  864. uint texture​,
  865. int level​,
  866. GLboolean layered​,
  867. int layer​,
  868. TextureAccess access​,
  869. SizedInternalFormat format​) => p_glBindImageTexture(unit, texture, level, layered, layer, access, format);
  870. [UnmanagedFunctionPointer(CallConv)]
  871. private delegate void glMemoryBarrier_t(MemoryBarrierFlags barriers);
  872. private static glMemoryBarrier_t p_glMemoryBarrier;
  873. public static void glMemoryBarrier(MemoryBarrierFlags barriers) => p_glMemoryBarrier(barriers);
  874. [UnmanagedFunctionPointer(CallConv)]
  875. private delegate void glTexStorage1D_t(
  876. TextureTarget target,
  877. uint levels,
  878. SizedInternalFormat internalformat,
  879. uint width);
  880. private static glTexStorage1D_t p_glTexStorage1D;
  881. public static void glTexStorage1D(TextureTarget target, uint levels, SizedInternalFormat internalformat, uint width)
  882. => p_glTexStorage1D(target, levels, internalformat, width);
  883. [UnmanagedFunctionPointer(CallConv)]
  884. private delegate void glTexStorage2D_t(
  885. TextureTarget target,
  886. uint levels,
  887. SizedInternalFormat internalformat,
  888. uint width,
  889. uint height);
  890. private static glTexStorage2D_t p_glTexStorage2D;
  891. public static void glTexStorage2D(
  892. TextureTarget target,
  893. uint levels,
  894. SizedInternalFormat internalformat,
  895. uint width,
  896. uint height) => p_glTexStorage2D(target, levels, internalformat, width, height);
  897. [UnmanagedFunctionPointer(CallConv)]
  898. private delegate void glTexStorage3D_t(
  899. TextureTarget target,
  900. uint levels,
  901. SizedInternalFormat internalformat,
  902. uint width,
  903. uint height,
  904. uint depth);
  905. private static glTexStorage3D_t p_glTexStorage3D;
  906. public static void glTexStorage3D(
  907. TextureTarget target,
  908. uint levels,
  909. SizedInternalFormat internalformat,
  910. uint width,
  911. uint height,
  912. uint depth) => p_glTexStorage3D(target, levels, internalformat, width, height, depth);
  913. [UnmanagedFunctionPointer(CallConv)]
  914. private delegate void glTextureStorage1D_t(
  915. uint texture,
  916. uint levels,
  917. SizedInternalFormat internalformat,
  918. uint width);
  919. private static glTextureStorage1D_t p_glTextureStorage1D;
  920. public static void glTextureStorage1D(uint texture, uint levels, SizedInternalFormat internalformat, uint width)
  921. => p_glTextureStorage1D(texture, levels, internalformat, width);
  922. [UnmanagedFunctionPointer(CallConv)]
  923. private delegate void glTextureStorage2D_t(
  924. uint texture,
  925. uint levels,
  926. SizedInternalFormat internalformat,
  927. uint width,
  928. uint height);
  929. private static glTextureStorage2D_t p_glTextureStorage2D;
  930. public static void glTextureStorage2D(
  931. uint texture,
  932. uint levels,
  933. SizedInternalFormat internalformat,
  934. uint width,
  935. uint height) => p_glTextureStorage2D(texture, levels, internalformat, width, height);
  936. [UnmanagedFunctionPointer(CallConv)]
  937. private delegate void glTextureStorage3D_t(
  938. uint texture,
  939. uint levels,
  940. SizedInternalFormat internalformat,
  941. uint width,
  942. uint height,
  943. uint depth);
  944. private static glTextureStorage3D_t p_glTextureStorage3D;
  945. public static void glTextureStorage3D(
  946. uint texture,
  947. uint levels,
  948. SizedInternalFormat internalformat,
  949. uint width,
  950. uint height,
  951. uint depth) => p_glTextureStorage3D(texture, levels, internalformat, width, height, depth);
  952. [UnmanagedFunctionPointer(CallConv)]
  953. private delegate void glTextureStorage2DMultisample_t(
  954. uint texture,
  955. uint samples,
  956. SizedInternalFormat internalformat,
  957. uint width,
  958. uint height,
  959. GLboolean fixedsamplelocations);
  960. private static glTextureStorage2DMultisample_t p_glTextureStorage2DMultisample;
  961. public static void glTextureStorage2DMultisample(
  962. uint texture,
  963. uint samples,
  964. SizedInternalFormat internalformat,
  965. uint width,
  966. uint height,
  967. GLboolean fixedsamplelocations)
  968. => p_glTextureStorage2DMultisample(texture, samples, internalformat, width, height, fixedsamplelocations);
  969. [UnmanagedFunctionPointer(CallConv)]
  970. private delegate void glTextureStorage3DMultisample_t(
  971. uint texture,
  972. uint samples,
  973. SizedInternalFormat internalformat,
  974. uint width,
  975. uint height,
  976. uint depth,
  977. GLboolean fixedsamplelocations);
  978. private static glTextureStorage3DMultisample_t p_glTextureStorage3DMultisample;
  979. public static void glTextureStorage3DMultisample(
  980. uint texture,
  981. uint samples,
  982. SizedInternalFormat internalformat,
  983. uint width,
  984. uint height,
  985. uint depth,
  986. GLboolean fixedsamplelocations)
  987. => p_glTextureStorage3DMultisample(texture, samples, internalformat, width, height, depth, fixedsamplelocations);
  988. [UnmanagedFunctionPointer(CallConv)]
  989. private delegate void glTexStorage2DMultisample_t(
  990. TextureTarget target,
  991. uint samples,
  992. SizedInternalFormat internalformat,
  993. uint width,
  994. uint height,
  995. GLboolean fixedsamplelocations);
  996. private static glTexStorage2DMultisample_t p_glTexStorage2DMultisample;
  997. public static void glTexStorage2DMultisample(
  998. TextureTarget target,
  999. uint samples,
  1000. SizedInternalFormat internalformat,
  1001. uint width,
  1002. uint height,
  1003. GLboolean fixedsamplelocations)
  1004. => p_glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
  1005. [UnmanagedFunctionPointer(CallConv)]
  1006. private delegate void glTexStorage3DMultisample_t(
  1007. TextureTarget target,
  1008. uint samples,
  1009. SizedInternalFormat internalformat,
  1010. uint width,
  1011. uint height,
  1012. uint depth,
  1013. GLboolean fixedsamplelocations);
  1014. private static glTexStorage3DMultisample_t p_glTexStorage3DMultisample;
  1015. public static void glTexStorage3DMultisample(
  1016. TextureTarget target,
  1017. uint samples,
  1018. SizedInternalFormat internalformat,
  1019. uint width,
  1020. uint height,
  1021. uint depth,
  1022. GLboolean fixedsamplelocations)
  1023. => p_glTexStorage3DMultisample(target, samples, internalformat, width, height, depth, fixedsamplelocations);
  1024. [UnmanagedFunctionPointer(CallConv)]
  1025. private delegate void glTextureView_t(
  1026. uint texture,
  1027. TextureTarget target,
  1028. uint origtexture,
  1029. PixelInternalFormat internalformat,
  1030. uint minlevel,
  1031. uint numlevels,
  1032. uint minlayer,
  1033. uint numlayers);
  1034. private static glTextureView_t p_glTextureView;
  1035. public static void glTextureView(
  1036. uint texture,
  1037. TextureTarget target,
  1038. uint origtexture,
  1039. PixelInternalFormat internalformat,
  1040. uint minlevel,
  1041. uint numlevels,
  1042. uint minlayer,
  1043. uint numlayers)
  1044. => p_glTextureView(texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
  1045. [UnmanagedFunctionPointer(CallConv)]
  1046. private delegate void* glMapBuffer_t(BufferTarget target, BufferAccess access);
  1047. private static glMapBuffer_t p_glMapBuffer;
  1048. public static void* glMapBuffer(BufferTarget target, BufferAccess access) => p_glMapBuffer(target, access);
  1049. [UnmanagedFunctionPointer(CallConv)]
  1050. private delegate void* glMapNamedBuffer_t(uint buffer, BufferAccess access);
  1051. private static glMapNamedBuffer_t p_glMapNamedBuffer;
  1052. public static void* glMapNamedBuffer(uint buffer, BufferAccess access) => p_glMapNamedBuffer(buffer, access);
  1053. [UnmanagedFunctionPointer(CallConv)]
  1054. private delegate GLboolean glUnmapBuffer_t(BufferTarget target);
  1055. private static glUnmapBuffer_t p_glUnmapBuffer;
  1056. public static GLboolean glUnmapBuffer(BufferTarget target) => p_glUnmapBuffer(target);
  1057. [UnmanagedFunctionPointer(CallConv)]
  1058. private delegate GLboolean glUnmapNamedBuffer_t(uint buffer);
  1059. private static glUnmapNamedBuffer_t p_glUnmapNamedBuffer;
  1060. public static GLboolean glUnmapNamedBuffer(uint buffer) => p_glUnmapNamedBuffer(buffer);
  1061. [UnmanagedFunctionPointer(CallConv)]
  1062. private delegate void glCopyBufferSubData_t(
  1063. BufferTarget readTarget,
  1064. BufferTarget writeTarget,
  1065. IntPtr readOffset,
  1066. IntPtr writeOffset,
  1067. IntPtr size);
  1068. private static glCopyBufferSubData_t p_glCopyBufferSubData;
  1069. public static void glCopyBufferSubData(
  1070. BufferTarget readTarget,
  1071. BufferTarget writeTarget,
  1072. IntPtr readOffset,
  1073. IntPtr writeOffset,
  1074. IntPtr size) => p_glCopyBufferSubData(readTarget, writeTarget, readOffset, writeOffset, size);
  1075. [UnmanagedFunctionPointer(CallConv)]
  1076. private delegate void glCopyTexSubImage2D_t(
  1077. TextureTarget target,
  1078. int level,
  1079. int xoffset,
  1080. int yoffset,
  1081. int x,
  1082. int y,
  1083. uint width,
  1084. uint height);
  1085. private static glCopyTexSubImage2D_t p_glCopyTexSubImage2D;
  1086. public static void glCopyTexSubImage2D(
  1087. TextureTarget target,
  1088. int level,
  1089. int xoffset,
  1090. int yoffset,
  1091. int x,
  1092. int y,
  1093. uint width,
  1094. uint height) => p_glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
  1095. [UnmanagedFunctionPointer(CallConv)]
  1096. private delegate void glCopyTexSubImage3D_t(
  1097. TextureTarget target,
  1098. int level,
  1099. int xoffset,
  1100. int yoffset,
  1101. int zoffset,
  1102. int x,
  1103. int y,
  1104. uint width,
  1105. uint height);
  1106. private static glCopyTexSubImage3D_t p_glCopyTexSubImage3D;
  1107. public static void glCopyTexSubImage3D(
  1108. TextureTarget target,
  1109. int level,
  1110. int xoffset,
  1111. int yoffset,
  1112. int zoffset,
  1113. int x,
  1114. int y,
  1115. uint width,
  1116. uint height) => p_glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height);
  1117. [UnmanagedFunctionPointer(CallConv)]
  1118. private delegate void* glMapBufferRange_t(BufferTarget target, IntPtr offset, IntPtr length, BufferAccessMask access);
  1119. private static glMapBufferRange_t p_glMapBufferRange;
  1120. public static void* glMapBufferRange(BufferTarget target, IntPtr offset, IntPtr length, BufferAccessMask access)
  1121. => p_glMapBufferRange(target, offset, length, access);
  1122. [UnmanagedFunctionPointer(CallConv)]
  1123. private delegate void* glMapNamedBufferRange_t(uint buffer, IntPtr offset, uint length, BufferAccessMask access);
  1124. private static glMapNamedBufferRange_t p_glMapNamedBufferRange;
  1125. public static void* glMapNamedBufferRange(uint buffer, IntPtr offset, uint length, BufferAccessMask access)
  1126. => p_glMapNamedBufferRange(buffer, offset, length, access);
  1127. [UnmanagedFunctionPointer(CallConv)]
  1128. private delegate void glGetTexImage_t(
  1129. TextureTarget target,
  1130. int level,
  1131. GLPixelFormat format,
  1132. GLPixelType type,
  1133. void* pixels);
  1134. private static glGetTexImage_t p_glGetTexImage;
  1135. public static void glGetTexImage(TextureTarget target, int level, GLPixelFormat format, GLPixelType type, void* pixels)
  1136. => p_glGetTexImage(target, level, format, type, pixels);
  1137. [UnmanagedFunctionPointer(CallConv)]
  1138. private delegate void glGetTextureSubImage_t(
  1139. uint texture,
  1140. int level,
  1141. int xoffset,
  1142. int yoffset,
  1143. int zoffset,
  1144. uint width,
  1145. uint height,
  1146. uint depth,
  1147. GLPixelFormat format,
  1148. GLPixelType type,
  1149. uint bufSize,
  1150. void* pixels);
  1151. private static glGetTextureSubImage_t p_glGetTextureSubImage;
  1152. public static void glGetTextureSubImage(
  1153. uint texture,
  1154. int level,
  1155. int xoffset,
  1156. int yoffset,
  1157. int zoffset,
  1158. uint width,
  1159. uint height,
  1160. uint depth,
  1161. GLPixelFormat format,
  1162. GLPixelType type,
  1163. uint bufSize,
  1164. void* pixels)
  1165. => p_glGetTextureSubImage(
  1166. texture,
  1167. level,
  1168. xoffset,
  1169. yoffset,
  1170. zoffset,
  1171. width,
  1172. height,
  1173. depth,
  1174. format,
  1175. type,
  1176. bufSize,
  1177. pixels);
  1178. [UnmanagedFunctionPointer(CallConv)]
  1179. private delegate void glCopyNamedBufferSubData_t(
  1180. uint readBuffer,
  1181. uint writeBuffer,
  1182. IntPtr readOffset,
  1183. IntPtr writeOffset,
  1184. uint size);
  1185. private static glCopyNamedBufferSubData_t p_glCopyNamedBufferSubData;
  1186. public static void glCopyNamedBufferSubData(
  1187. uint readBuffer,
  1188. uint writeBuffer,
  1189. IntPtr readOffset,
  1190. IntPtr writeOffset,
  1191. uint size) => p_glCopyNamedBufferSubData(readBuffer, writeBuffer, readOffset, writeOffset, size);
  1192. [UnmanagedFunctionPointer(CallConv)]
  1193. private delegate void glCreateBuffers_t(uint n, uint* buffers);
  1194. private static glCreateBuffers_t p_glCreateBuffers;
  1195. public static void glCreateBuffers(uint n, uint* buffers) => p_glCreateBuffers(n, buffers);
  1196. [UnmanagedFunctionPointer(CallConv)]
  1197. private delegate void glCreateTextures_t(TextureTarget target, uint n, uint* textures);
  1198. private static glCreateTextures_t p_glCreateTextures;
  1199. public static void glCreateTextures(TextureTarget target, uint n, uint* textures)
  1200. => p_glCreateTextures(target, n, textures);
  1201. [UnmanagedFunctionPointer(CallConv)]
  1202. private delegate void glCompressedTexSubImage1D_t(
  1203. TextureTarget target,
  1204. int level,
  1205. int xoffset,
  1206. uint width,
  1207. PixelInternalFormat internalformat,
  1208. uint imageSize,
  1209. void* data);
  1210. private static glCompressedTexSubImage1D_t p_glCompressedTexSubImage1D;
  1211. public static void glCompressedTexSubImage1D(
  1212. TextureTarget target,
  1213. int level,
  1214. int xoffset,
  1215. uint width,
  1216. PixelInternalFormat internalformat,
  1217. uint imageSize,
  1218. void* data) => p_glCompressedTexSubImage1D(target, level, xoffset, width, internalformat, imageSize, data);
  1219. [UnmanagedFunctionPointer(CallConv)]
  1220. private delegate void glCompressedTexSubImage2D_t(
  1221. TextureTarget target,
  1222. int level,
  1223. int xoffset,
  1224. int yoffset,
  1225. uint width,
  1226. uint height,
  1227. PixelInternalFormat format,
  1228. uint imageSize,
  1229. void* data);
  1230. private static glCompressedTexSubImage2D_t p_glCompressedTexSubImage2D;
  1231. public static void glCompressedTexSubImage2D(
  1232. TextureTarget target,
  1233. int level,
  1234. int xoffset,
  1235. int yoffset,
  1236. uint width,
  1237. uint height,
  1238. PixelInternalFormat format,
  1239. uint imageSize,
  1240. void* data) => p_glCompressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, imageSize, data);
  1241. [UnmanagedFunctionPointer(CallConv)]
  1242. private delegate void glCompressedTexSubImage3D_t(
  1243. TextureTarget target,
  1244. int level,
  1245. int xoffset,
  1246. int yoffset,
  1247. int zoffset,
  1248. uint width,
  1249. uint height,
  1250. uint depth,
  1251. PixelInternalFormat format,
  1252. uint imageSize,
  1253. void* data);
  1254. private static glCompressedTexSubImage3D_t p_glCompressedTexSubImage3D;
  1255. public static void glCompressedTexSubImage3D(
  1256. TextureTarget target,
  1257. int level,
  1258. int xoffset,
  1259. int yoffset,
  1260. int zoffset,
  1261. uint width,
  1262. uint height,
  1263. uint depth,
  1264. PixelInternalFormat format,
  1265. uint imageSize,
  1266. void* data)
  1267. => p_glCompressedTexSubImage3D(
  1268. target,
  1269. level,
  1270. xoffset,
  1271. yoffset,
  1272. zoffset,
  1273. width,
  1274. height,
  1275. depth,
  1276. format,
  1277. imageSize,
  1278. data);
  1279. [UnmanagedFunctionPointer(CallConv)]
  1280. private delegate void glCopyImageSubData_t(
  1281. uint srcName,
  1282. TextureTarget srcTarget,
  1283. int srcLevel,
  1284. int srcX,
  1285. int srcY,
  1286. int srcZ,
  1287. uint dstName,
  1288. TextureTarget dstTarget,
  1289. int dstLevel,
  1290. int dstX,
  1291. int dstY,
  1292. int dstZ,
  1293. uint srcWidth,
  1294. uint srcHeight,
  1295. uint srcDepth);
  1296. private static glCopyImageSubData_t p_glCopyImageSubData;
  1297. public static void glCopyImageSubData(
  1298. uint srcName,
  1299. TextureTarget srcTarget,
  1300. int srcLevel,
  1301. int srcX,
  1302. int srcY,
  1303. int srcZ,
  1304. uint dstName,
  1305. TextureTarget dstTarget,
  1306. int dstLevel,
  1307. int dstX,
  1308. int dstY,
  1309. int dstZ,
  1310. uint srcWidth,
  1311. uint srcHeight,
  1312. uint srcDepth) => p_glCopyImageSubData(
  1313. srcName, srcTarget,
  1314. srcLevel, srcX, srcY, srcZ,
  1315. dstName, dstTarget,
  1316. dstLevel, dstX, dstY, dstZ,
  1317. srcWidth, srcHeight, srcDepth);
  1318. [UnmanagedFunctionPointer(CallConv)]
  1319. private delegate void glStencilFuncSeparate_t(CullFaceMode face, StencilFunction func, int @ref, uint mask);
  1320. private static glStencilFuncSeparate_t p_glStencilFuncSeparate;
  1321. public static void glStencilFuncSeparate(CullFaceMode face, StencilFunction func, int @ref, uint mask)
  1322. => p_glStencilFuncSeparate(face, func, @ref, mask);
  1323. [UnmanagedFunctionPointer(CallConv)]
  1324. private delegate void glStencilOpSeparate_t(
  1325. CullFaceMode face,
  1326. StencilOp sfail,
  1327. StencilOp dpfail,
  1328. StencilOp dppass);
  1329. private static glStencilOpSeparate_t p_glStencilOpSeparate;
  1330. public static void glStencilOpSeparate(
  1331. CullFaceMode face,
  1332. StencilOp sfail,
  1333. StencilOp dpfail,
  1334. StencilOp dppass) => p_glStencilOpSeparate(face, sfail, dpfail, dppass);
  1335. [UnmanagedFunctionPointer(CallConv)]
  1336. private delegate void glStencilMask_t(uint mask);
  1337. private static glStencilMask_t p_glStencilMask;
  1338. public static void glStencilMask(uint mask) => p_glStencilMask(mask);
  1339. [UnmanagedFunctionPointer(CallConv)]
  1340. private delegate void glClearStencil_t(int s);
  1341. private static glClearStencil_t p_glClearStencil;
  1342. public static void glClearStencil(int s) => p_glClearStencil(s);
  1343. [UnmanagedFunctionPointer(CallConv)]
  1344. private delegate void glGetActiveUniformBlockiv_t(
  1345. uint program,
  1346. uint uniformBlockIndex,
  1347. ActiveUniformBlockParameter pname,
  1348. int* @params);
  1349. private static glGetActiveUniformBlockiv_t p_glGetActiveUniformBlockiv;
  1350. public static void glGetActiveUniformBlockiv(
  1351. uint program,
  1352. uint uniformBlockIndex,
  1353. ActiveUniformBlockParameter pname,
  1354. int* @params) => p_glGetActiveUniformBlockiv(program, uniformBlockIndex, pname, @params);
  1355. [UnmanagedFunctionPointer(CallConv)]
  1356. private delegate void glGetActiveUniformBlockName_t(
  1357. uint program,
  1358. uint uniformBlockIndex,
  1359. uint bufSize,
  1360. uint* length,
  1361. byte* uniformBlockName);
  1362. private static glGetActiveUniformBlockName_t p_glGetActiveUniformBlockName;
  1363. public static void glGetActiveUniformBlockName(
  1364. uint program,
  1365. uint uniformBlockIndex,
  1366. uint bufSize,
  1367. uint* length,
  1368. byte* uniformBlockName) => p_glGetActiveUniformBlockName(program, uniformBlockIndex, bufSize, length, uniformBlockName);
  1369. [UnmanagedFunctionPointer(CallConv)]
  1370. private delegate void glGetActiveUniform_t(
  1371. uint program,
  1372. uint index,
  1373. uint bufSize,
  1374. uint* length,
  1375. int* size,
  1376. uint* type,
  1377. byte* name);
  1378. private static glGetActiveUniform_t p_glGetActiveUniform;
  1379. public static void glGetActiveUniform(
  1380. uint program,
  1381. uint index,
  1382. uint bufSize,
  1383. uint* length,
  1384. int* size,
  1385. uint* type,
  1386. byte* name) => p_glGetActiveUniform(program, index, bufSize, length, size, type, name);
  1387. [UnmanagedFunctionPointer(CallConv)]
  1388. private delegate void glGetCompressedTexImage_t(TextureTarget target, int level, void* pixels);
  1389. private static glGetCompressedTexImage_t p_glGetCompressedTexImage;
  1390. public static void glGetCompressedTexImage(TextureTarget target, int level, void* pixels)
  1391. => p_glGetCompressedTexImage(target, level, pixels);
  1392. [UnmanagedFunctionPointer(CallConv)]
  1393. private delegate void glGetCompressedTextureImage_t(uint texture, int level, uint bufSize, void* pixels);
  1394. private static glGetCompressedTextureImage_t p_glGetCompressedTextureImage;
  1395. public static void glGetCompressedTextureImage(uint texture, int level, uint bufSize, void* pixels)
  1396. => p_glGetCompressedTextureImage(texture, level, bufSize, pixels);
  1397. [UnmanagedFunctionPointer(CallConv)]
  1398. private delegate void glGetTexLevelParameteriv_t(
  1399. TextureTarget target,
  1400. int level,
  1401. GetTextureParameter pname,
  1402. int* @params);
  1403. private static glGetTexLevelParameteriv_t p_glGetTexLevelParameteriv;
  1404. public static void glGetTexLevelParameteriv(
  1405. TextureTarget target,
  1406. int level,
  1407. GetTextureParameter pname,
  1408. int* @params) => p_glGetTexLevelParameteriv(target, level, pname, @params);
  1409. [UnmanagedFunctionPointer(CallConv)]
  1410. private delegate void glFramebufferRenderbuffer_t(
  1411. FramebufferTarget target,
  1412. GLFramebufferAttachment attachment,
  1413. RenderbufferTarget renderbuffertarget,
  1414. uint renderbuffer);
  1415. private static glFramebufferRenderbuffer_t p_glFramebufferRenderbuffer;
  1416. public static void glFramebufferRenderbuffer(
  1417. FramebufferTarget target,
  1418. GLFramebufferAttachment attachment,
  1419. RenderbufferTarget renderbuffertarget,
  1420. uint renderbuffer)
  1421. => p_glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
  1422. [UnmanagedFunctionPointer(CallConv)]
  1423. private delegate void glRenderbufferStorage_t(
  1424. RenderbufferTarget target,
  1425. uint internalformat,
  1426. uint width,
  1427. uint height);
  1428. private static glRenderbufferStorage_t p_glRenderbufferStorage;
  1429. public static void glRenderbufferStorage(
  1430. RenderbufferTarget target,
  1431. uint internalFormat,
  1432. uint width,
  1433. uint height) => p_glRenderbufferStorage(target, internalFormat, width, height);
  1434. [UnmanagedFunctionPointer(CallConv)]
  1435. private delegate void glGetRenderbufferParameteriv_t(
  1436. RenderbufferTarget target,
  1437. RenderbufferPname pname,
  1438. out int parameters);
  1439. private static glGetRenderbufferParameteriv_t p_glGetRenderbufferParameteriv;
  1440. public static void glGetRenderbufferParameteriv(
  1441. RenderbufferTarget target,
  1442. RenderbufferPname pname,
  1443. out int parameters) => p_glGetRenderbufferParameteriv(target, pname, out parameters);
  1444. [UnmanagedFunctionPointer(CallConv)]
  1445. private delegate void glGenRenderbuffers_t(uint count, out uint names);
  1446. private static glGenRenderbuffers_t p_glGenRenderbuffers;
  1447. public static void glGenRenderbuffers(uint count, out uint names)
  1448. => p_glGenRenderbuffers(count, out names);
  1449. [UnmanagedFunctionPointer(CallConv)]
  1450. private delegate void glBindRenderbuffer_t(RenderbufferTarget bindPoint, uint name);
  1451. private static glBindRenderbuffer_t p_glBindRenderbuffer;
  1452. public static void glBindRenderbuffer(RenderbufferTarget bindPoint, uint name)
  1453. => p_glBindRenderbuffer(bindPoint, name);
  1454. [UnmanagedFunctionPointer(CallConv)]
  1455. private delegate void glGenerateMipmap_t(TextureTarget target);
  1456. private static glGenerateMipmap_t p_glGenerateMipmap;
  1457. public static void glGenerateMipmap(TextureTarget target) => p_glGenerateMipmap(target);
  1458. [UnmanagedFunctionPointer(CallConv)]
  1459. private delegate void glGenerateTextureMipmap_t(uint texture);
  1460. private static glGenerateTextureMipmap_t p_glGenerateTextureMipmap;
  1461. public static void glGenerateTextureMipmap(uint texture) => p_glGenerateTextureMipmap(texture);
  1462. [UnmanagedFunctionPointer(CallConv)]
  1463. private delegate void glClipControl_t(ClipControlOrigin origin, ClipControlDepthRange depth);
  1464. private static glClipControl_t p_glClipControl;
  1465. public static void glClipControl(ClipControlOrigin origin, ClipControlDepthRange depth)
  1466. => p_glClipControl(origin, depth);
  1467. [UnmanagedFunctionPointer(CallConv)]
  1468. private delegate void glGetFramebufferAttachmentParameteriv_t(
  1469. FramebufferTarget target,
  1470. GLFramebufferAttachment attachment,
  1471. FramebufferParameterName pname,
  1472. int* @params);
  1473. private static glGetFramebufferAttachmentParameteriv_t p_glGetFramebufferAttachmentParameteriv;
  1474. public static void glGetFramebufferAttachmentParameteriv(
  1475. FramebufferTarget target,
  1476. GLFramebufferAttachment attachment,
  1477. FramebufferParameterName pname,
  1478. int* @params) => p_glGetFramebufferAttachmentParameteriv(target, attachment, pname, @params);
  1479. [UnmanagedFunctionPointer(CallConv)]
  1480. private delegate void glFlush_t();
  1481. private static glFlush_t p_glFlush;
  1482. public static void glFlush() => p_glFlush();
  1483. [UnmanagedFunctionPointer(CallConv)]
  1484. private delegate void glFinish_t();
  1485. private static glFinish_t p_glFinish;
  1486. public static void glFinish() => p_glFinish();
  1487. [UnmanagedFunctionPointer(CallConv)]
  1488. private delegate void glPushDebugGroup_t(DebugSource source, uint id, uint length, byte* message);
  1489. private static glPushDebugGroup_t p_glPushDebugGroup;
  1490. public static void glPushDebugGroup(DebugSource source, uint id, uint length, byte* message)
  1491. => p_glPushDebugGroup(source, id, length, message);
  1492. [UnmanagedFunctionPointer(CallConv)]
  1493. private delegate void glPopDebugGroup_t();
  1494. private static glPopDebugGroup_t p_glPopDebugGroup;
  1495. public static void glPopDebugGroup() => p_glPopDebugGroup();
  1496. [UnmanagedFunctionPointer(CallConv)]
  1497. private delegate void glDebugMessageInsert_t(
  1498. DebugSource source,
  1499. DebugType type,
  1500. uint id,
  1501. DebugSeverity severity,
  1502. uint length,
  1503. byte* message);
  1504. private static glDebugMessageInsert_t p_glDebugMessageInsert;
  1505. public static void glDebugMessageInsert(
  1506. DebugSource source,
  1507. DebugType type,
  1508. uint id,
  1509. DebugSeverity severity,
  1510. uint length,
  1511. byte* message) => p_glDebugMessageInsert(source, type, id, severity, length, message);
  1512. [UnmanagedFunctionPointer(CallConv)]
  1513. private delegate void glInsertEventMarker_t(uint length, byte* marker);
  1514. private static glInsertEventMarker_t p_glInsertEventMarker;
  1515. public static void glInsertEventMarker(uint length, byte* marker) => p_glInsertEventMarker(length, marker);
  1516. [UnmanagedFunctionPointer(CallConv)]
  1517. private delegate void glPushGroupMarkerEXT_t(uint length, byte* marker);
  1518. private static glPushGroupMarkerEXT_t p_glPushGroupMarker;
  1519. public static void glPushGroupMarker(uint length, byte* marker) => p_glPushGroupMarker(length, marker);
  1520. [UnmanagedFunctionPointer(CallConv)]
  1521. private delegate void glPopGroupMarkerEXT_t();
  1522. private static glPopGroupMarkerEXT_t p_glPopGroupMarker;
  1523. public static void glPopGroupMarker() => p_glPopGroupMarker();
  1524. [UnmanagedFunctionPointer(CallConv)]
  1525. private delegate void glReadPixels_t(
  1526. int x,
  1527. int y,
  1528. uint width,
  1529. uint height,
  1530. GLPixelFormat format,
  1531. GLPixelType type,
  1532. void* data);
  1533. private static glReadPixels_t p_glReadPixels;
  1534. public static void glReadPixels(
  1535. int x,
  1536. int y,
  1537. uint width,
  1538. uint height,
  1539. GLPixelFormat format,
  1540. GLPixelType type,
  1541. void* data) => p_glReadPixels(x, y, width, height, format, type, data);
  1542. public static void LoadGetString(IntPtr glContext, Func<string, IntPtr> getProcAddress)
  1543. {
  1544. s_getProcAddress = getProcAddress;
  1545. LoadFunction("glGetString", out p_glGetString);
  1546. }
  1547. public static void LoadAllFunctions(IntPtr glContext, Func<string, IntPtr> getProcAddress, bool gles)
  1548. {
  1549. s_getProcAddress = getProcAddress;
  1550. // Common functions
  1551. LoadFunction("glCompressedTexSubImage2D", out p_glCompressedTexSubImage2D);
  1552. LoadFunction("glCompressedTexSubImage3D", out p_glCompressedTexSubImage3D);
  1553. LoadFunction("glStencilFuncSeparate", out p_glStencilFuncSeparate);
  1554. LoadFunction("glStencilOpSeparate", out p_glStencilOpSeparate);
  1555. LoadFunction("glStencilMask", out p_glStencilMask);
  1556. LoadFunction("glClearStencil", out p_glClearStencil);
  1557. LoadFunction("glGetActiveUniformBlockiv", out p_glGetActiveUniformBlockiv);
  1558. LoadFunction("glGetActiveUniformBlockName", out p_glGetActiveUniformBlockName);
  1559. LoadFunction("glGetActiveUniform", out p_glGetActiveUniform);
  1560. LoadFunction("glGetCompressedTexImage", out p_glGetCompressedTexImage);
  1561. LoadFunction("glGetCompressedTextureImage", out p_glGetCompressedTextureImage);
  1562. LoadFunction("glGetTexLevelParameteriv", out p_glGetTexLevelParameteriv);
  1563. LoadFunction("glTexImage1D", out p_glTexImage1D);
  1564. LoadFunction("glCompressedTexImage1D", out p_glCompressedTexSubImage1D);
  1565. LoadFunction("glGenVertexArrays", out p_glGenVertexArrays);
  1566. LoadFunction("glGetError", out p_glGetError);
  1567. LoadFunction("glBindVertexArray", out p_glBindVertexArray);
  1568. LoadFunction("glClearColor", out p_glClearColor);
  1569. LoadFunction("glDrawBuffer", out p_glDrawBuffer);
  1570. LoadFunction("glDrawBuffers", out p_glDrawBuffers);
  1571. LoadFunction("glClear", out p_glClear);
  1572. LoadFunction("glClearDepth", out p_glClearDepth);
  1573. LoadFunction("glClearDepthf", out p_glClearDepthf);
  1574. if (p_glClearDepthf != null) { p_glClearDepthf_Compat = p_glClearDepthf; }
  1575. else { p_glClearDepthf_Compat = depth => p_glClearDepth(depth); }
  1576. LoadFunction("glDrawElements", out p_glDrawElements);
  1577. LoadFunction("glDrawElementsBaseVertex", out p_glDrawElementsBaseVertex);
  1578. LoadFunction("glDrawElementsInstanced", out p_glDrawElementsInstanced);
  1579. LoadFunction("glDrawElementsInstancedBaseVertex", out p_glDrawElementsInstancedBaseVertex);
  1580. LoadFunction("glDrawArrays", out p_glDrawArrays);
  1581. LoadFunction("glDrawArraysInstanced", out p_glDrawArraysInstanced);
  1582. LoadFunction("glDrawArraysInstancedBaseInstance", out p_glDrawArraysInstancedBaseInstance);
  1583. LoadFunction("glGenBuffers", out p_glGenBuffers);
  1584. LoadFunction("glDeleteBuffers", out p_glDeleteBuffers);
  1585. LoadFunction("glGenFramebuffers", out p_glGenFramebuffers);
  1586. LoadFunction("glActiveTexture", out p_glActiveTexture);
  1587. LoadFunction("glFramebufferTexture2D", out p_glFramebufferTexture2D);
  1588. LoadFunction("glBindTexture", out p_glBindTexture);
  1589. LoadFunction("glBindFramebuffer", out p_glBindFramebuffer);
  1590. LoadFunction("glDeleteFramebuffers", out p_glDeleteFramebuffers);
  1591. LoadFunction("glGenTextures", out p_glGenTextures);
  1592. LoadFunction("glDeleteTextures", out p_glDeleteTextures);
  1593. LoadFunction("glCheckFramebufferStatus", out p_glCheckFramebufferStatus);
  1594. LoadFunction("glBindBuffer", out p_glBindBuffer);
  1595. LoadFunction("glDepthRangeIndexed", out p_glDepthRangeIndexed);
  1596. LoadFunction("glBufferSubData", out p_glBufferSubData);
  1597. LoadFunction("glNamedBufferSubData", out p_glNamedBufferSubData);
  1598. LoadFunction("glScissorIndexed", out p_glScissorIndexed);
  1599. LoadFunction("glTexSubImage1D", out p_glTexSubImage1D);
  1600. LoadFunction("glTexSubImage2D", out p_glTexSubImage2D);
  1601. LoadFunction("glTexSubImage3D", out p_glTexSubImage3D);
  1602. LoadFunction("glPixelStorei", out p_glPixelStorei);
  1603. LoadFunction("glShaderSource", out p_glShaderSource);
  1604. LoadFunction("glCreateShader", out p_glCreateShader);
  1605. LoadFunction("glCompileShader", out p_glCompileShader);
  1606. LoadFunction("glGetShaderiv", out p_glGetShaderiv);
  1607. LoadFunction("glGetShaderInfoLog", out p_glGetShaderInfoLog);
  1608. LoadFunction("glDeleteShader", out p_glDeleteShader);
  1609. LoadFunction("glGenSamplers", out p_glGenSamplers);
  1610. LoadFunction("glSamplerParameterf", out p_glSamplerParameterf);
  1611. LoadFunction("glSamplerParameteri", out p_glSamplerParameteri);
  1612. LoadFunction("glSamplerParameterfv", out p_glSamplerParameterfv);
  1613. LoadFunction("glBindSampler", out p_glBindSampler);
  1614. LoadFunction("glDeleteSamplers", out p_glDeleteSamplers);
  1615. LoadFunction("glColorMaski", out p_glColorMaski);
  1616. LoadFunction("glColorMask", out p_glColorMask);
  1617. LoadFunction("glBlendFuncSeparatei", out p_glBlendFuncSeparatei);
  1618. LoadFunction("glBlendFuncSeparate", out p_glBlendFuncSeparate);
  1619. LoadFunction("glEnable", out p_glEnable);
  1620. LoadFunction("glEnablei", out p_glEnablei);
  1621. LoadFunction("glDisable", out p_glDisable);
  1622. LoadFunction("glDisablei", out p_glDisablei);
  1623. LoadFunction("glBlendEquationSeparatei", out p_glBlendEquationSeparatei);
  1624. LoadFunction("glBlendEquationSeparate", out p_glBlendEquationSeparate);
  1625. LoadFunction("glBlendColor", out p_glBlendColor);
  1626. LoadFunction("glDepthFunc", out p_glDepthFunc);
  1627. LoadFunction("glDepthMask", out p_glDepthMask);
  1628. LoadFunction("glCullFace", out p_glCullFace);
  1629. LoadFunction("glCreateProgram", out p_glCreateProgram);
  1630. LoadFunction("glAttachShader", out p_glAttachShader);
  1631. LoadFunction("glBindAttribLocation", out p_glBindAttribLocation);
  1632. LoadFunction("glLinkProgram", out p_glLinkProgram);
  1633. LoadFunction("glGetProgramiv", out p_glGetProgramiv);
  1634. LoadFunction("glGetProgramInfoLog", out p_glGetProgramInfoLog);
  1635. LoadFunction("glUniformBlockBinding", out p_glUniformBlockBinding);
  1636. LoadFunction("glDeleteProgram", out p_glDeleteProgram);
  1637. LoadFunction("glUniform1i", out p_glUniform1i);
  1638. LoadFunction("glGetUniformBlockIndex", out p_glGetUniformBlockIndex);
  1639. LoadFunction("glGetUniformLocation", out p_glGetUniformLocation);
  1640. LoadFunction("glGetAttribLocation", out p_glGetAttribLocation);
  1641. LoadFunction("glUseProgram", out p_glUseProgram);
  1642. LoadFunction("glBindBufferRange", out p_glBindBufferRange);
  1643. LoadFunction("glDebugMessageCallback", out p_glDebugMessageCallback);
  1644. LoadFunction("glBufferData", out p_glBufferData);
  1645. LoadFunction("glNamedBufferData", out p_glNamedBufferData);
  1646. LoadFunction("glTexImage2D", out p_glTexImage2D);
  1647. LoadFunction("glTexImage3D", out p_glTexImage3D);
  1648. LoadFunction("glEnableVertexAttribArray", out p_glEnableVertexAttribArray);
  1649. LoadFunction("glDisableVertexAttribArray", out p_glDisableVertexAttribArray);
  1650. LoadFunction("glVertexAttribPointer", out p_glVertexAttribPointer);
  1651. LoadFunction("glVertexAttribIPointer", out p_glVertexAttribIPointer);
  1652. LoadFunction("glVertexAttribDivisor", out p_glVertexAttribDivisor);
  1653. LoadFunction("glFrontFace", out p_glFrontFace);
  1654. LoadFunction("glGetIntegerv", out p_glGetIntegerv);
  1655. LoadFunction("glBindTextureUnit", out p_glBindTextureUnit);
  1656. LoadFunction("glTexParameteri", out p_glTexParameteri);
  1657. LoadFunction("glGetStringi", out p_glGetStringi);
  1658. LoadFunction("glObjectLabel", out p_glObjectLabel);
  1659. LoadFunction("glTexImage2DMultisample", out p_glTexImage2DMultisample);
  1660. LoadFunction("glTexImage3DMultisample", out p_glTexImage3DMultisample);
  1661. LoadFunction("glBlitFramebuffer", out p_glBlitFramebuffer);
  1662. LoadFunction("glFramebufferTextureLayer", out p_glFramebufferTextureLayer);
  1663. LoadFunction("glDispatchCompute", out p_glDispatchCompute);
  1664. LoadFunction("glGetProgramResourceIndex", out p_glGetProgramResourceIndex);
  1665. LoadFunction("glShaderStorageBlockBinding", out p_glShaderStorageBlockBinding);
  1666. LoadFunction("glDrawElementsIndirect", out p_glDrawElementsIndirect);
  1667. LoadFunction("glMultiDrawElementsIndirect", out p_glMultiDrawElementsIndirect);
  1668. LoadFunction("glDrawArraysIndirect", out p_glDrawArraysIndirect);
  1669. LoadFunction("glMultiDrawArraysIndirect", out p_glMultiDrawArraysIndirect);
  1670. LoadFunction("glDispatchComputeIndirect", out p_glDispatchComputeIndirect);
  1671. LoadFunction("glBindImageTexture", out p_glBindImageTexture);
  1672. LoadFunction("glMemoryBarrier", out p_glMemoryBarrier);
  1673. LoadFunction("glTexStorage1D", out p_glTexStorage1D);
  1674. LoadFunction("glTexStorage2D", out p_glTexStorage2D);
  1675. LoadFunction("glTexStorage3D", out p_glTexStorage3D);
  1676. LoadFunction("glTextureStorage1D", out p_glTextureStorage1D);
  1677. LoadFunction("glTextureStorage2D", out p_glTextureStorage2D);
  1678. LoadFunction("glTextureStorage3D", out p_glTextureStorage3D);
  1679. LoadFunction("glTextureStorage2DMultisample", out p_glTextureStorage2DMultisample);
  1680. LoadFunction("glTextureStorage3DMultisample", out p_glTextureStorage3DMultisample);
  1681. LoadFunction("glTexStorage2DMultisample", out p_glTexStorage2DMultisample);
  1682. LoadFunction("glTexStorage3DMultisample", out p_glTexStorage3DMultisample);
  1683. LoadFunction("glMapBuffer", out p_glMapBuffer);
  1684. LoadFunction("glMapNamedBuffer", out p_glMapNamedBuffer);
  1685. LoadFunction("glUnmapBuffer", out p_glUnmapBuffer);
  1686. LoadFunction("glUnmapNamedBuffer", out p_glUnmapNamedBuffer);
  1687. LoadFunction("glCopyBufferSubData", out p_glCopyBufferSubData);
  1688. LoadFunction("glCopyTexSubImage2D", out p_glCopyTexSubImage2D);
  1689. LoadFunction("glCopyTexSubImage3D", out p_glCopyTexSubImage3D);
  1690. LoadFunction("glMapBufferRange", out p_glMapBufferRange);
  1691. LoadFunction("glMapNamedBufferRange", out p_glMapNamedBufferRange);
  1692. LoadFunction("glGetTextureSubImage", out p_glGetTextureSubImage);
  1693. LoadFunction("glCopyNamedBufferSubData", out p_glCopyNamedBufferSubData);
  1694. LoadFunction("glCreateBuffers", out p_glCreateBuffers);
  1695. LoadFunction("glCreateTextures", out p_glCreateTextures);
  1696. LoadFunction("glGenerateMipmap", out p_glGenerateMipmap);
  1697. LoadFunction("glGetFramebufferAttachmentParameteriv", out p_glGetFramebufferAttachmentParameteriv);
  1698. LoadFunction("glFlush", out p_glFlush);
  1699. LoadFunction("glFinish", out p_glFinish);
  1700. LoadFunction("glPushDebugGroup", out p_glPushDebugGroup);
  1701. LoadFunction("glPopDebugGroup", out p_glPopDebugGroup);
  1702. LoadFunction("glDebugMessageInsert", out p_glDebugMessageInsert);
  1703. LoadFunction("glReadPixels", out p_glReadPixels);
  1704. if (!gles)
  1705. {
  1706. LoadFunction("glFramebufferTexture1D", out p_glFramebufferTexture1D);
  1707. LoadFunction("glGetTexImage", out p_glGetTexImage);
  1708. LoadFunction("glPolygonMode", out p_glPolygonMode);
  1709. LoadFunction("glViewportIndexedf", out p_glViewportIndexedf);
  1710. LoadFunction("glCopyImageSubData", out p_glCopyImageSubData);
  1711. LoadFunction("glTextureView", out p_glTextureView);
  1712. LoadFunction("glGenerateTextureMipmap", out p_glGenerateTextureMipmap);
  1713. LoadFunction("glClipControl", out p_glClipControl);
  1714. LoadFunction("glDrawElementsInstancedBaseVertexBaseInstance", out p_glDrawElementsInstancedBaseVertexBaseInstance);
  1715. }
  1716. else
  1717. {
  1718. LoadFunction("glViewport", out p_glViewport);
  1719. LoadFunction("glDepthRangef", out p_glDepthRangef);
  1720. LoadFunction("glScissor", out p_glScissor);
  1721. LoadFunction("glCopyImageSubData", out p_glCopyImageSubData);
  1722. if (p_glCopyImageSubData == null)
  1723. {
  1724. LoadFunction("glCopyImageSubDataOES", out p_glCopyImageSubData);
  1725. }
  1726. if (p_glCopyImageSubData == null)
  1727. {
  1728. LoadFunction("glCopyImageSubDataEXT", out p_glCopyImageSubData);
  1729. }
  1730. LoadFunction("glTextureView", out p_glTextureView);
  1731. if(p_glTextureView == null)
  1732. {
  1733. LoadFunction("glTextureViewOES", out p_glTextureView);
  1734. }
  1735. LoadFunction("glRenderbufferStorage", out p_glRenderbufferStorage);
  1736. LoadFunction("glFramebufferRenderbuffer", out p_glFramebufferRenderbuffer);
  1737. LoadFunction("glGetRenderbufferParameteriv", out p_glGetRenderbufferParameteriv);
  1738. LoadFunction("glGenRenderbuffers", out p_glGenRenderbuffers);
  1739. LoadFunction("glBindRenderbuffer", out p_glBindRenderbuffer);
  1740. LoadFunction("glInsertEventMarker", out p_glInsertEventMarker);
  1741. LoadFunction("glPushGroupMarker", out p_glPushGroupMarker);
  1742. LoadFunction("glPopGroupMarker", out p_glPopGroupMarker);
  1743. }
  1744. }
  1745. private static void LoadFunction<T>(string name, out T field)
  1746. {
  1747. IntPtr funcPtr = s_getProcAddress(name);
  1748. if (funcPtr != IntPtr.Zero)
  1749. {
  1750. field = Marshal.GetDelegateForFunctionPointer<T>(funcPtr);
  1751. }
  1752. else
  1753. {
  1754. field = default(T);
  1755. }
  1756. }
  1757. private static void LoadFunction<T>(out T field)
  1758. {
  1759. // Slow version using reflection -- prefer above.
  1760. string name = typeof(T).Name;
  1761. name = name.Substring(0, name.Length - 2); // Remove _t
  1762. LoadFunction(name, out field);
  1763. }
  1764. }
  1765. }