GCC Code Coverage Report


Directory: src/gate/
File: src/gate/graphics/gl_apis.c
Date: 2026-02-03 22:06:38
Exec Total Coverage
Lines: 0 297 0.0%
Functions: 0 41 0.0%
Branches: 0 123 0.0%

Line Branch Exec Source
1 /* GATE PROJECT LICENSE:
2 +----------------------------------------------------------------------------+
3 | Copyright(c) 2018-2026, Stefan Meislinger |
4 | All rights reserved. |
5 | |
6 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met:|
8 | |
9 | 1. Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. |
11 | 2. Redistributions in binary form must reproduce the above copyright |
12 | notice, this list of conditions and the following disclaimer in the |
13 | documentation and/or other materials provided with the distribution. |
14 | |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"|
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
18 | ARE DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
25 | THE POSSIBILITY OF SUCH DAMAGE. |
26 +----------------------------------------------------------------------------+
27 */
28 #include "gate/graphics/gl_apis.h"
29
30 #include "gate/debugging.h"
31 #include "gate/mathematics.h"
32
33 #if (defined(GATE_SYS_WIN) && !defined(GATE_SYS_WINCE) && !defined(GATE_SYS_WINSTORE) && !defined(GATE_SYS_WIN16)) || (defined(GATE_SYS_POSIX) && !defined(GATE_SYS_OPENBSD) && !defined(GATE_SYS_BEOS)) || defined(GATE_SYS_WASM)
34 # define GATE_GRAPHICS_GL_OPENGL
35 #else
36 # define GATE_GARPHICS_GL_NOIMPL
37 #endif
38
39 #if defined(GATE_GRAPHICS_GL_OPENGL)
40
41 #include "gate/graphics/platform/opengl_apis.h"
42
43 #if defined(GATE_GRAPHICS_OPENGL_GLUT)
44 # define GATE_GL_API_GLUT 1
45 #elif defined(GATE_SYS_WIN) && !defined(GATE_SYS_WINCE)
46 # define GATE_GL_API_WINAPI 1
47 #elif defined(GATE_SYS_DARWIN)
48 # define GATE_GL_API_GLUT 1
49 #else
50 # define GATE_GL_API_EGL 1
51 #endif
52
53
54
55 gate_result_t gate_gl_api_init()
56 {
57 return gate_gl_api_load_functions();
58 }
59
60 void gate_gl_api_color3(gate_real32_t r, gate_real32_t g, gate_real32_t b)
61 {
62 gate_gl_api_color4(r, g, b, 1.0f);
63 }
64 void gate_gl_api_color4(gate_real32_t r, gate_real32_t g, gate_real32_t b, gate_real32_t a)
65 {
66 gate_gl_api.glColor4f(r, g, b, a);
67 }
68 void gate_gl_api_color3b(gate_uint8_t r, gate_uint8_t g, gate_uint8_t b)
69 {
70 gate_gl_api_color4b(r, g, b, 255);
71 }
72 void gate_gl_api_color4b(gate_uint8_t r, gate_uint8_t g, gate_uint8_t b, gate_uint8_t a)
73 {
74 gate_gl_api.glColor4f((gate_real32_t)r / 255.0f,
75 (gate_real32_t)g / 255.0f,
76 (gate_real32_t)b / 255.0f,
77 (gate_real32_t)a / 255.0f);
78 }
79
80 void gate_gl_api_vertexpointer(gate_size_t coord_count, gate_real32_t const* ptr_coords)
81 {
82 gate_gl_api.glVertexPointer((GLint)coord_count, GL_FLOAT, 0, ptr_coords);
83 }
84
85 void gate_gl_api_texcoordpointer(gate_size_t coord_count, gate_real32_t const* ptr_coords)
86 {
87 gate_gl_api.glTexCoordPointer((GLint)coord_count, GL_FLOAT, 0, ptr_coords);
88 }
89
90 void gate_gl_api_shademodel(gate_gl_api_shademodel_t model)
91 {
92 GLenum value = 0;
93 switch (model)
94 {
95 case gate_gl_api_shademodel_flat: value = GL_FLAT; break;
96 case gate_gl_api_shademodel_smooth: value = GL_SMOOTH; break;
97 }
98 gate_gl_api.glShadeModel(value);
99 }
100
101 static GLenum resolve_blend_function(gate_gl_api_blend_t blend_function)
102 {
103 switch (blend_function)
104 {
105 case gate_gl_api_blend_zero: return GL_ZERO;
106 case gate_gl_api_blend_one: return GL_ONE;
107 case gate_gl_api_blend_src_color: return GL_SRC_COLOR;
108 case gate_gl_api_blend_one_minus_src_color: return GL_ONE_MINUS_SRC_COLOR;
109 case gate_gl_api_blend_src_alpha: return GL_SRC_ALPHA;
110 case gate_gl_api_blend_one_minus_src_alpha: return GL_ONE_MINUS_SRC_ALPHA;
111 case gate_gl_api_blend_dst_alpha: return GL_DST_ALPHA;
112 case gate_gl_api_blend_one_minus_dst_alpha: return GL_ONE_MINUS_DST_ALPHA;
113 case gate_gl_api_blend_dst_color: return GL_DST_COLOR;
114 case gate_gl_api_blend_one_minus_dst_color: return GL_ONE_MINUS_DST_COLOR;
115 case gate_gl_api_blend_src_alpha_saturate: return GL_SRC_ALPHA_SATURATE;
116 }
117 return 0;
118 }
119
120 void gate_gl_api_blendfunc(gate_gl_api_blend_t blend_func_src, gate_gl_api_blend_t blend_func_dst)
121 {
122 gate_gl_api.glBlendFunc(resolve_blend_function(blend_func_src), resolve_blend_function(blend_func_dst));
123 }
124
125 void gate_gl_api_clearcolor(gate_real32_t r, gate_real32_t g, gate_real32_t b, gate_real32_t a)
126 {
127 gate_gl_api.glClearColor(r, g, b, a);
128 }
129
130 void gate_gl_api_cleardepth(gate_real32_t depth)
131 {
132 gate_gl_api.glClearDepth(depth);
133 }
134
135 static GLenum translate_capability(gate_gl_api_capability_t capability)
136 {
137 switch (capability)
138 {
139 case gate_gl_api_capability_alpha_test: return GL_ALPHA_TEST;
140 #if defined(GL_AUTO_NORMAL)
141 case gate_gl_api_capability_auto_normal: return GL_AUTO_NORMAL;
142 #endif
143 case gate_gl_api_capability_blend: return GL_BLEND;
144 //case gate_gl_api_capability_clip_plane: return GL_CLIP_PLANEi;
145 case gate_gl_api_capability_color_logic_op: return GL_COLOR_LOGIC_OP;
146 case gate_gl_api_capability_color_material: return GL_COLOR_MATERIAL;
147 case gate_gl_api_capability_cull_face: return GL_CULL_FACE;
148 case gate_gl_api_capability_depth_test: return GL_DEPTH_TEST;
149 case gate_gl_api_capability_dither: return GL_DITHER;
150 case gate_gl_api_capability_fog: return GL_FOG;
151 #if defined(GL_INDEX_LOGIC_OP)
152 case gate_gl_api_capability_index_logic_op: return GL_INDEX_LOGIC_OP;
153 #endif
154 //case gate_gl_api_capability_light: return GL_LIGHTi;
155 case gate_gl_api_capability_lighting: return GL_LIGHTING;
156 case gate_gl_api_capability_line_smooth: return GL_LINE_SMOOTH;
157 #if defined(GL_LINE_STIPPLE)
158 case gate_gl_api_capability_line_stipple: return GL_LINE_STIPPLE;
159 #endif
160 #if defined(GL_LOGIC_OP)
161 case gate_gl_api_capability_logic_op: return GL_LOGIC_OP;
162 #endif
163 #if defined(GL_MAP1_COLOR_4)
164 case gate_gl_api_capability_map1_color_4: return GL_MAP1_COLOR_4;
165 #endif
166 #if defined(GL_MAP1_INDEX)
167 case gate_gl_api_capability_map1_index: return GL_MAP1_INDEX;
168 #endif
169 #if defined(GL_MAP1_NORMAL)
170 case gate_gl_api_capability_map1_normal: return GL_MAP1_NORMAL;
171 #endif
172 #if defined(GL_MAP1_TEXTURE_COORD_1)
173 case gate_gl_api_capability_map1_texture_coord_1: return GL_MAP1_TEXTURE_COORD_1;
174 #endif
175 #if defined(GL_MAP1_TEXTURE_COORD_2)
176 case gate_gl_api_capability_map1_texture_coord_2: return GL_MAP1_TEXTURE_COORD_2;
177 #endif
178 #if defined(GL_MAP1_TEXTURE_COORD_3)
179 case gate_gl_api_capability_map1_texture_coord_3: return GL_MAP1_TEXTURE_COORD_3;
180 #endif
181 #if defined(GL_MAP1_TEXTURE_COORD_4)
182 case gate_gl_api_capability_map1_texture_coord_4: return GL_MAP1_TEXTURE_COORD_4;
183 #endif
184 #if defined(GL_MAP1_VERTEX_3)
185 case gate_gl_api_capability_map1_vertex_3: return GL_MAP1_VERTEX_3;
186 #endif
187 #if defined(GL_MAP1_VERTEX_4)
188 case gate_gl_api_capability_map1_vertex_4: return GL_MAP1_VERTEX_4;
189 #endif
190 #if defined(GL_MAP2_COLOR_4)
191 case gate_gl_api_capability_map2_color_4: return GL_MAP2_COLOR_4;
192 #endif
193 #if defined(GL_MAP2_INDEX)
194 case gate_gl_api_capability_map2_index: return GL_MAP2_INDEX;
195 #endif
196 #if defined(GL_MAP2_NORMAL)
197 case gate_gl_api_capability_map2_normal: return GL_MAP2_NORMAL;
198 #endif
199 #if defined(GL_MAP2_TEXTURE_COORD_1)
200 case gate_gl_api_capability_map2_texture_coord_1: return GL_MAP2_TEXTURE_COORD_1;
201 #endif
202 #if defined(GL_MAP2_TEXTURE_COORD_2)
203 case gate_gl_api_capability_map2_texture_coord_2: return GL_MAP2_TEXTURE_COORD_2;
204 #endif
205 #if defined(GL_MAP2_TEXTURE_COORD_3)
206 case gate_gl_api_capability_map2_texture_coord_3: return GL_MAP2_TEXTURE_COORD_3;
207 #endif
208 #if defined(GL_MAP2_TEXTURE_COORD_4)
209 case gate_gl_api_capability_map2_texture_coord_4: return GL_MAP2_TEXTURE_COORD_4;
210 #endif
211 #if defined(GL_MAP2_VERTEX_3)
212 case gate_gl_api_capability_map2_vertex_3: return GL_MAP2_VERTEX_3;
213 #endif
214 #if defined(GL_MAP2_VERTEX_4)
215 case gate_gl_api_capability_map2_vertex_4: return GL_MAP2_VERTEX_4;
216 #endif
217 case gate_gl_api_capability_normalize: return GL_NORMALIZE;
218 case gate_gl_api_capability_point_smooth: return GL_POINT_SMOOTH;
219 case gate_gl_api_capability_polygon_offset_fill: return GL_POLYGON_OFFSET_FILL;
220 #if defined(GL_POLYGON_OFFSET_LINE)
221 case gate_gl_api_capability_polygon_offset_line: return GL_POLYGON_OFFSET_LINE;
222 #endif
223 #if defined(GL_POLYGON_OFFSET_POINT)
224 case gate_gl_api_capability_polygon_offset_point: return GL_POLYGON_OFFSET_POINT;
225 #endif
226 #if defined(GL_POLYGON_SMOOTH)
227 case gate_gl_api_capability_polygon_smooth: return GL_POLYGON_SMOOTH;
228 #endif
229 #if defined(GL_POLYGON_STIPPLE)
230 case gate_gl_api_capability_polygon_stipple: return GL_POLYGON_STIPPLE;
231 #endif
232 case gate_gl_api_capability_scissor_test: return GL_SCISSOR_TEST;
233 case gate_gl_api_capability_stencil_test: return GL_STENCIL_TEST;
234 #if defined(GL_TEXTURE_1D)
235 case gate_gl_api_capability_texture_1d: return GL_TEXTURE_1D;
236 #endif
237 case gate_gl_api_capability_texture_2d: return GL_TEXTURE_2D;
238 #if defined(GL_TEXTURE_GEN_Q)
239 case gate_gl_api_capability_texture_gen_q: return GL_TEXTURE_GEN_Q;
240 #endif
241 #if defined(GL_TEXTURE_GEN_R)
242 case gate_gl_api_capability_texture_gen_r: return GL_TEXTURE_GEN_R;
243 #endif
244 #if defined(GL_TEXTURE_GEN_S)
245 case gate_gl_api_capability_texture_gen_s: return GL_TEXTURE_GEN_S;
246 #endif
247 #if defined(GL_TEXTURE_GEN_T)
248 case gate_gl_api_capability_texture_gen_t: return GL_TEXTURE_GEN_T;
249 #endif
250 default: return 0;
251 }
252 }
253
254
255 void gate_gl_api_enable(gate_gl_api_capability_t capability)
256 {
257 gate_gl_api.glEnable(translate_capability(capability));
258 }
259
260 void gate_gl_api_disable(gate_gl_api_capability_t capability)
261 {
262 gate_gl_api.glDisable(translate_capability(capability));
263 }
264
265 void gate_gl_api_depthfunc(gate_gl_api_depth_t depth_function)
266 {
267 GLenum value = 0;
268 switch (depth_function)
269 {
270 case gate_gl_api_depth_never: value = GL_NEVER; break;
271 case gate_gl_api_depth_less: value = GL_LESS; break;
272 case gate_gl_api_depth_lequal: value = GL_LEQUAL; break;
273 case gate_gl_api_depth_equal: value = GL_EQUAL; break;
274 case gate_gl_api_depth_greater: value = GL_GREATER; break;
275 case gate_gl_api_depth_notequal:value = GL_NOTEQUAL;break;
276 case gate_gl_api_depth_gequal: value = GL_GEQUAL; break;
277 case gate_gl_api_depth_always: value = GL_ALWAYS; break;
278 }
279 gate_gl_api.glDepthFunc(value);
280 }
281
282 void gate_gl_api_depthmask(gate_bool_t enabled)
283 {
284 gate_gl_api.glDepthMask(enabled ? GL_TRUE : GL_FALSE);
285 }
286
287 void gate_gl_api_hint(gate_gl_api_hint_t hint_type, gate_gl_api_hintmode_t hint_mode)
288 {
289 GLenum ht = 0, hm = 0;
290 switch (hint_type)
291 {
292 case gate_gl_api_hint_fog_hint: ht = GL_FOG_HINT; break;
293 case gate_gl_api_hint_line_smooth_hint: ht = GL_LINE_SMOOTH_HINT; break;
294 case gate_gl_api_hint_perspective_correction_hint: ht = GL_PERSPECTIVE_CORRECTION_HINT;break;
295 case gate_gl_api_hint_point_smooth_hint: ht = GL_POINT_SMOOTH_HINT; break;
296 #if defined(GL_POLYGON_SMOOTH_HINT)
297 case gate_gl_api_hint_polygon_smooth_hint: ht = GL_POLYGON_SMOOTH_HINT; break;
298 #endif
299 default: ht = 0; break;
300 }
301
302 switch (hint_mode)
303 {
304 case gate_gl_api_hintmode_fastest: hm = GL_FASTEST; break;
305 case gate_gl_api_hintmode_nicest: hm = GL_NICEST; break;
306 case gate_gl_api_hintmode_dont_care: hm = GL_DONT_CARE; break;
307 }
308
309 gate_gl_api.glHint(ht, hm);
310 }
311
312 void gate_gl_api_viewport(gate_int32_t x, gate_int32_t y, gate_int32_t width, gate_int32_t height)
313 {
314 gate_gl_api.glViewport(x, y, width, height);
315 }
316
317 void gate_gl_api_matrixmode(gate_gl_api_matrixmode_t matrix_mode)
318 {
319 GLenum mm = 0;
320 switch (matrix_mode)
321 {
322 case gate_gl_api_matrixmode_modelview: mm = GL_MODELVIEW; break;
323 case gate_gl_api_matrixmode_projection: mm = GL_PROJECTION; break;
324 case gate_gl_api_matrixmode_texture: mm = GL_TEXTURE; break;
325 }
326 gate_gl_api.glMatrixMode(mm);
327 }
328
329 void gate_gl_api_loadidentity()
330 {
331 gate_gl_api.glLoadIdentity();
332 }
333
334 void gate_gl_api_multmatrix(gate_real32_t const matrix[16])
335 {
336 gate_gl_api.glMultMatrixf(matrix);
337 }
338
339 void gate_gl_api_translate(gate_real32_t x, gate_real32_t y, gate_real32_t z)
340 {
341 gate_gl_api.glTranslatef(x, y, z);
342 }
343
344 void gate_gl_api_rotate(gate_real32_t angle, gate_real32_t x, gate_real32_t y, gate_real32_t z)
345 {
346 gate_gl_api.glRotatef(angle, x, y, z);
347 }
348
349
350 void gate_gl_api_flush()
351 {
352 gate_gl_api.glFlush();
353 }
354
355 void gate_gl_api_finish()
356 {
357 gate_gl_api.glFinish();
358 }
359
360 void gate_gl_api_clear(unsigned clear_bits)
361 {
362 GLbitfield bf = 0;
363
364 if (clear_bits & gate_gl_api_clearbit_color_buffer_bit)
365 {
366 bf |= GL_COLOR_BUFFER_BIT;
367 }
368 if (clear_bits & gate_gl_api_clearbit_depth_buffer_bit)
369 {
370 bf |= GL_DEPTH_BUFFER_BIT;
371 }
372 if (clear_bits & gate_gl_api_clearbit_accum_buffer_bit)
373 {
374 #if defined(GL_ACCUM_BUFFER_BIT)
375 bf |= GL_ACCUM_BUFFER_BIT;
376 #endif
377 }
378 if (clear_bits & gate_gl_api_clearbit_stencil_buffer_bit)
379 {
380 bf |= GL_STENCIL_BUFFER_BIT;
381 }
382 gate_gl_api.glClear(bf);
383 }
384
385 void gate_gl_api_perspective(gate_real32_t fovy, gate_real32_t aspect, gate_real32_t znear, gate_real32_t zfar)
386 {
387 gate_real32_t f = (gate_real32_t)(1.0 / gate_math_tan(gate_math_deg2rad(fovy) / 2.0));
388 GLfloat a = f / aspect;
389 GLfloat m[16];
390 m[0] = a; m[1] = 0; m[2] = 0; m[3] = 0;
391 m[4] = 0; m[5] = f; m[6] = 0; m[7] = 0;
392 m[8] = 0; m[9] = 0; m[10] = (zfar + znear) / (znear - zfar); m[11] = -1.0f;
393 m[12] = 0; m[13] = 0; m[14] = (2.0f * zfar * znear) / (znear - zfar); m[15] = 0;
394 gate_gl_api.glMultMatrixf(m);
395 }
396
397
398 static void math_cross_prod(float x1, float y1, float z1, float x2, float y2, float z2, float res[3])
399 {
400 res[0] = y1 * z2 - y2 * z1;
401 res[1] = x2 * z1 - x1 * z2;
402 res[2] = x1 * y2 - x2 * y1;
403 }
404
405 /* https://www.khronos.org/message_boards/showthread.php/4991-The-Solution-for-gluLookAt%28%29-Function!!!! */
406 /* https://community.khronos.org/t/the-solution-for-glulookat-function/521 */
407
408 static double square(double const arg)
409 {
410 return arg * arg;
411 }
412
413
414 void gate_gl_api_lookat(gate_real32_t eyeX, gate_real32_t eyeY, gate_real32_t eyeZ,
415 gate_real32_t lookX, gate_real32_t lookY, gate_real32_t lookZ,
416 gate_real32_t upX, gate_real32_t upY, gate_real32_t upZ)
417 {
418 float f[3];
419 float fMag;
420 float upMag;
421 float s[3], u[3];
422 float M[16];
423
424
425 f[0] = lookX - eyeX;
426 f[1] = lookY - eyeY;
427 f[2] = lookZ - eyeZ;
428
429 fMag = (float)gate_math_sqrt(square(f[0]) + square(f[1]) + square(f[2]));
430 upMag = (float)gate_math_sqrt(square(upX) + square(upY) + square(upZ));
431
432 if (fMag != 0)
433 {
434 f[0] = f[0] / fMag;
435 f[1] = f[1] / fMag;
436 f[2] = f[2] / fMag;
437 }
438
439 if (upMag != 0)
440 {
441 upX = upX / upMag;
442 upY = upY / upMag;
443 upZ = upZ / upMag;
444 }
445
446 math_cross_prod(f[0], f[1], f[2], upX, upY, upZ, s);
447 math_cross_prod(s[0], s[1], s[2], f[0], f[1], f[2], u);
448
449 M[0] = s[0]; M[1] = u[0]; M[2] = -f[0]; M[3] = 0;
450 M[4] = s[1]; M[5] = u[1]; M[6] = -f[1]; M[7] = 0;
451 M[8] = s[2]; M[9] = u[2]; M[10] = -f[2]; M[11] = 0;
452 M[12] = 0; M[13] = 0; M[14] = 0; M[15] = 1;
453
454 gate_gl_api.glMultMatrixf(M);
455 gate_gl_api.glTranslatef(-eyeX, -eyeY, -eyeZ);
456 }
457
458 void gate_gl_api_ortho(gate_real32_t left, gate_real32_t right, gate_real32_t bottom, gate_real32_t top, gate_real32_t near_val, gate_real32_t far_val)
459 {
460 gate_gl_api.glOrtho(left, right, bottom, top, near_val, far_val);
461 }
462
463
464 static GLenum translate_clientstate(gate_gl_api_clientstate_t client_state)
465 {
466 switch (client_state)
467 {
468 case gate_gl_api_clientstate_color_array: return GL_COLOR_ARRAY;
469 #if defined(GL_EDGE_FLAG_ARRAY)
470 case gate_gl_api_clientstate_edge_flag_array: return GL_EDGE_FLAG_ARRAY;
471 #endif
472 #if defined(GL_INDEX_ARRAY)
473 case gate_gl_api_clientstate_index_array: return GL_INDEX_ARRAY;
474 #endif
475 case gate_gl_api_clientstate_normal_array: return GL_NORMAL_ARRAY;
476 case gate_gl_api_clientstate_texture_coord_array: return GL_TEXTURE_COORD_ARRAY;
477 case gate_gl_api_clientstate_vertex_array: return GL_VERTEX_ARRAY;
478 default: return 0;
479 }
480 }
481
482 void gate_gl_api_enableclientstate(gate_gl_api_clientstate_t state)
483 {
484 gate_gl_api.glEnableClientState(translate_clientstate(state));
485 }
486
487 void gate_gl_api_disableclientstate(gate_gl_api_clientstate_t state)
488 {
489 gate_gl_api.glDisableClientState(translate_clientstate(state));
490 }
491
492 static GLenum translate_draw_mode(gate_gl_api_drawmode_t draw_mode)
493 {
494 GLenum ret = 0;
495 switch (draw_mode)
496 {
497 case gate_gl_api_drawmode_points: ret = GL_POINTS; break;
498 case gate_gl_api_drawmode_lines: ret = GL_LINES; break;
499 case gate_gl_api_drawmode_line_loop: ret = GL_LINE_LOOP; break;
500 case gate_gl_api_drawmode_line_strip: ret = GL_LINE_STRIP; break;
501 case gate_gl_api_drawmode_triangles: ret = GL_TRIANGLES; break;
502 case gate_gl_api_drawmode_triangle_strip: ret = GL_TRIANGLE_STRIP; break;
503 case gate_gl_api_drawmode_triangle_fan: ret = GL_TRIANGLE_FAN; break;
504 #if defined(GL_QUADS)
505 case gate_gl_api_drawmode_quads: ret = GL_QUADS; break;
506 #endif
507 #if defined(GL_QUAD_STRIP)
508 case gate_gl_api_drawmode_quad_strip: ret = GL_QUAD_STRIP; break;
509 #endif
510 #if defined(GL_POLYGON)
511 case gate_gl_api_drawmode_polygon: ret = GL_POLYGON; break;
512 #endif
513 default: ret = 0; break;
514 }
515 return ret;
516 }
517
518 void gate_gl_api_drawarrays(gate_gl_api_drawmode_t draw_mode, int index, size_t count)
519 {
520 gate_gl_api.glDrawArrays(translate_draw_mode(draw_mode), (GLint)index, (GLsizei)count);
521 }
522
523 void* gate_gl_api_createtexture(gate_gl_api_pixelformat_t pixel_format,
524 gate_uint32_t width, gate_uint32_t height, void const* data)
525 {
526 GLenum format;
527 GLenum datatype;
528 GLuint tex;
529 GLenum paramFilter = GL_LINEAR;
530 GLint internalFormat =
531 #if defined(GATE_GRAPHICS_OPENGL2_SUPPORT)
532 GL_RGBA;
533 #elif defined(GL_RGBA8)
534 GL_RGBA8;
535 #elif defined(GL_RGB8)
536 GL_RGB8;
537 #else
538 GL_RGBA;
539 #endif
540
541 switch (pixel_format)
542 {
543 case gate_gl_api_pixelformat_rgb:
544 {
545 format = GL_RGB;
546 datatype = GL_UNSIGNED_BYTE;
547 break;
548 }
549 case gate_gl_api_pixelformat_rgba:
550 {
551 format = GL_RGBA;
552 datatype = GL_UNSIGNED_BYTE;
553 break;
554 }
555 default:
556 {
557 /* not supported */
558 return 0;
559 }
560 }
561
562 #if !defined(GATE_GRAPHICS_OPENGL2_SUPPORT)
563 gate_gl_api.glEnable(GL_TEXTURE_2D);
564 #endif
565 gate_gl_api.glGenTextures(1, &tex);
566 gate_gl_api.glBindTexture(GL_TEXTURE_2D, tex);
567
568 gate_gl_api.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, paramFilter);
569 gate_gl_api.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, paramFilter);
570
571 gate_gl_api.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
572 gate_gl_api.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
573
574 gate_gl_api.glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, datatype, data);
575
576 #if !defined(GATE_GRAPHICS_OPENGL2_SUPPORT)
577 gate_gl_api.glDisable(GL_TEXTURE_2D);
578 #endif
579
580 return (void*)(gate_uintptr_t)(tex);
581 }
582
583 void gate_gl_api_deletetexture(void* texture_id)
584 {
585 GLuint tex = (GLuint)(gate_uintptr_t)(texture_id);
586 gate_gl_api.glDeleteTextures(1, &tex);
587 }
588
589 void gate_gl_api_bindtexture(void* texture_id)
590 {
591 GLuint tex = (GLuint)(gate_uintptr_t)texture_id;
592 gate_gl_api.glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
593 gate_gl_api.glBindTexture(GL_TEXTURE_2D, tex);
594 }
595
596 void gate_gl_api_cullface(gate_gl_api_cullface_t mode)
597 {
598 GLenum value = GL_FRONT_AND_BACK;
599 switch (mode)
600 {
601 case gate_gl_api_cullface_front: value = GL_FRONT; break;
602 case gate_gl_api_cullface_back: value = GL_BACK; break;
603 case gate_gl_api_cullface_front_and_back: value = GL_FRONT_AND_BACK; break;
604 }
605 gate_gl_api.glCullFace(value);
606 }
607
608
609
610 #if defined(GATE_GRAPHICS_OPENGL2_SUPPORT)
611
612 #if defined(GATE_SYS_WASM)
613 # define GATE_GL2_DIRECT_CALL
614 #endif
615
616 #if defined(GATE_GL2_DIRECT_CALL)
617 # define GL2CALL(func) func
618 #else
619 # define GL2CALL(func) gate_gl2_api. func
620 #endif
621
622
623 gate_uintptr_t gate_gl2_api_create_shader(gate_gl2_api_shader_type_t type)
624 {
625 GLenum itype = GL_VERTEX_SHADER;
626 switch(type)
627 {
628 case gate_gl2_api_shader_type_compute: itype = GL_COMPUTE_SHADER; break;
629 case gate_gl2_api_shader_type_vertex: itype = GL_VERTEX_SHADER; break;
630 case gate_gl2_api_shader_type_tess_control: itype = GL_TESS_CONTROL_SHADER; break;
631 case gate_gl2_api_shader_type_tess_evaluation: itype = GL_TESS_EVALUATION_SHADER; break;
632 case gate_gl2_api_shader_type_geometry: itype = GL_GEOMETRY_SHADER; break;
633 case gate_gl2_api_shader_type_fragment: itype = GL_FRAGMENT_SHADER; break;
634 }
635 return (gate_uintptr_t) GL2CALL(glCreateShader)(itype);
636 }
637 void gate_gl2_api_shader_source(gate_uintptr_t shader, gate_size_t count, char const * const * code, gate_size_t const* length)
638 {
639 GLint const iLength = length ? (GLint)*length : 0;
640 GL2CALL(glShaderSource)((GLuint)shader, (GLsizei)count, code, length ? &iLength : NULL);
641 }
642 void gate_gl2_api_compile_shader(gate_uintptr_t shader)
643 {
644 GL2CALL(glCompileShader)((GLuint)shader);
645 }
646 void gate_gl2_api_get_shader_iv(gate_uintptr_t shader, gate_gl2_api_shader_param_t param_name, gate_intptr_t* params)
647 {
648 GLenum pname = GL_SHADER_TYPE;
649 GLint iparam = (GLint)*params;
650 switch(param_name)
651 {
652 case gate_gl2_api_shader_param_type: pname = GL_SHADER_TYPE; break;
653 case gate_gl2_api_shader_param_delete_status: pname = GL_DELETE_STATUS; break;
654 case gate_gl2_api_shader_param_compile_status: pname = GL_COMPILE_STATUS; break;
655 case gate_gl2_api_shader_param_info_log_length: pname = GL_INFO_LOG_LENGTH; break;
656 case gate_gl2_api_shader_param_source_length: pname = GL_SHADER_SOURCE_LENGTH; break;
657 }
658 GL2CALL(glGetShaderiv)(shader, pname, &iparam);
659 *params = (gate_intptr_t)iparam;
660 }
661 void gate_gl2_api_get_shader_info_log(gate_uintptr_t shader, gate_size_t maxLength, gate_size_t* length, char* infoLog)
662 {
663 GLsizei max_length = (GLsizei)maxLength;
664 GLsizei len = max_length;
665 GLchar* ptr_info = (GLchar*)infoLog;
666 GL2CALL(glGetShaderInfoLog)((GLuint)shader, max_length, &len, ptr_info);
667 }
668 void gate_gl2_api_delete_shader(gate_uintptr_t shader)
669 {
670 GL2CALL(glDeleteShader)((GLuint)shader);
671 }
672
673
674 gate_uintptr_t gate_gl2_api_create_program(void)
675 {
676 return GL2CALL(glCreateProgram)();
677 }
678 void gate_gl2_api_link_program(gate_uintptr_t program)
679 {
680 GL2CALL(glLinkProgram)((GLuint)program);
681 }
682 void gate_gl2_api_get_program_iv(gate_uintptr_t program, gate_gl2_api_program_param_t param_name, gate_intptr_t* params)
683 {
684 GLenum pname = GL_LINK_STATUS;
685 GLint iparams = (GLint)*params;
686 switch(param_name)
687 {
688 case gate_gl2_api_program_param_active_attributes: pname = GL_ACTIVE_ATTRIBUTES; break;
689 case gate_gl2_api_program_param_active_attribute_max_length: pname = GL_ACTIVE_ATTRIBUTE_MAX_LENGTH; break;
690 case gate_gl2_api_program_param_active_uniforms: pname = GL_ACTIVE_UNIFORMS; break;
691 case gate_gl2_api_program_param_active_uniform_blocks: pname = GL_ACTIVE_UNIFORM_BLOCKS; break;
692 case gate_gl2_api_program_param_active_uniform_block_max_name_length: pname = GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH; break;
693 case gate_gl2_api_program_param_active_uniform_max_length: pname = GL_ACTIVE_UNIFORM_MAX_LENGTH; break;
694 case gate_gl2_api_program_param_attached_shaders: pname = GL_ATTACHED_SHADERS; break;
695 case gate_gl2_api_program_param_delete_status: pname = GL_DELETE_STATUS; break;
696 case gate_gl2_api_program_param_info_log_length: pname = GL_INFO_LOG_LENGTH; break;
697 case gate_gl2_api_program_param_link_status: pname = GL_LINK_STATUS; break;
698 case gate_gl2_api_program_param_program_binary_retrievable_hint: pname = GL_PROGRAM_BINARY_RETRIEVABLE_HINT; break;
699 case gate_gl2_api_program_param_transform_feedback_buffer_mode: pname = GL_TRANSFORM_FEEDBACK_BUFFER_MODE; break;
700 case gate_gl2_api_program_param_transform_feedback_varyings: pname = GL_TRANSFORM_FEEDBACK_VARYINGS; break;
701 case gate_gl2_api_program_param_transform_feedback_varying_max_length: pname = GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH; break;
702 case gate_gl2_api_program_param_validate_status: pname = GL_VALIDATE_STATUS; break;
703 }
704 GL2CALL(glGetProgramiv)(program, pname, &iparams);
705 *params = (gate_intptr_t)iparams;
706 }
707 void gate_gl2_api_get_program_info_log(gate_uintptr_t program, gate_size_t bufSize, gate_size_t* length, char* infoLog)
708 {
709 GLsizei len = *length;
710 GL2CALL(glGetProgramInfoLog)((GLuint)program, (GLsizei)bufSize, &len, infoLog);
711 *length = len;
712 }
713
714 void gate_gl2_api_use_program(gate_uintptr_t program)
715 {
716 GL2CALL(glUseProgram)((GLuint)program);
717 }
718 void gate_gl2_api_attach_shader(gate_uintptr_t program, gate_uintptr_t shader)
719 {
720 GL2CALL(glAttachShader)((GLuint)program, (GLuint)shader);
721 }
722 void gate_gl2_api_delete_program(gate_uintptr_t program)
723 {
724 GL2CALL(glDeleteProgram)((GLuint)program);
725 }
726 void gate_gl2_api_bind_attrib_location(gate_uintptr_t program, gate_size_t index, char const* name)
727 {
728 GL2CALL(glBindAttribLocation)((GLuint)program, (GLuint)index, name);
729 }
730 gate_intptr_t gate_gl2_api_get_attrib_location(gate_uintptr_t program, char const* name)
731 {
732 return GL2CALL(glGetAttribLocation)((GLuint)program, name);
733 }
734 gate_intptr_t gate_gl2_api_get_uniform_location(gate_uintptr_t program, char const* name)
735 {
736 return GL2CALL(glGetUniformLocation)((GLuint)program, name);
737 }
738
739
740 void gate_gl2_api_gen_buffers(gate_size_t n, unsigned int* buffers)
741 {
742 GL2CALL(glGenBuffers)((GLsizei)n, buffers);
743 }
744 void gate_gl2_api_delete_buffers(gate_size_t n, unsigned int const * buffers)
745 {
746 GL2CALL(glDeleteBuffers)((GLsizei)n, buffers);
747 }
748
749 static GLenum convert_target(gate_gl2_api_buffer_type_t target_type)
750 {
751 switch(target_type)
752 {
753 default:
754 case gate_gl2_api_buffer_type_array: return GL_ARRAY_BUFFER;
755 case gate_gl2_api_buffer_type_atomic_counter: return GL_ATOMIC_COUNTER_BUFFER;
756 case gate_gl2_api_buffer_type_copy_read: return GL_COPY_READ_BUFFER;
757 case gate_gl2_api_buffer_type_copy_write: return GL_COPY_WRITE_BUFFER;
758 case gate_gl2_api_buffer_type_dispatch_indirect: return GL_DISPATCH_INDIRECT_BUFFER;
759 case gate_gl2_api_buffer_type_draw_indirect: return GL_DRAW_INDIRECT_BUFFER;
760 case gate_gl2_api_buffer_type_element_array: return GL_ELEMENT_ARRAY_BUFFER;
761 case gate_gl2_api_buffer_type_pixel_pack: return GL_PIXEL_PACK_BUFFER;
762 case gate_gl2_api_buffer_type_pixel_unpack: return GL_PIXEL_UNPACK_BUFFER;
763 case gate_gl2_api_buffer_type_query: return GL_QUERY_BUFFER;
764 case gate_gl2_api_buffer_type_shader_storage: return GL_SHADER_STORAGE_BUFFER;
765 case gate_gl2_api_buffer_type_texture: return GL_TEXTURE_BUFFER;
766 case gate_gl2_api_buffer_type_transform_feedback: return GL_TRANSFORM_FEEDBACK_BUFFER;
767 case gate_gl2_api_buffer_type_uniform: return GL_UNIFORM_BUFFER;
768 }
769 }
770 void gate_gl2_api_bind_buffers(gate_gl2_api_buffer_type_t target_type, unsigned int buffer)
771 {
772 GLenum target = convert_target(target_type);
773 return GL2CALL(glBindBuffer)(target, buffer);
774 }
775 static GLenum convert_usage(gate_gl2_api_usage_type_t usage_value)
776 {
777 switch(usage_value)
778 {
779 default:
780 case gate_gl2_api_usage_type_stream_draw: return GL_STREAM_DRAW;
781 case gate_gl2_api_usage_type_stream_read: return GL_STREAM_READ;
782 case gate_gl2_api_usage_type_stream_copy: return GL_STREAM_COPY;
783 case gate_gl2_api_usage_type_static_draw: return GL_STATIC_DRAW;
784 case gate_gl2_api_usage_type_static_read: return GL_STATIC_READ;
785 case gate_gl2_api_usage_type_static_copy: return GL_STATIC_COPY;
786 case gate_gl2_api_usage_type_dynamic_draw: return GL_DYNAMIC_DRAW;
787 case gate_gl2_api_usage_type_dynamic_read: return GL_DYNAMIC_READ;
788 case gate_gl2_api_usage_type_dynamic_copy: return GL_DYNAMIC_COPY;
789 }
790 }
791 void gate_gl2_api_buffer_data(gate_gl2_api_buffer_type_t target_type, gate_size_t size, void const* data, gate_gl2_api_usage_type_t usage_value)
792 {
793 GLenum target = convert_target(target_type);
794 GLenum usage = convert_usage(usage_value);
795 GL2CALL(glBufferData)(target, size, data, usage);
796 }
797 /*
798 void gate_gl2_api_named_buffer_data(unsigned int buffer, gate_size_t size, void const* data, gate_gl2_api_usage_type_t usage_value)
799 {
800 GLenum usage = convert_usage(usage_value);
801 gate_gl2_api.glNamedBufferData(buffer, size, data, usage);
802 }
803 */
804 void gate_gl2_api_vertex_attrib_pointer(gate_uintptr_t index, gate_size_t size, gate_gl2_api_vertex_attrib_type_t type, gate_bool_t normalized, gate_size_t stride, void const* pointer)
805 {
806 GLenum vtype = GL_INT;
807 GLboolean bnorm = normalized ? GL_TRUE : GL_FALSE;
808 switch(type)
809 {
810 case gate_gl2_api_vertex_attrib_byte: vtype = GL_BYTE; break;
811 case gate_gl2_api_vertex_attrib_unsigned_byte: vtype = GL_UNSIGNED_BYTE; break;
812 case gate_gl2_api_vertex_attrib_short: vtype = GL_SHORT; break;
813 case gate_gl2_api_vertex_attrib_unsigned_short: vtype = GL_UNSIGNED_SHORT; break;
814 case gate_gl2_api_vertex_attrib_int: vtype = GL_INT; break;
815 case gate_gl2_api_vertex_attrib_half_float: vtype = GL_HALF_FLOAT; break;
816 case gate_gl2_api_vertex_attrib_float: vtype = GL_FLOAT; break;
817 case gate_gl2_api_vertex_attrib_double: vtype = GL_DOUBLE; break;
818 case gate_gl2_api_vertex_attrib_fixed: vtype = GL_FIXED; break;
819 case gate_gl2_api_vertex_attrib_int_2_10_10_10_rev: vtype = GL_INT_2_10_10_10_REV; break;
820 case gate_gl2_api_vertex_attrib_unsigned_int_2_10_10_10_rev: vtype = GL_UNSIGNED_INT_2_10_10_10_REV; break;
821 case gate_gl2_api_vertex_attrib_unsigned_int_10F_11F_11F_rev: vtype = GL_UNSIGNED_INT_10F_11F_11F_REV; break;
822 }
823
824 GL2CALL(glVertexAttribPointer)((GLuint)index, (GLint)size, vtype, bnorm, (GLsizei)stride, pointer);
825 }
826
827 void gate_gl2_api_enable_vertex_attrib_array(gate_uintptr_t index)
828 {
829 GL2CALL(glEnableVertexAttribArray)((GLuint)index);
830 }
831 void gate_gl2_api_disable_vertex_attrib_array(gate_uintptr_t index)
832 {
833 GL2CALL(glDisableVertexAttribArray)((GLuint)index);
834 }
835 void gate_gl2_api_active_texture(gate_uintptr_t texture_index)
836 {
837 GLenum param = GL_TEXTURE0 + texture_index;
838 GL2CALL(glActiveTexture)(param);
839 }
840
841
842 void gate_gl2_api_uniform1f(gate_intptr_t location, gate_real32_t v0)
843 {
844 GL2CALL(glUniform1f)(location, v0);
845 }
846 void gate_gl2_api_uniform2f(gate_intptr_t location, gate_real32_t v0, gate_real32_t v1)
847 {
848 GL2CALL(glUniform2f)(location, v0, v1);
849 }
850 void gate_gl2_api_uniform3f(gate_intptr_t location, gate_real32_t v0, gate_real32_t v1, gate_real32_t v2)
851 {
852 GL2CALL(glUniform3f)(location, v0, v1, v2);
853 }
854 void gate_gl2_api_uniform4f(gate_intptr_t location, gate_real32_t v0, gate_real32_t v1, gate_real32_t v2, gate_real32_t v3)
855 {
856 GL2CALL(glUniform4f)(location, v0, v1, v2, v3);
857 }
858 void gate_gl2_api_uniform1fv(gate_intptr_t location, gate_size_t count,const gate_real32_t *value)
859 {
860 GL2CALL(glUniform1fv)(location, count, value);
861 }
862 void gate_gl2_api_uniform2fv(gate_intptr_t location, gate_size_t count, const gate_real32_t *value)
863 {
864 GL2CALL(glUniform2fv)(location, count, value);
865 }
866 void gate_gl2_api_uniform3fv(gate_intptr_t location, gate_size_t count, const gate_real32_t *value)
867 {
868 GL2CALL(glUniform3fv)(location, count, value);
869 }
870 void gate_gl2_api_uniform4fv(gate_intptr_t location, gate_size_t count, const gate_real32_t *value)
871 {
872 GL2CALL(glUniform4fv)(location, count, value);
873 }
874 void gate_gl2_api_uniform1i(gate_intptr_t location, int v0)
875 {
876 GL2CALL(glUniform1i)(location, v0);
877 }
878 void gate_gl2_api_uniform2i(gate_intptr_t location, int v0, int v1)
879 {
880 GL2CALL(glUniform2i)(location, v0, v1);
881 }
882 void gate_gl2_api_uniform3i(gate_intptr_t location, int v0, int v1, int v2)
883 {
884 GL2CALL(glUniform3i)(location, v0, v1, v2);
885 }
886 void gate_gl2_api_uniform4i(gate_intptr_t location, int v0, int v1, int v2, int v3)
887 {
888 GL2CALL(glUniform4i)(location, v0, v1, v2, v3);
889 }
890 void gate_gl2_api_uniform1iv(gate_intptr_t location, gate_size_t count, const int *value)
891 {
892 GL2CALL(glUniform1iv)(location, count, value);
893 }
894 void gate_gl2_api_uniform2iv(gate_intptr_t location, gate_size_t count, const int *value)
895 {
896 GL2CALL(glUniform2iv)(location, count, value);
897 }
898 void gate_gl2_api_uniform3iv(gate_intptr_t location, gate_size_t count, const int *value)
899 {
900 GL2CALL(glUniform3iv)(location, count, value);
901 }
902 void gate_gl2_api_uniform4iv(gate_intptr_t location, gate_size_t count, const int *value)
903 {
904 GL2CALL(glUniform4iv)(location, count, value);
905 }
906
907
908 void gate_gl2_api_uniform_matrix2fv(gate_intptr_t location, gate_size_t count, gate_bool_t transpose, const gate_real32_t *value)
909 {
910 GL2CALL(glUniformMatrix2fv)(location, count, transpose, value);
911 }
912 void gate_gl2_api_uniform_matrix3fv(gate_intptr_t location, gate_size_t count, gate_bool_t transpose, const gate_real32_t *value)
913 {
914 GL2CALL(glUniformMatrix3fv)(location, count, transpose, value);
915 }
916 void gate_gl2_api_uniform_matrix4fv(gate_intptr_t location, gate_size_t count, gate_bool_t transpose, const gate_real32_t *value)
917 {
918 GL2CALL(glUniformMatrix4fv)(location, count, transpose, value);
919 }
920
921
922
923 #endif /* GATE_GRAPHICS_OPENGL2_SUPPORT */
924
925
926
927 #if defined(GATE_GL_API_WINAPI)
928
929 #include "gate/graphics/platform/opengl_winapi_impl.h"
930
931 #endif /* GATE_GL_API_WINAPI */
932
933
934
935 #if defined(GATE_GL_API_GLUT)
936
937 #include "gate/graphics/platform/opengl_glut_impl.h"
938
939 #endif /* GATE_GL_API_GLUT */
940
941
942
943 #if defined(GATE_GL_API_EGL)
944
945 # include "gate/graphics/platform/opengl_egl_apis.h"
946
947 # if defined(GATE_SYS_WINCE)
948 # elif defined(GATE_SYS_WASM)
949 # include "gate/graphics/platform/opengl_emscripten_impl.h"
950 # elif defined(GATE_SYS_ANDROID)
951 # include "gate/graphics/platform/opengl_android_impl.h"
952 # else
953 # include "gate/graphics/platform/opengl_xlib_impl.h"
954 # endif
955
956 #endif /* GATE_GL_API_EGL */
957
958
959 #endif /* GATE_GRAPHICS_GL_OPENGL */
960
961
962
963 #if defined(GATE_GARPHICS_GL_NOIMPL)
964
965
966 gate_result_t gate_gl_surface_init(gate_gl_surface_t* surface)
967 {
968 (void)surface;
969 return GATE_RESULT_NOTIMPLEMENTED;
970 }
971 gate_result_t gate_gl_surface_uninit(gate_gl_surface_t* surface)
972 {
973 (void)surface;
974 return GATE_RESULT_NOTIMPLEMENTED;
975 }
976 gate_result_t gate_gl_surface_open(gate_gl_surface_t* surface, gate_gl_surface_type_t type,
977 gate_uint32_t width, gate_uint32_t height, gate_enumint_t flags)
978 {
979 (void)surface;
980 (void)type;
981 (void)width;
982 (void)height;
983 (void)flags;
984 return GATE_RESULT_NOTIMPLEMENTED;
985 }
986 gate_result_t gate_gl_surface_close(gate_gl_surface_t* surface)
987 {
988 (void)surface;
989 return GATE_RESULT_NOTIMPLEMENTED;
990 }
991 gate_result_t gate_gl_surface_resize(gate_gl_surface_t* surface, gate_uint32_t width, gate_uint32_t height)
992 {
993 (void)surface;
994 (void)width;
995 (void)height;
996 return GATE_RESULT_NOTIMPLEMENTED;
997 }
998 gate_result_t gate_gl_surface_get_size(gate_gl_surface_t* surface, gate_uint32_t* width, gate_uint32_t* height)
999 {
1000 (void)surface;
1001 (void)width;
1002 (void)height;
1003 return GATE_RESULT_NOTIMPLEMENTED;
1004 }
1005 gate_result_t gate_gl_surface_print_image(gate_gl_surface_t* surface, gate_rasterimage_t* target_image)
1006 {
1007 (void)surface;
1008 (void)target_image;
1009 return GATE_RESULT_NOTIMPLEMENTED;
1010 }
1011 gate_result_t gate_gl_surface_run_event_loop(gate_gl_surface_t* surface,
1012 gate_gl_surface_events_t* event_callbacks, void* user_param)
1013 {
1014 (void)surface;
1015 (void)event_callbacks;
1016 (void)user_param;
1017 return GATE_RESULT_NOTIMPLEMENTED;
1018 }
1019 gate_result_t gate_gl_surface_exit_event_loop(gate_gl_surface_t* surface)
1020 {
1021 (void)surface;
1022 return GATE_RESULT_NOTIMPLEMENTED;
1023 }
1024 gate_result_t gate_gl_surface_swap_buffers(gate_gl_surface_t* surface)
1025 {
1026 (void)surface;
1027 return GATE_RESULT_NOTIMPLEMENTED;
1028 }
1029
1030
1031
1032 gate_result_t gate_gl_api_init()
1033 {
1034 return GATE_RESULT_NOTIMPLEMENTED;
1035 }
1036
1037 void gate_gl_api_color3(gate_real32_t r, gate_real32_t g, gate_real32_t b)
1038 {
1039 (void)r;
1040 (void)g;
1041 (void)b;
1042 }
1043 void gate_gl_api_color4(gate_real32_t r, gate_real32_t g, gate_real32_t b, gate_real32_t a)
1044 {
1045 (void)r;
1046 (void)g;
1047 (void)b;
1048 (void)a;
1049 }
1050 void gate_gl_api_color3b(gate_uint8_t r, gate_uint8_t g, gate_uint8_t b)
1051 {
1052 (void)r;
1053 (void)g;
1054 (void)b;
1055 }
1056 void gate_gl_api_color4b(gate_uint8_t r, gate_uint8_t g, gate_uint8_t b, gate_uint8_t a)
1057 {
1058 (void)r;
1059 (void)g;
1060 (void)b;
1061 (void)a;
1062 }
1063 void gate_gl_api_vertexpointer(gate_size_t coord_count, gate_real32_t const* ptr_coords)
1064 {
1065 (void)coord_count;
1066 (void)ptr_coords;
1067 }
1068 void gate_gl_api_texcoordpointer(gate_size_t coord_count, gate_real32_t const* ptr_coords)
1069 {
1070 (void)coord_count;
1071 (void)ptr_coords;
1072 }
1073 void gate_gl_api_shademodel(gate_gl_api_shademodel_t model)
1074 {
1075 (void)model;
1076 }
1077 void gate_gl_api_blendfunc(gate_gl_api_blend_t blend_func_src, gate_gl_api_blend_t blend_func_dst)
1078 {
1079 (void)blend_func_src;
1080 (void)blend_func_dst;
1081 }
1082 void gate_gl_api_clearcolor(gate_real32_t r, gate_real32_t g, gate_real32_t b, gate_real32_t a)
1083 {
1084 (void)r;
1085 (void)g;
1086 (void)b;
1087 (void)a;
1088 }
1089 void gate_gl_api_cleardepth(gate_real32_t depth)
1090 {
1091 (void)depth;
1092 }
1093 void gate_gl_api_enable(gate_gl_api_capability_t capability)
1094 {
1095 (void)capability;
1096 }
1097 void gate_gl_api_disable(gate_gl_api_capability_t capability)
1098 {
1099 (void)capability;
1100 }
1101 void gate_gl_api_depthfunc(gate_gl_api_depth_t depth_function)
1102 {
1103 (void)depth_function;
1104 }
1105 void gate_gl_api_depthmask(gate_bool_t enabled)
1106 {
1107 (void)enabled;
1108 }
1109 void gate_gl_api_hint(gate_gl_api_hint_t hint_type, gate_gl_api_hintmode_t hint_mode)
1110 {
1111 (void)hint_type;
1112 (void)hint_mode;
1113 }
1114 void gate_gl_api_viewport(gate_int32_t x, gate_int32_t y, gate_int32_t width, gate_int32_t height)
1115 {
1116 (void)x;
1117 (void)y;
1118 (void)width;
1119 (void)height;
1120 }
1121 void gate_gl_api_matrixmode(gate_gl_api_matrixmode_t matrix_mode)
1122 {
1123 (void)matrix_mode;
1124 }
1125 void gate_gl_api_loadidentity()
1126 {
1127 }
1128 void gate_gl_api_multmatrix(gate_real32_t const matrix[16])
1129 {
1130 (void)matrix;
1131 }
1132 void gate_gl_api_translate(gate_real32_t x, gate_real32_t y, gate_real32_t z)
1133 {
1134 (void)x;
1135 (void)y;
1136 (void)z;
1137 }
1138 void gate_gl_api_rotate(gate_real32_t angle, gate_real32_t x, gate_real32_t y, gate_real32_t z)
1139 {
1140 (void)angle;
1141 (void)x;
1142 (void)y;
1143 (void)z;
1144 }
1145 void gate_gl_api_flush()
1146 {
1147
1148 }
1149 void gate_gl_api_finish()
1150 {
1151
1152 }
1153 void gate_gl_api_clear(unsigned clear_bits)
1154 {
1155 (void)clear_bits;
1156 }
1157 void gate_gl_api_perspective(gate_real32_t fovy, gate_real32_t aspect, gate_real32_t znear, gate_real32_t zfar)
1158 {
1159 (void)fovy;
1160 (void)aspect;
1161 (void)znear;
1162 (void)zfar;
1163 }
1164 void gate_gl_api_lookat(gate_real32_t eyeX, gate_real32_t eyeY, gate_real32_t eyeZ,
1165 gate_real32_t lookX, gate_real32_t lookY, gate_real32_t lookZ,
1166 gate_real32_t upX, gate_real32_t upY, gate_real32_t upZ)
1167 {
1168 (void)eyeX;
1169 (void)eyeY;
1170 (void)eyeZ;
1171 (void)lookX;
1172 (void)lookY;
1173 (void)lookZ;
1174 (void)upX;
1175 (void)upY;
1176 (void)upZ;
1177 }
1178 void gate_gl_api_ortho(gate_real32_t left, gate_real32_t right, gate_real32_t bottom, gate_real32_t top,
1179 gate_real32_t near_val, gate_real32_t far_val)
1180 {
1181 (void)left;
1182 (void)right;
1183 (void)bottom;
1184 (void)top;
1185 (void)near_val;
1186 (void)far_val;
1187 }
1188 void gate_gl_api_enableclientstate(gate_gl_api_clientstate_t state)
1189 {
1190 (void)state;
1191 }
1192 void gate_gl_api_disableclientstate(gate_gl_api_clientstate_t state)
1193 {
1194 (void)state;
1195 }
1196 void gate_gl_api_drawarrays(gate_gl_api_drawmode_t draw_mode, int index, size_t count)
1197 {
1198 (void)draw_mode;
1199 (void)index;
1200 (void)count;
1201 }
1202 void* gate_gl_api_createtexture(gate_gl_api_pixelformat_t pixel_format, gate_uint32_t width, gate_uint32_t height,
1203 void const* data)
1204 {
1205 (void)pixel_format;
1206 (void)width;
1207 (void)height;
1208 (void)data;
1209 return NULL;
1210 }
1211 void gate_gl_api_deletetexture(void* texture_id)
1212 {
1213 (void)texture_id;
1214 }
1215 void gate_gl_api_bindtexture(void* texture_id)
1216 {
1217 (void)texture_id;
1218 }
1219 void gate_gl_api_cullface(gate_gl_api_cullface_t mode)
1220 {
1221 (void)mode;
1222 }
1223
1224 #endif /* GATE_GRAPHICS_GL_OPENGL */
1225
1226