GLAPI.cpp 24 KB

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