GCC Code Coverage Report


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