GLAPI.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. * Copyright (c) 2021-2022, Jelle Raaijmakers <jelle@gmta.nl>
  4. * Copyright (c) 2021-2022, Jesse Buhagiar <jooster669@gmail.com>
  5. * Copyright (c) 2021, Stephan Unverwerth <s.unverwerth@serenityos.org>
  6. *
  7. * SPDX-License-Identifier: BSD-2-Clause
  8. */
  9. #include <AK/Array.h>
  10. #include <AK/Debug.h>
  11. #include <LibGL/GL/gl.h>
  12. #include <LibGL/GLContext.h>
  13. extern GL::GLContext* g_gl_context;
  14. // Transposes input matrices (column-major) to our Matrix (row-major).
  15. template<typename I, typename O>
  16. static constexpr Matrix4x4<O> transpose_input_matrix(I const* matrix)
  17. {
  18. if constexpr (IsSame<I, O>) {
  19. // clang-format off
  20. return {
  21. matrix[0], matrix[4], matrix[8], matrix[12],
  22. matrix[1], matrix[5], matrix[9], matrix[13],
  23. matrix[2], matrix[6], matrix[10], matrix[14],
  24. matrix[3], matrix[7], matrix[11], matrix[15],
  25. };
  26. // clang-format on
  27. }
  28. Array<O, 16> elements;
  29. for (size_t i = 0; i < 16; ++i)
  30. elements[i] = static_cast<O>(matrix[i]);
  31. // clang-format off
  32. return {
  33. elements[0], elements[4], elements[8], elements[12],
  34. elements[1], elements[5], elements[9], elements[13],
  35. elements[2], elements[6], elements[10], elements[14],
  36. elements[3], elements[7], elements[11], elements[15],
  37. };
  38. // clang-format on
  39. }
  40. void glActiveTexture(GLenum texture)
  41. {
  42. g_gl_context->gl_active_texture(texture);
  43. }
  44. void glActiveTextureARB(GLenum texture)
  45. {
  46. glActiveTexture(texture);
  47. }
  48. void glAlphaFunc(GLenum func, GLclampf ref)
  49. {
  50. return g_gl_context->gl_alpha_func(func, ref);
  51. }
  52. void glArrayElement(GLint i)
  53. {
  54. g_gl_context->gl_array_element(i);
  55. }
  56. void glAttachShader(GLuint program, GLuint shader)
  57. {
  58. g_gl_context->gl_attach_shader(program, shader);
  59. }
  60. void glBegin(GLenum mode)
  61. {
  62. g_gl_context->gl_begin(mode);
  63. }
  64. void glBindBuffer(GLenum target, GLuint buffer)
  65. {
  66. g_gl_context->gl_bind_buffer(target, buffer);
  67. }
  68. void glBindTexture(GLenum target, GLuint texture)
  69. {
  70. g_gl_context->gl_bind_texture(target, texture);
  71. }
  72. void glBitmap(GLsizei width, GLsizei height, GLfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, GLubyte const* bitmap)
  73. {
  74. g_gl_context->gl_bitmap(width, height, xorig, yorig, xmove, ymove, bitmap);
  75. }
  76. void glBlendFunc(GLenum sfactor, GLenum dfactor)
  77. {
  78. return g_gl_context->gl_blend_func(sfactor, dfactor);
  79. }
  80. void glBufferData(GLenum target, GLsizeiptr size, void const* data, GLenum usage)
  81. {
  82. g_gl_context->gl_buffer_data(target, size, data, usage);
  83. }
  84. void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, void const* data)
  85. {
  86. g_gl_context->gl_buffer_sub_data(target, offset, size, data);
  87. }
  88. void glCallList(GLuint list)
  89. {
  90. return g_gl_context->gl_call_list(list);
  91. }
  92. void glCallLists(GLsizei n, GLenum type, void const* lists)
  93. {
  94. return g_gl_context->gl_call_lists(n, type, lists);
  95. }
  96. void glClear(GLbitfield mask)
  97. {
  98. g_gl_context->gl_clear(mask);
  99. }
  100. void glClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)
  101. {
  102. g_gl_context->gl_clear_color(red, green, blue, alpha);
  103. }
  104. void glClearDepth(GLdouble depth)
  105. {
  106. g_gl_context->gl_clear_depth(depth);
  107. }
  108. void glClearDepthf(GLfloat depth)
  109. {
  110. g_gl_context->gl_clear_depth(static_cast<double>(depth));
  111. }
  112. void glClearStencil(GLint s)
  113. {
  114. g_gl_context->gl_clear_stencil(s);
  115. }
  116. void glClientActiveTexture(GLenum target)
  117. {
  118. g_gl_context->gl_client_active_texture(target);
  119. }
  120. void glClientActiveTextureARB(GLenum target)
  121. {
  122. glClientActiveTexture(target);
  123. }
  124. void glClipPlane(GLenum plane, GLdouble const* equation)
  125. {
  126. g_gl_context->gl_clip_plane(plane, equation);
  127. }
  128. void glColor3d(GLdouble r, GLdouble g, GLdouble b)
  129. {
  130. g_gl_context->gl_color(r, g, b, 1.0);
  131. }
  132. void glColor3dv(GLdouble const* v)
  133. {
  134. g_gl_context->gl_color(v[0], v[1], v[2], 1.0);
  135. }
  136. void glColor3f(GLfloat r, GLfloat g, GLfloat b)
  137. {
  138. g_gl_context->gl_color(r, g, b, 1.0);
  139. }
  140. void glColor3fv(GLfloat const* v)
  141. {
  142. g_gl_context->gl_color(v[0], v[1], v[2], 1.0);
  143. }
  144. void glColor3ub(GLubyte r, GLubyte g, GLubyte b)
  145. {
  146. g_gl_context->gl_color(r / 255.0, g / 255.0, b / 255.0, 1.0);
  147. }
  148. void glColor3ubv(GLubyte const* v)
  149. {
  150. g_gl_context->gl_color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, 1.0);
  151. }
  152. void glColor4b(GLbyte r, GLbyte g, GLbyte b, GLbyte a)
  153. {
  154. g_gl_context->gl_color(
  155. (static_cast<double>(r) + 128) / 127.5 - 1,
  156. (static_cast<double>(g) + 128) / 127.5 - 1,
  157. (static_cast<double>(b) + 128) / 127.5 - 1,
  158. (static_cast<double>(a) + 128) / 127.5 - 1);
  159. }
  160. void glColor4dv(GLdouble const* v)
  161. {
  162. g_gl_context->gl_color(v[0], v[1], v[2], v[3]);
  163. }
  164. void glColor4f(GLfloat r, GLfloat g, GLfloat b, GLfloat a)
  165. {
  166. g_gl_context->gl_color(r, g, b, a);
  167. }
  168. void glColor4fv(GLfloat const* v)
  169. {
  170. g_gl_context->gl_color(v[0], v[1], v[2], v[3]);
  171. }
  172. void glColor4ub(GLubyte r, GLubyte g, GLubyte b, GLubyte a)
  173. {
  174. g_gl_context->gl_color(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  175. }
  176. void glColor4ubv(GLubyte const* v)
  177. {
  178. g_gl_context->gl_color(v[0] / 255.0, v[1] / 255.0, v[2] / 255.0, v[3] / 255.0);
  179. }
  180. void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha)
  181. {
  182. g_gl_context->gl_color_mask(red, green, blue, alpha);
  183. }
  184. void glColorMaterial(GLenum face, GLenum mode)
  185. {
  186. g_gl_context->gl_color_material(face, mode);
  187. }
  188. void glColorPointer(GLint size, GLenum type, GLsizei stride, void const* pointer)
  189. {
  190. g_gl_context->gl_color_pointer(size, type, stride, pointer);
  191. }
  192. void glCompileShader(GLuint shader)
  193. {
  194. g_gl_context->gl_compile_shader(shader);
  195. }
  196. void glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border)
  197. {
  198. g_gl_context->gl_copy_tex_image_2d(target, level, internalformat, x, y, width, height, border);
  199. }
  200. void glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height)
  201. {
  202. g_gl_context->gl_copy_tex_sub_image_2d(target, level, xoffset, yoffset, x, y, width, height);
  203. }
  204. GLuint glCreateProgram()
  205. {
  206. return g_gl_context->gl_create_program();
  207. }
  208. GLuint glCreateShader(GLenum shader_type)
  209. {
  210. return g_gl_context->gl_create_shader(shader_type);
  211. }
  212. void glCullFace(GLenum mode)
  213. {
  214. g_gl_context->gl_cull_face(mode);
  215. }
  216. void glDeleteBuffers(GLsizei n, GLuint const* buffers)
  217. {
  218. g_gl_context->gl_delete_buffers(n, buffers);
  219. }
  220. void glDepthFunc(GLenum func)
  221. {
  222. g_gl_context->gl_depth_func(func);
  223. }
  224. void glDepthMask(GLboolean flag)
  225. {
  226. g_gl_context->gl_depth_mask(flag);
  227. }
  228. void glDepthRange(GLdouble min, GLdouble max)
  229. {
  230. g_gl_context->gl_depth_range(min, max);
  231. }
  232. void glDeleteLists(GLuint list, GLsizei range)
  233. {
  234. return g_gl_context->gl_delete_lists(list, range);
  235. }
  236. void glDeleteProgram(GLuint program)
  237. {
  238. g_gl_context->gl_delete_program(program);
  239. }
  240. void glDeleteShader(GLuint shader)
  241. {
  242. g_gl_context->gl_delete_shader(shader);
  243. }
  244. void glDeleteTextures(GLsizei n, GLuint const* textures)
  245. {
  246. g_gl_context->gl_delete_textures(n, textures);
  247. }
  248. void glDisable(GLenum cap)
  249. {
  250. g_gl_context->gl_disable(cap);
  251. }
  252. void glDisableClientState(GLenum cap)
  253. {
  254. g_gl_context->gl_disable_client_state(cap);
  255. }
  256. void glDrawArrays(GLenum mode, GLint first, GLsizei count)
  257. {
  258. g_gl_context->gl_draw_arrays(mode, first, count);
  259. }
  260. void glDrawBuffer(GLenum buffer)
  261. {
  262. g_gl_context->gl_draw_buffer(buffer);
  263. }
  264. void glDrawElements(GLenum mode, GLsizei count, GLenum type, void const* indices)
  265. {
  266. g_gl_context->gl_draw_elements(mode, count, type, indices);
  267. }
  268. void glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, void const* data)
  269. {
  270. g_gl_context->gl_draw_pixels(width, height, format, type, data);
  271. }
  272. void glEnable(GLenum cap)
  273. {
  274. g_gl_context->gl_enable(cap);
  275. }
  276. void glEnableClientState(GLenum cap)
  277. {
  278. g_gl_context->gl_enable_client_state(cap);
  279. }
  280. void glEnd()
  281. {
  282. g_gl_context->gl_end();
  283. }
  284. void glEndList(void)
  285. {
  286. return g_gl_context->gl_end_list();
  287. }
  288. void glEvalCoord1d(GLdouble u)
  289. {
  290. dbgln("glEvalCoord1d({}): unimplemented", u);
  291. TODO();
  292. }
  293. void glEvalCoord1f(GLfloat u)
  294. {
  295. dbgln("glEvalCoord1f({}): unimplemented", u);
  296. TODO();
  297. }
  298. void glEvalCoord2d(GLdouble u, GLdouble v)
  299. {
  300. dbgln("glEvalCoord2d({}, {}): unimplemented", u, v);
  301. TODO();
  302. }
  303. void glEvalCoord2f(GLfloat u, GLfloat v)
  304. {
  305. dbgln("glEvalCoord2f({}, {}): unimplemented", u, v);
  306. TODO();
  307. }
  308. void glEvalMesh1(GLenum mode, GLint i1, GLint i2)
  309. {
  310. dbgln("glEvalMesh1({:#x}, {}, {}): unimplemented", mode, i1, i2);
  311. TODO();
  312. }
  313. void glEvalMesh2(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2)
  314. {
  315. dbgln("glEvalMesh2({:#x}, {}, {}, {}, {}): unimplemented", mode, i1, i2, j1, j2);
  316. TODO();
  317. }
  318. void glEvalPoint1(GLint i)
  319. {
  320. dbgln("glEvalPoint1({}): unimplemented", i);
  321. TODO();
  322. }
  323. void glEvalPoint2(GLint i, GLint j)
  324. {
  325. dbgln("glEvalPoint2({}, {}): unimplemented", i, j);
  326. TODO();
  327. }
  328. void glFinish()
  329. {
  330. g_gl_context->gl_finish();
  331. }
  332. void glFogfv(GLenum pname, GLfloat const* params)
  333. {
  334. g_gl_context->gl_fogfv(pname, params);
  335. }
  336. void glFogf(GLenum pname, GLfloat param)
  337. {
  338. g_gl_context->gl_fogf(pname, param);
  339. }
  340. void glFogi(GLenum pname, GLint param)
  341. {
  342. g_gl_context->gl_fogi(pname, param);
  343. }
  344. void glFlush()
  345. {
  346. g_gl_context->gl_flush();
  347. }
  348. void glFrontFace(GLenum mode)
  349. {
  350. g_gl_context->gl_front_face(mode);
  351. }
  352. void glFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)
  353. {
  354. g_gl_context->gl_frustum(left, right, bottom, top, nearVal, farVal);
  355. }
  356. void glGenBuffers(GLsizei n, GLuint* buffers)
  357. {
  358. g_gl_context->gl_gen_buffers(n, buffers);
  359. }
  360. GLuint glGenLists(GLsizei range)
  361. {
  362. return g_gl_context->gl_gen_lists(range);
  363. }
  364. void glGenTextures(GLsizei n, GLuint* textures)
  365. {
  366. g_gl_context->gl_gen_textures(n, textures);
  367. }
  368. void glGetBooleanv(GLenum pname, GLboolean* data)
  369. {
  370. g_gl_context->gl_get_booleanv(pname, data);
  371. }
  372. void glGetClipPlane(GLenum plane, GLdouble* equation)
  373. {
  374. g_gl_context->gl_get_clip_plane(plane, equation);
  375. }
  376. void glGetDoublev(GLenum pname, GLdouble* params)
  377. {
  378. g_gl_context->gl_get_doublev(pname, params);
  379. }
  380. GLenum glGetError()
  381. {
  382. return g_gl_context->gl_get_error();
  383. }
  384. void glGetFloatv(GLenum pname, GLfloat* params)
  385. {
  386. g_gl_context->gl_get_floatv(pname, params);
  387. }
  388. void glGetIntegerv(GLenum pname, GLint* data)
  389. {
  390. g_gl_context->gl_get_integerv(pname, data);
  391. }
  392. void glGetLightfv(GLenum light, GLenum pname, GLfloat* params)
  393. {
  394. g_gl_context->gl_get_light(light, pname, params, GL_FLOAT);
  395. }
  396. void glGetLightiv(GLenum light, GLenum pname, GLint* params)
  397. {
  398. g_gl_context->gl_get_light(light, pname, params, GL_INT);
  399. }
  400. void glGetMaterialfv(GLenum face, GLenum pname, GLfloat* params)
  401. {
  402. g_gl_context->gl_get_material(face, pname, params, GL_FLOAT);
  403. }
  404. void glGetMaterialiv(GLenum face, GLenum pname, GLint* params)
  405. {
  406. g_gl_context->gl_get_material(face, pname, params, GL_INT);
  407. }
  408. GLubyte const* glGetString(GLenum name)
  409. {
  410. return g_gl_context->gl_get_string(name);
  411. }
  412. void glGetTexImage(GLenum target, GLint level, GLenum format, GLenum type, void* pixels)
  413. {
  414. g_gl_context->gl_get_tex_image(target, level, format, type, pixels);
  415. }
  416. void glGetTexLevelParameteriv(GLenum target, GLint level, GLenum pname, GLint* params)
  417. {
  418. g_gl_context->gl_get_tex_parameter_integerv(target, level, pname, params);
  419. }
  420. void glHint(GLenum target, GLenum mode)
  421. {
  422. g_gl_context->gl_hint(target, mode);
  423. }
  424. GLboolean glIsEnabled(GLenum cap)
  425. {
  426. return g_gl_context->gl_is_enabled(cap);
  427. }
  428. GLboolean glIsList(GLuint list)
  429. {
  430. return g_gl_context->gl_is_list(list);
  431. }
  432. GLboolean glIsTexture(GLuint texture)
  433. {
  434. return g_gl_context->gl_is_texture(texture);
  435. }
  436. void glLightf(GLenum light, GLenum pname, GLfloat param)
  437. {
  438. g_gl_context->gl_lightf(light, pname, param);
  439. }
  440. void glLightfv(GLenum light, GLenum pname, GLfloat const* param)
  441. {
  442. g_gl_context->gl_lightfv(light, pname, param);
  443. }
  444. void glLighti(GLenum light, GLenum pname, GLint param)
  445. {
  446. g_gl_context->gl_lightf(light, pname, param);
  447. }
  448. void glLightiv(GLenum light, GLenum pname, GLint const* params)
  449. {
  450. g_gl_context->gl_lightiv(light, pname, params);
  451. }
  452. void glLightModelf(GLenum pname, GLfloat param)
  453. {
  454. g_gl_context->gl_light_model(pname, param, 0.0f, 0.0f, 0.0f);
  455. }
  456. void glLightModelfv(GLenum pname, GLfloat const* params)
  457. {
  458. switch (pname) {
  459. case GL_LIGHT_MODEL_AMBIENT:
  460. g_gl_context->gl_light_model(pname, params[0], params[1], params[2], params[3]);
  461. break;
  462. default:
  463. g_gl_context->gl_light_model(pname, params[0], 0.0f, 0.0f, 0.0f);
  464. break;
  465. }
  466. }
  467. void glLightModeliv(GLenum pname, GLint const* params)
  468. {
  469. switch (pname) {
  470. case GL_LIGHT_MODEL_AMBIENT:
  471. g_gl_context->gl_light_model(pname, params[0], params[1], params[2], params[3]);
  472. break;
  473. default:
  474. g_gl_context->gl_light_model(pname, params[0], 0.0f, 0.0f, 0.0f);
  475. break;
  476. }
  477. }
  478. void glLightModeli(GLenum pname, GLint param)
  479. {
  480. g_gl_context->gl_light_model(pname, param, 0.0f, 0.0f, 0.0f);
  481. }
  482. void glLineWidth(GLfloat width)
  483. {
  484. g_gl_context->gl_line_width(width);
  485. }
  486. void glLinkProgram(GLuint program)
  487. {
  488. g_gl_context->gl_link_program(program);
  489. }
  490. void glListBase(GLuint base)
  491. {
  492. return g_gl_context->gl_list_base(base);
  493. }
  494. void glLoadIdentity()
  495. {
  496. g_gl_context->gl_load_identity();
  497. }
  498. void glLoadMatrixd(GLdouble const* matrix)
  499. {
  500. g_gl_context->gl_load_matrix(transpose_input_matrix<double, float>(matrix));
  501. }
  502. void glLoadMatrixf(GLfloat const* matrix)
  503. {
  504. g_gl_context->gl_load_matrix(transpose_input_matrix<float, float>(matrix));
  505. }
  506. void glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, GLdouble const* points)
  507. {
  508. dbgln("glMap1d({:#x}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, stride, order, points);
  509. TODO();
  510. }
  511. void glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, GLfloat const* points)
  512. {
  513. dbgln("glMap1f({:#x}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, stride, order, points);
  514. TODO();
  515. }
  516. void glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble const* points)
  517. {
  518. dbgln("glMap2d({:#x}, {}, {}, {}, {}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
  519. TODO();
  520. }
  521. void glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat const* points)
  522. {
  523. dbgln("glMap2f({:#x}, {}, {}, {}, {}, {}, {}, {}, {}, {:p}): unimplemented", target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points);
  524. TODO();
  525. }
  526. void glMapGrid1d(GLint un, GLdouble u1, GLdouble u2)
  527. {
  528. dbgln("glMapGrid1d({}, {}, {}): unimplemented", un, u1, u2);
  529. TODO();
  530. }
  531. void glMapGrid1f(GLint un, GLfloat u1, GLfloat u2)
  532. {
  533. dbgln("glMapGrid1f({}, {}, {}): unimplemented", un, u1, u2);
  534. TODO();
  535. }
  536. void glMapGrid2d(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2)
  537. {
  538. dbgln("glMapGrid2d({}, {}, {}, {}, {}, {}): unimplemented", un, u1, u2, vn, v1, v2);
  539. TODO();
  540. }
  541. void glMapGrid2f(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2)
  542. {
  543. dbgln("glMapGrid2f({}, {}, {}, {}, {}, {}): unimplemented", un, u1, u2, vn, v1, v2);
  544. TODO();
  545. }
  546. void glMaterialf(GLenum face, GLenum pname, GLfloat param)
  547. {
  548. g_gl_context->gl_materialf(face, pname, param);
  549. }
  550. void glMaterialfv(GLenum face, GLenum pname, GLfloat const* params)
  551. {
  552. g_gl_context->gl_materialfv(face, pname, params);
  553. }
  554. void glMateriali(GLenum face, GLenum pname, GLint param)
  555. {
  556. g_gl_context->gl_materialf(face, pname, param);
  557. }
  558. void glMaterialiv(GLenum face, GLenum pname, GLint const* params)
  559. {
  560. g_gl_context->gl_materialiv(face, pname, params);
  561. }
  562. void glMatrixMode(GLenum mode)
  563. {
  564. g_gl_context->gl_matrix_mode(mode);
  565. }
  566. void glMultiTexCoord1f(GLenum target, GLfloat s)
  567. {
  568. g_gl_context->gl_multi_tex_coord(target, s, 0.f, 0.f, 1.f);
  569. }
  570. void glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t)
  571. {
  572. glMultiTexCoord2f(target, s, t);
  573. }
  574. void glMultiTexCoord2fvARB(GLenum target, GLfloat const* v)
  575. {
  576. glMultiTexCoord2fv(target, v);
  577. }
  578. void glMultiTexCoord2fv(GLenum target, GLfloat const* v)
  579. {
  580. g_gl_context->gl_multi_tex_coord(target, v[0], v[1], 0.f, 1.f);
  581. }
  582. void glMultiTexCoord2f(GLenum target, GLfloat s, GLfloat t)
  583. {
  584. g_gl_context->gl_multi_tex_coord(target, s, t, 0.f, 1.f);
  585. }
  586. void glMultiTexCoord3f(GLenum target, GLfloat s, GLfloat t, GLfloat r)
  587. {
  588. g_gl_context->gl_multi_tex_coord(target, s, t, r, 1.f);
  589. }
  590. void glMultiTexCoord4f(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)
  591. {
  592. g_gl_context->gl_multi_tex_coord(target, s, t, r, q);
  593. }
  594. void glMultMatrixd(GLdouble const* matrix)
  595. {
  596. g_gl_context->gl_mult_matrix(transpose_input_matrix<double, float>(matrix));
  597. }
  598. void glMultMatrixf(GLfloat const* matrix)
  599. {
  600. g_gl_context->gl_mult_matrix(transpose_input_matrix<float, float>(matrix));
  601. }
  602. void glNewList(GLuint list, GLenum mode)
  603. {
  604. return g_gl_context->gl_new_list(list, mode);
  605. }
  606. void glNormal3d(GLdouble nx, GLdouble ny, GLdouble nz)
  607. {
  608. g_gl_context->gl_normal(nx, ny, nz);
  609. }
  610. void glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz)
  611. {
  612. g_gl_context->gl_normal(nx, ny, nz);
  613. }
  614. void glNormal3fv(GLfloat const* v)
  615. {
  616. g_gl_context->gl_normal(v[0], v[1], v[2]);
  617. }
  618. void glNormalPointer(GLenum type, GLsizei stride, void const* pointer)
  619. {
  620. g_gl_context->gl_normal_pointer(type, stride, pointer);
  621. }
  622. void glOrtho(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble nearVal, GLdouble farVal)
  623. {
  624. g_gl_context->gl_ortho(left, right, bottom, top, nearVal, farVal);
  625. }
  626. void glPixelStorei(GLenum pname, GLint param)
  627. {
  628. g_gl_context->gl_pixel_storei(pname, param);
  629. }
  630. void glPointSize(GLfloat size)
  631. {
  632. g_gl_context->gl_point_size(size);
  633. }
  634. void glPolygonMode(GLenum face, GLenum mode)
  635. {
  636. g_gl_context->gl_polygon_mode(face, mode);
  637. }
  638. void glPolygonOffset(GLfloat factor, GLfloat units)
  639. {
  640. g_gl_context->gl_polygon_offset(factor, units);
  641. }
  642. void glPopAttrib()
  643. {
  644. g_gl_context->gl_pop_attrib();
  645. }
  646. void glPopMatrix()
  647. {
  648. g_gl_context->gl_pop_matrix();
  649. }
  650. void glPushAttrib(GLbitfield mask)
  651. {
  652. g_gl_context->gl_push_attrib(mask);
  653. }
  654. void glPushMatrix()
  655. {
  656. g_gl_context->gl_push_matrix();
  657. }
  658. void glRasterPos2d(GLdouble x, GLdouble y)
  659. {
  660. g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.f, 1.f);
  661. }
  662. void glRasterPos2f(GLfloat x, GLfloat y)
  663. {
  664. g_gl_context->gl_raster_pos(x, y, 0.f, 1.f);
  665. }
  666. void glRasterPos2i(GLint x, GLint y)
  667. {
  668. g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.f, 1.f);
  669. }
  670. void glRasterPos2s(GLshort x, GLshort y)
  671. {
  672. g_gl_context->gl_raster_pos(static_cast<float>(x), static_cast<float>(y), 0.f, 1.f);
  673. }
  674. void glReadBuffer(GLenum mode)
  675. {
  676. g_gl_context->gl_read_buffer(mode);
  677. }
  678. void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels)
  679. {
  680. g_gl_context->gl_read_pixels(x, y, width, height, format, type, pixels);
  681. }
  682. void glRectf(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2)
  683. {
  684. g_gl_context->gl_rect(x1, y1, x2, y2);
  685. }
  686. void glRecti(GLint x1, GLint y1, GLint x2, GLint y2)
  687. {
  688. g_gl_context->gl_rect(x1, y1, x2, y2);
  689. }
  690. void glRotated(GLdouble angle, GLdouble x, GLdouble y, GLdouble z)
  691. {
  692. g_gl_context->gl_rotate(angle, x, y, z);
  693. }
  694. void glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z)
  695. {
  696. g_gl_context->gl_rotate(angle, x, y, z);
  697. }
  698. void glScaled(GLdouble x, GLdouble y, GLdouble z)
  699. {
  700. g_gl_context->gl_scale(x, y, z);
  701. }
  702. void glScalef(GLfloat x, GLfloat y, GLfloat z)
  703. {
  704. g_gl_context->gl_scale(x, y, z);
  705. }
  706. void glScissor(GLint x, GLint y, GLsizei width, GLsizei height)
  707. {
  708. g_gl_context->gl_scissor(x, y, width, height);
  709. }
  710. void glShadeModel(GLenum mode)
  711. {
  712. g_gl_context->gl_shade_model(mode);
  713. }
  714. void glShaderSource(GLuint shader, GLsizei count, GLchar const** string, GLint const* length)
  715. {
  716. g_gl_context->gl_shader_source(shader, count, string, length);
  717. }
  718. void glStencilFunc(GLenum func, GLint ref, GLuint mask)
  719. {
  720. g_gl_context->gl_stencil_func_separate(GL_FRONT_AND_BACK, func, ref, mask);
  721. }
  722. void glStencilFuncSeparate(GLenum face, GLenum func, GLint ref, GLuint mask)
  723. {
  724. g_gl_context->gl_stencil_func_separate(face, func, ref, mask);
  725. }
  726. void glStencilMask(GLuint mask)
  727. {
  728. g_gl_context->gl_stencil_mask_separate(GL_FRONT_AND_BACK, mask);
  729. }
  730. void glStencilMaskSeparate(GLenum face, GLuint mask)
  731. {
  732. g_gl_context->gl_stencil_mask_separate(face, mask);
  733. }
  734. void glStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
  735. {
  736. g_gl_context->gl_stencil_op_separate(GL_FRONT_AND_BACK, sfail, dpfail, dppass);
  737. }
  738. void glStencilOpSeparate(GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass)
  739. {
  740. g_gl_context->gl_stencil_op_separate(face, sfail, dpfail, dppass);
  741. }
  742. void glTexCoord1f(GLfloat s)
  743. {
  744. g_gl_context->gl_tex_coord(s, 0.0f, 0.0f, 1.0f);
  745. }
  746. void glTexCoord1fv(GLfloat const* v)
  747. {
  748. g_gl_context->gl_tex_coord(v[0], 0.0f, 0.0f, 1.0f);
  749. }
  750. void glTexCoord2d(GLdouble s, GLdouble t)
  751. {
  752. g_gl_context->gl_tex_coord(s, t, 0.0f, 1.0f);
  753. }
  754. void glTexCoord2dv(GLdouble const* v)
  755. {
  756. g_gl_context->gl_tex_coord(v[0], v[1], 0.0f, 1.0f);
  757. }
  758. void glTexCoord2f(GLfloat s, GLfloat t)
  759. {
  760. g_gl_context->gl_tex_coord(s, t, 0.0f, 1.0f);
  761. }
  762. void glTexCoord2fv(GLfloat const* v)
  763. {
  764. g_gl_context->gl_tex_coord(v[0], v[1], 0.0f, 1.0f);
  765. }
  766. void glTexCoord2i(GLint s, GLint t)
  767. {
  768. g_gl_context->gl_tex_coord(s, t, 0.0f, 1.0f);
  769. }
  770. void glTexCoord3f(GLfloat s, GLfloat t, GLfloat r)
  771. {
  772. g_gl_context->gl_tex_coord(s, t, r, 1.0f);
  773. }
  774. void glTexCoord3fv(GLfloat const* v)
  775. {
  776. g_gl_context->gl_tex_coord(v[0], v[1], v[2], 1.0f);
  777. }
  778. void glTexCoord4f(GLfloat s, GLfloat t, GLfloat r, GLfloat q)
  779. {
  780. g_gl_context->gl_tex_coord(s, t, r, q);
  781. }
  782. void glTexCoord4fv(GLfloat const* v)
  783. {
  784. g_gl_context->gl_tex_coord(v[0], v[1], v[2], v[3]);
  785. }
  786. void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, void const* pointer)
  787. {
  788. g_gl_context->gl_tex_coord_pointer(size, type, stride, pointer);
  789. }
  790. void glTexEnvf(GLenum target, GLenum pname, GLfloat param)
  791. {
  792. g_gl_context->gl_tex_env(target, pname, param);
  793. }
  794. void glTexEnvi(GLenum target, GLenum pname, GLint param)
  795. {
  796. g_gl_context->gl_tex_env(target, pname, param);
  797. }
  798. void glTexGend(GLenum coord, GLenum pname, GLdouble param)
  799. {
  800. g_gl_context->gl_tex_gen(coord, pname, param);
  801. }
  802. void glTexGenf(GLenum coord, GLenum pname, GLfloat param)
  803. {
  804. g_gl_context->gl_tex_gen(coord, pname, param);
  805. }
  806. void glTexGenfv(GLenum coord, GLenum pname, GLfloat const* params)
  807. {
  808. g_gl_context->gl_tex_gen_floatv(coord, pname, params);
  809. }
  810. void glTexGeni(GLenum coord, GLenum pname, GLint param)
  811. {
  812. g_gl_context->gl_tex_gen(coord, pname, param);
  813. }
  814. void glTexImage1D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLint border, GLenum format, GLenum type, GLvoid const* data)
  815. {
  816. dbgln("glTexImage1D({:#x}, {}, {:#x}, {}, {}, {:#x}, {:#x}, {:p}): unimplemented", target, level, internalFormat, width, border, format, type, data);
  817. TODO();
  818. }
  819. void glTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid const* data)
  820. {
  821. g_gl_context->gl_tex_image_2d(target, level, internalFormat, width, height, border, format, type, data);
  822. }
  823. void glTexImage3D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid const* data)
  824. {
  825. dbgln("glTexImage3D({:#x}, {}, {:#x}, {}, {}, {}, {}, {:#x}, {:#x}, {:p}): unimplemented", target, level, internalFormat, width, height, depth, border, format, type, data);
  826. TODO();
  827. }
  828. void glTexParameteri(GLenum target, GLenum pname, GLint param)
  829. {
  830. g_gl_context->gl_tex_parameter(target, pname, param);
  831. }
  832. void glTexParameterf(GLenum target, GLenum pname, GLfloat param)
  833. {
  834. g_gl_context->gl_tex_parameter(target, pname, param);
  835. }
  836. void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid const* data)
  837. {
  838. g_gl_context->gl_tex_sub_image_2d(target, level, xoffset, yoffset, width, height, format, type, data);
  839. }
  840. void glTranslated(GLdouble x, GLdouble y, GLdouble z)
  841. {
  842. g_gl_context->gl_translate(x, y, z);
  843. }
  844. void glTranslatef(GLfloat x, GLfloat y, GLfloat z)
  845. {
  846. g_gl_context->gl_translate(x, y, z);
  847. }
  848. void glUseProgram(GLuint program)
  849. {
  850. g_gl_context->gl_use_program(program);
  851. }
  852. void glVertex2d(GLdouble x, GLdouble y)
  853. {
  854. g_gl_context->gl_vertex(x, y, 0.0, 1.0);
  855. }
  856. void glVertex2dv(GLdouble const* v)
  857. {
  858. g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
  859. }
  860. void glVertex2f(GLfloat x, GLfloat y)
  861. {
  862. g_gl_context->gl_vertex(x, y, 0.0, 1.0);
  863. }
  864. void glVertex2fv(GLfloat const* v)
  865. {
  866. g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
  867. }
  868. void glVertex2i(GLint x, GLint y)
  869. {
  870. g_gl_context->gl_vertex(x, y, 0.0, 1.0);
  871. }
  872. void glVertex2iv(GLint const* v)
  873. {
  874. g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
  875. }
  876. void glVertex2s(GLshort x, GLshort y)
  877. {
  878. g_gl_context->gl_vertex(x, y, 0.0, 1.0);
  879. }
  880. void glVertex2sv(GLshort const* v)
  881. {
  882. g_gl_context->gl_vertex(v[0], v[1], 0.0, 1.0);
  883. }
  884. void glVertex3d(GLdouble x, GLdouble y, GLdouble z)
  885. {
  886. g_gl_context->gl_vertex(x, y, z, 1.0);
  887. }
  888. void glVertex3dv(GLdouble const* v)
  889. {
  890. g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
  891. }
  892. void glVertex3f(GLfloat x, GLfloat y, GLfloat z)
  893. {
  894. g_gl_context->gl_vertex(x, y, z, 1.0);
  895. }
  896. void glVertex3fv(GLfloat const* v)
  897. {
  898. g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
  899. }
  900. void glVertex3i(GLint x, GLint y, GLint z)
  901. {
  902. g_gl_context->gl_vertex(x, y, z, 1.0);
  903. }
  904. void glVertex3iv(GLint const* v)
  905. {
  906. g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
  907. }
  908. void glVertex3s(GLshort x, GLshort y, GLshort z)
  909. {
  910. g_gl_context->gl_vertex(x, y, z, 1.0);
  911. }
  912. void glVertex3sv(GLshort const* v)
  913. {
  914. g_gl_context->gl_vertex(v[0], v[1], v[2], 1.0);
  915. }
  916. void glVertex4d(GLdouble x, GLdouble y, GLdouble z, GLdouble w)
  917. {
  918. g_gl_context->gl_vertex(x, y, z, w);
  919. }
  920. void glVertex4dv(GLdouble const* v)
  921. {
  922. g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
  923. }
  924. void glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w)
  925. {
  926. g_gl_context->gl_vertex(x, y, z, w);
  927. }
  928. void glVertex4fv(GLfloat const* v)
  929. {
  930. g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
  931. }
  932. void glVertex4i(GLint x, GLint y, GLint z, GLint w)
  933. {
  934. g_gl_context->gl_vertex(x, y, z, w);
  935. }
  936. void glVertex4iv(GLint const* v)
  937. {
  938. g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
  939. }
  940. void glVertex4s(GLshort x, GLshort y, GLshort z, GLshort w)
  941. {
  942. g_gl_context->gl_vertex(x, y, z, w);
  943. }
  944. void glVertex4sv(GLshort const* v)
  945. {
  946. g_gl_context->gl_vertex(v[0], v[1], v[2], v[3]);
  947. }
  948. void glVertexPointer(GLint size, GLenum type, GLsizei stride, void const* pointer)
  949. {
  950. g_gl_context->gl_vertex_pointer(size, type, stride, pointer);
  951. }
  952. void glViewport(GLint x, GLint y, GLsizei width, GLsizei height)
  953. {
  954. g_gl_context->gl_viewport(x, y, width, height);
  955. }