| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gate/graphics/gl_apis.hpp" | ||
| 2 | #include "gate/exceptions.hpp" | ||
| 3 | |||
| 4 | namespace gate | ||
| 5 | { | ||
| 6 | namespace graph | ||
| 7 | { | ||
| 8 | |||
| 9 | 1 | GlApi::GlApi() | |
| 10 | { | ||
| 11 | 1 | result_t result = gate_gl_api_init(); | |
| 12 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 13 | 1 | } | |
| 14 | |||
| 15 | 1 | GlApi::~GlApi() noexcept | |
| 16 | { | ||
| 17 | 1 | } | |
| 18 | |||
| 19 | #if !defined(GATE_GRAPHICS_NO_LEGACY_OPENGL) | ||
| 20 | 40 | void GlApi::enableClientState(ClientStateEnum state) | |
| 21 | { | ||
| 22 | 40 | gate_gl_api_enableclientstate((gate_gl_api_clientstate_t)(int)state); | |
| 23 | 40 | } | |
| 24 | 2 | void GlApi::disableClientState(ClientStateEnum state) | |
| 25 | { | ||
| 26 | 2 | gate_gl_api_disableclientstate((gate_gl_api_clientstate_t)(int)state); | |
| 27 | 2 | } | |
| 28 | 1 | void GlApi::setShadeModel(ShadeModelEnum model) | |
| 29 | { | ||
| 30 | 1 | gate_gl_api_shademodel((gate_gl_api_shademodel_t)(int)model); | |
| 31 | 1 | } | |
| 32 | |||
| 33 | ✗ | void GlApi::mulMatrix(real32_t const matrix[16]) | |
| 34 | { | ||
| 35 | ✗ | gate_gl_api_multmatrix(matrix); | |
| 36 | ✗ | } | |
| 37 | 20 | void GlApi::translate(real32_t x, real32_t y, real32_t z) | |
| 38 | { | ||
| 39 | 20 | gate_gl_api_translate(x, y, z); | |
| 40 | 20 | } | |
| 41 | 20 | void GlApi::rotate(real32_t angle, real32_t x, real32_t y, real32_t z) | |
| 42 | { | ||
| 43 | 20 | gate_gl_api_rotate(angle, x, y, z); | |
| 44 | 20 | } | |
| 45 | |||
| 46 | 1 | void GlApi::setPerspective(real32_t fovy, real32_t aspect, real32_t znear, real32_t zfar) | |
| 47 | { | ||
| 48 | 1 | gate_gl_api_perspective(fovy, aspect, znear, zfar); | |
| 49 | 1 | } | |
| 50 | ✗ | void GlApi::lookAt(real32_t eyeX, real32_t eyeY, real32_t eyeZ, real32_t lookX, real32_t lookY, real32_t lookZ, real32_t upX, real32_t upY, real32_t upZ) | |
| 51 | { | ||
| 52 | ✗ | gate_gl_api_lookat(eyeX, eyeY, eyeZ, lookX, lookY, lookZ, upX, upY, upZ); | |
| 53 | ✗ | } | |
| 54 | |||
| 55 | ✗ | void GlApi::setTexCoordPointer(size_t coord_count, real32_t const* ptr_coords) | |
| 56 | { | ||
| 57 | ✗ | gate_gl_api_texcoordpointer(coord_count, ptr_coords); | |
| 58 | ✗ | } | |
| 59 | |||
| 60 | ✗ | void GlApi::setColor(real32_t r, real32_t g, real32_t b, real32_t a) | |
| 61 | { | ||
| 62 | ✗ | gate_gl_api_color4(r, g, b, a); | |
| 63 | ✗ | } | |
| 64 | ✗ | void GlApi::setColorByte(uint8_t r, uint8_t g, uint8_t b, uint8_t a) | |
| 65 | { | ||
| 66 | ✗ | gate_gl_api_color4b(r, g, b, a); | |
| 67 | ✗ | } | |
| 68 | ✗ | void GlApi::setColor(real32_t r, real32_t g, real32_t b) | |
| 69 | { | ||
| 70 | ✗ | gate_gl_api_color3(r, g, b); | |
| 71 | ✗ | } | |
| 72 | ✗ | void GlApi::setColorByte(uint8_t r, uint8_t g, uint8_t b) | |
| 73 | { | ||
| 74 | ✗ | gate_gl_api_color3b(r, g, b); | |
| 75 | ✗ | } | |
| 76 | |||
| 77 | #endif /* !defined(GATE_GRAPHICS_NO_LEGACY_OPENGL) */ | ||
| 78 | |||
| 79 | 20 | void GlApi::setVertexPointer(size_t coord_count, size_t stride, real32_t const* ptr_coords) | |
| 80 | { | ||
| 81 | 20 | gate_gl_api_vertexpointer(coord_count, stride, ptr_coords); | |
| 82 | 20 | } | |
| 83 | 20 | void GlApi::setColorPointer(size_t color_count, size_t stride, real32_t const* ptr_colors) | |
| 84 | { | ||
| 85 | 20 | gate_gl_api_colorpointer(color_count, stride, ptr_colors); | |
| 86 | 20 | } | |
| 87 | ✗ | void GlApi::setBlendFunc(BlendEnum srcFunc, BlendEnum dstFunc) | |
| 88 | { | ||
| 89 | ✗ | gate_gl_api_blendfunc((gate_gl_api_blend_t)(int)srcFunc, (gate_gl_api_blend_t)(int)dstFunc); | |
| 90 | ✗ | } | |
| 91 | 20 | void GlApi::setClearColor(real32_t r, real32_t g, real32_t b, real32_t a) | |
| 92 | { | ||
| 93 | 20 | gate_gl_api_clearcolor(r, g, b, a); | |
| 94 | 20 | } | |
| 95 | 20 | void GlApi::setClearDepth(real32_t depth) | |
| 96 | { | ||
| 97 | 20 | gate_gl_api_cleardepth(depth); | |
| 98 | 20 | } | |
| 99 | 1 | void GlApi::enableCapability(CapabilityEnum capability) | |
| 100 | { | ||
| 101 | 1 | gate_gl_api_enable((gate_gl_api_capability_t)(int)capability); | |
| 102 | 1 | } | |
| 103 | 1 | void GlApi::disableCapability(CapabilityEnum capability) | |
| 104 | { | ||
| 105 | 1 | gate_gl_api_disable((gate_gl_api_capability_t)(int)capability); | |
| 106 | 1 | } | |
| 107 | ✗ | void GlApi::setDepthFunc(DepthEnum depthFunction) | |
| 108 | { | ||
| 109 | ✗ | gate_gl_api_depthfunc((gate_gl_api_depth_t)(int)depthFunction); | |
| 110 | ✗ | } | |
| 111 | ✗ | void GlApi::setDepthMask(bool_t enabled) | |
| 112 | { | ||
| 113 | ✗ | gate_gl_api_depthmask(enabled); | |
| 114 | ✗ | } | |
| 115 | |||
| 116 | ✗ | void GlApi::setHint(HintEnum hintType, HintModeEnum hintMode) | |
| 117 | { | ||
| 118 | ✗ | gate_gl_api_hint((gate_gl_api_hint_t)(int)hintType, (gate_gl_api_hintmode_t)(int)hintMode); | |
| 119 | ✗ | } | |
| 120 | 1 | void GlApi::setViewport(int32_t x, int32_t y, int32_t width, int32_t height) | |
| 121 | { | ||
| 122 | 1 | gate_gl_api_viewport(x, y, width, height); | |
| 123 | 1 | } | |
| 124 | 2 | void GlApi::setMatrixMode(MatrixModeEnum matrixMode) | |
| 125 | { | ||
| 126 | 2 | gate_gl_api_matrixmode((gate_gl_api_matrixmode_t)(int)matrixMode); | |
| 127 | 2 | } | |
| 128 | 22 | void GlApi::loadIdentity() | |
| 129 | { | ||
| 130 | 22 | gate_gl_api_loadidentity(); | |
| 131 | 22 | } | |
| 132 | |||
| 133 | 20 | void GlApi::flush() | |
| 134 | { | ||
| 135 | 20 | gate_gl_api_flush(); | |
| 136 | 20 | } | |
| 137 | 20 | void GlApi::finish() | |
| 138 | { | ||
| 139 | 20 | gate_gl_api_finish(); | |
| 140 | 20 | } | |
| 141 | 20 | void GlApi::clear(unsigned clearBits) | |
| 142 | { | ||
| 143 | 20 | gate_gl_api_clear(clearBits); | |
| 144 | 20 | } | |
| 145 | 20 | void GlApi::drawArrays(DrawModeEnum drawMode, int index, size_t vertex_count) | |
| 146 | { | ||
| 147 | 20 | gate_gl_api_drawarrays((gate_gl_api_drawmode_t)(int)drawMode, index, vertex_count); | |
| 148 | 20 | } | |
| 149 | ✗ | void* GlApi::createTexture(PixelFormatEnum pixelFormat, uint32_t width, uint32_t height, void const* data) | |
| 150 | { | ||
| 151 | ✗ | return gate_gl_api_createtexture((gate_gl_api_pixelformat_t)(int)pixelFormat, width, height, data); | |
| 152 | } | ||
| 153 | ✗ | void GlApi::deleteTexture(void* textureId) | |
| 154 | { | ||
| 155 | ✗ | gate_gl_api_deletetexture(textureId); | |
| 156 | ✗ | } | |
| 157 | ✗ | void GlApi::bindTexture(void* textureId) | |
| 158 | { | ||
| 159 | ✗ | gate_gl_api_bindtexture(textureId); | |
| 160 | ✗ | } | |
| 161 | 1 | void GlApi::setCullFace(CullFaceEnum cullface) | |
| 162 | { | ||
| 163 | 1 | gate_gl_api_cullface((gate_gl_api_cullface_t)cullface); | |
| 164 | 1 | } | |
| 165 | |||
| 166 | |||
| 167 | #if defined(GATE_GRAPHICS_OPENGL2_SUPPORT) | ||
| 168 | uintptr_t GlApi::createShader(gate_gl2_api_shader_type_t type) | ||
| 169 | { | ||
| 170 | return gate_gl2_api_create_shader(type); | ||
| 171 | } | ||
| 172 | void GlApi::shaderSource(uintptr_t shader, size_t count, char const* const* code, size_t const* length) | ||
| 173 | { | ||
| 174 | gate_gl2_api_shader_source(shader, count, code, length); | ||
| 175 | } | ||
| 176 | void GlApi::compileShader(uintptr_t shader) | ||
| 177 | { | ||
| 178 | gate_gl2_api_compile_shader(shader); | ||
| 179 | } | ||
| 180 | void GlApi::getShaderIv(uintptr_t shader, gate_gl2_api_shader_param_t param_name, intptr_t* params) | ||
| 181 | { | ||
| 182 | gate_gl2_api_get_shader_iv(shader, param_name, params); | ||
| 183 | } | ||
| 184 | void GlApi::getShaderInfoLog(uintptr_t shader, size_t max_length, size_t& len_used, char* info_buffer) | ||
| 185 | { | ||
| 186 | gate_gl2_api_get_shader_info_log(shader, max_length, &len_used, info_buffer); | ||
| 187 | } | ||
| 188 | |||
| 189 | void GlApi::deleteShader(uintptr_t shader) | ||
| 190 | { | ||
| 191 | gate_gl2_api_delete_shader(shader); | ||
| 192 | } | ||
| 193 | |||
| 194 | uintptr_t GlApi::createProgram(void) | ||
| 195 | { | ||
| 196 | return gate_gl2_api_create_program(); | ||
| 197 | } | ||
| 198 | void GlApi::linkProgram(uintptr_t program) | ||
| 199 | { | ||
| 200 | gate_gl2_api_link_program(program); | ||
| 201 | } | ||
| 202 | void GlApi::getProgramIv(uintptr_t program, gate_gl2_api_program_param_t param_name, intptr_t* params) | ||
| 203 | { | ||
| 204 | gate_gl2_api_get_program_iv(program, param_name, params); | ||
| 205 | } | ||
| 206 | void GlApi::getProgramInfoLog(uintptr_t program, size_t bufSize, size_t* length, char* infoLog) | ||
| 207 | { | ||
| 208 | gate_gl2_api_get_program_info_log(program, bufSize, length, infoLog); | ||
| 209 | } | ||
| 210 | void GlApi::useProgram(uintptr_t program) | ||
| 211 | { | ||
| 212 | gate_gl2_api_use_program(program); | ||
| 213 | } | ||
| 214 | void GlApi::attachShader(uintptr_t program, uintptr_t shader) | ||
| 215 | { | ||
| 216 | gate_gl2_api_attach_shader(program, shader); | ||
| 217 | } | ||
| 218 | void GlApi::deleteProgram(uintptr_t program) | ||
| 219 | { | ||
| 220 | gate_gl2_api_delete_program(program); | ||
| 221 | } | ||
| 222 | void GlApi::bindAttribLocation(uintptr_t program, size_t index, char const* name) | ||
| 223 | { | ||
| 224 | gate_gl2_api_bind_attrib_location(program, index, name); | ||
| 225 | } | ||
| 226 | intptr_t GlApi::getAttribLocation(uintptr_t program, char const* name) | ||
| 227 | { | ||
| 228 | return gate_gl2_api_get_attrib_location(program, name); | ||
| 229 | } | ||
| 230 | intptr_t GlApi::getUniformLocation(uintptr_t program, char const* name) | ||
| 231 | { | ||
| 232 | return gate_gl2_api_get_uniform_location(program, name); | ||
| 233 | } | ||
| 234 | |||
| 235 | |||
| 236 | void GlApi::genBuffers(size_t n, unsigned int* buffers) | ||
| 237 | { | ||
| 238 | gate_gl2_api_gen_buffers(n, buffers); | ||
| 239 | } | ||
| 240 | void GlApi::deleteBuffers(size_t n, unsigned int* buffers) | ||
| 241 | { | ||
| 242 | gate_gl2_api_delete_buffers(n, buffers); | ||
| 243 | } | ||
| 244 | void GlApi::bindBuffer(gate_gl2_api_buffer_type_t target_type, unsigned int buffer) | ||
| 245 | { | ||
| 246 | gate_gl2_api_bind_buffer(target_type, buffer); | ||
| 247 | } | ||
| 248 | void GlApi::bufferData(gate_gl2_api_buffer_type_t target_type, size_t size, void const* data, gate_gl2_api_usage_type_t usage) | ||
| 249 | { | ||
| 250 | gate_gl2_api_buffer_data(target_type, size, data, usage); | ||
| 251 | } | ||
| 252 | /* | ||
| 253 | void GlApi::namedBufferData(unsigned int buffer, size_t size, void const* data, gate_gl2_api_usage_type_t usage) | ||
| 254 | { | ||
| 255 | gate_gl2_api_named_buffer_data(buffer, size, data, usage); | ||
| 256 | } | ||
| 257 | */ | ||
| 258 | void GlApi::vertexAttribPointer(uintptr_t index, size_t size, gate_gl2_api_vertex_attrib_type_t type, bool_t normalized, size_t stride, void const* pointer) | ||
| 259 | { | ||
| 260 | gate_gl2_api_vertex_attrib_pointer(index, size, type, normalized, stride, pointer); | ||
| 261 | } | ||
| 262 | void GlApi::enableVertexAttribArray(uintptr_t index) | ||
| 263 | { | ||
| 264 | gate_gl2_api_enable_vertex_attrib_array(index); | ||
| 265 | } | ||
| 266 | void GlApi::disableVertexAttribArray(uintptr_t index) | ||
| 267 | { | ||
| 268 | gate_gl2_api_disable_vertex_attrib_array(index); | ||
| 269 | } | ||
| 270 | void GlApi::activeTexture(uintptr_t texture_index) | ||
| 271 | { | ||
| 272 | gate_gl2_api_active_texture(texture_index); | ||
| 273 | } | ||
| 274 | |||
| 275 | |||
| 276 | void GlApi::uniform1f(intptr_t location, real32_t v0) | ||
| 277 | { | ||
| 278 | gate_gl2_api_uniform1f(location, v0); | ||
| 279 | } | ||
| 280 | void GlApi::uniform2f(intptr_t location, real32_t v0, real32_t v1) | ||
| 281 | { | ||
| 282 | gate_gl2_api_uniform2f(location, v0, v1); | ||
| 283 | } | ||
| 284 | void GlApi::uniform3f(intptr_t location, real32_t v0, real32_t v1, real32_t v2) | ||
| 285 | { | ||
| 286 | gate_gl2_api_uniform3f(location, v0, v1, v2); | ||
| 287 | } | ||
| 288 | void GlApi::uniform4f(intptr_t location, real32_t v0, real32_t v1, real32_t v2, real32_t v3) | ||
| 289 | { | ||
| 290 | gate_gl2_api_uniform4f(location, v0, v1, v2, v3); | ||
| 291 | } | ||
| 292 | void GlApi::uniform1fv(intptr_t location, size_t count, const real32_t *value) | ||
| 293 | { | ||
| 294 | gate_gl2_api_uniform1fv(location, count, value); | ||
| 295 | } | ||
| 296 | void GlApi::uniform2fv(intptr_t location, size_t count, const real32_t *value) | ||
| 297 | { | ||
| 298 | gate_gl2_api_uniform2fv(location, count, value); | ||
| 299 | } | ||
| 300 | void GlApi::uniform3fv(intptr_t location, size_t count, const real32_t *value) | ||
| 301 | { | ||
| 302 | gate_gl2_api_uniform3fv(location, count, value); | ||
| 303 | } | ||
| 304 | void GlApi::uniform4fv(intptr_t location, size_t count, const real32_t *value) | ||
| 305 | { | ||
| 306 | gate_gl2_api_uniform4fv(location, count, value); | ||
| 307 | } | ||
| 308 | void GlApi::uniform1i(intptr_t location, int v0) | ||
| 309 | { | ||
| 310 | gate_gl2_api_uniform1i(location, v0); | ||
| 311 | } | ||
| 312 | void GlApi::uniform2i(intptr_t location, int v0, int v1) | ||
| 313 | { | ||
| 314 | gate_gl2_api_uniform2i(location, v0, v1); | ||
| 315 | } | ||
| 316 | void GlApi::uniform3i(intptr_t location, int v0, int v1, int v2) | ||
| 317 | { | ||
| 318 | gate_gl2_api_uniform3i(location, v0, v1, v2); | ||
| 319 | } | ||
| 320 | void GlApi::uniform4i(intptr_t location, int v0, int v1, int v2, int v3) | ||
| 321 | { | ||
| 322 | gate_gl2_api_uniform4i(location, v0, v1, v2, v3); | ||
| 323 | } | ||
| 324 | void GlApi::uniform1iv(intptr_t location, size_t count, const int *value) | ||
| 325 | { | ||
| 326 | gate_gl2_api_uniform1iv(location, count, value); | ||
| 327 | } | ||
| 328 | void GlApi::uniform2iv(intptr_t location, size_t count, const int *value) | ||
| 329 | { | ||
| 330 | gate_gl2_api_uniform2iv(location, count, value); | ||
| 331 | } | ||
| 332 | void GlApi::uniform3iv(intptr_t location, size_t count, const int *value) | ||
| 333 | { | ||
| 334 | gate_gl2_api_uniform3iv(location, count, value); | ||
| 335 | } | ||
| 336 | void GlApi::uniform4iv(intptr_t location, size_t count, const int *value) | ||
| 337 | { | ||
| 338 | gate_gl2_api_uniform4iv(location, count, value); | ||
| 339 | } | ||
| 340 | |||
| 341 | void GlApi::uniform_matrix2fv(intptr_t location, size_t count, bool_t transpose, const real32_t *value) | ||
| 342 | { | ||
| 343 | gate_gl2_api_uniform_matrix2fv(location, count, transpose, value); | ||
| 344 | } | ||
| 345 | void GlApi::uniform_matrix3fv(intptr_t location, size_t count, bool_t transpose, const real32_t *value) | ||
| 346 | { | ||
| 347 | gate_gl2_api_uniform_matrix3fv(location, count, transpose, value); | ||
| 348 | } | ||
| 349 | void GlApi::uniform_matrix4fv(intptr_t location, size_t count, bool_t transpose, const real32_t *value) | ||
| 350 | { | ||
| 351 | gate_gl2_api_uniform_matrix4fv(location, count, transpose, value); | ||
| 352 | } | ||
| 353 | |||
| 354 | #endif | ||
| 355 | |||
| 356 | |||
| 357 | |||
| 358 | 1 | GlSurfaceEventSink::GlSurfaceEventSink() | |
| 359 | 1 | : surface_ptr(NULL) | |
| 360 | { | ||
| 361 | 1 | } | |
| 362 | |||
| 363 | 2 | GlSurfaceEventSink::~GlSurfaceEventSink() noexcept | |
| 364 | { | ||
| 365 | 2 | } | |
| 366 | |||
| 367 | 22 | GlSurface& GlSurfaceEventSink::getSurface() | |
| 368 | { | ||
| 369 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 22 times.
|
22 | if (!this->surface_ptr) |
| 370 | { | ||
| 371 | ✗ | GATEXX_RAISE_ERROR(results::NullPointer); | |
| 372 | } | ||
| 373 | 22 | return *this->surface_ptr; | |
| 374 | } | ||
| 375 | 1 | void GlSurfaceEventSink::connectSurface(GlSurface& surface) | |
| 376 | { | ||
| 377 | 1 | this->surface_ptr = &surface; | |
| 378 | 1 | } | |
| 379 | |||
| 380 | |||
| 381 | |||
| 382 | enumint_t const GlSurface::Flag_SoftwareRendering = GATE_GL_SURFACE_FLAG_SOFTWARE_RENDERING; | ||
| 383 | |||
| 384 | |||
| 385 | 1 | GlSurface::GlSurface() | |
| 386 | { | ||
| 387 |
1/2✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
|
1 | result_t result = gate_gl_surface_init(&this->impl); |
| 388 |
1/4✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
|
1 | GATEXX_CHECK_ERROR(result); |
| 389 | 1 | } | |
| 390 | 1 | GlSurface::~GlSurface() noexcept | |
| 391 | { | ||
| 392 | 1 | gate_gl_surface_uninit(&this->impl); | |
| 393 | 1 | } | |
| 394 | |||
| 395 | 1 | void GlSurface::openScreen(uint32_t width, uint32_t height, enumint_t flags) | |
| 396 | { | ||
| 397 | 1 | result_t result = gate_gl_surface_open(&this->impl, gate_gl_surface_type_screen, width, height, flags); | |
| 398 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 399 | 1 | } | |
| 400 | ✗ | void GlSurface::openImage(uint32_t width, uint32_t height, enumint_t flags) | |
| 401 | { | ||
| 402 | ✗ | result_t result = gate_gl_surface_open(&this->impl, gate_gl_surface_type_image, width, height, flags); | |
| 403 | ✗ | GATEXX_CHECK_ERROR(result); | |
| 404 | ✗ | } | |
| 405 | |||
| 406 | 1 | void GlSurface::close() | |
| 407 | { | ||
| 408 | 1 | result_t result = gate_gl_surface_close(&this->impl); | |
| 409 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 410 | 1 | } | |
| 411 | |||
| 412 | 1 | void GlSurface::getSize(uint32_t& width, uint32_t& height) | |
| 413 | { | ||
| 414 | 1 | result_t result = gate_gl_surface_get_size(&this->impl, &width, &height); | |
| 415 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 416 | 1 | } | |
| 417 | 1 | void GlSurface::resize(uint32_t width, uint32_t height) | |
| 418 | { | ||
| 419 | 1 | result_t result = gate_gl_surface_resize(&this->impl, width, height); | |
| 420 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_EXCEPTION(result); |
| 421 | 1 | } | |
| 422 | |||
| 423 | ✗ | RasterImage GlSurface::printImage() | |
| 424 | { | ||
| 425 | ✗ | gate_rasterimage_t rasterimage = GATE_INIT_EMPTY; | |
| 426 | ✗ | result_t result = gate_gl_surface_print_image(&this->impl, &rasterimage); | |
| 427 | ✗ | GATEXX_CHECK_ERROR(result); | |
| 428 | ✗ | RasterImage image(&rasterimage); | |
| 429 | ✗ | gate_rasterimage_release(&rasterimage); | |
| 430 | ✗ | return image; | |
| 431 | } | ||
| 432 | |||
| 433 | |||
| 434 | 21 | static void GATE_CALL surface_events_on_render(gate_gl_surface_t* surface, void* user_param) | |
| 435 | { | ||
| 436 | 21 | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 437 |
2/4✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21 times.
✗ Branch 5 not taken.
|
21 | GATEXX_TRY_IGNORE({ |
| 438 | sink->onRender(sink->getSurface()); | ||
| 439 | }) | ||
| 440 | 21 | } | |
| 441 | ✗ | static void GATE_CALL surface_events_on_exit(gate_gl_surface_t* surface, void* user_param) | |
| 442 | { | ||
| 443 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 444 | ✗ | GATEXX_TRY_IGNORE({ | |
| 445 | sink->onExit(sink->getSurface()); | ||
| 446 | }); | ||
| 447 | ✗ | } | |
| 448 | 1 | static void GATE_CALL surface_events_on_resize(gate_gl_surface_t* surface, gate_uint32_t width, gate_uint32_t height, void* user_param) | |
| 449 | { | ||
| 450 | 1 | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 451 |
2/4✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1 times.
✗ Branch 5 not taken.
|
1 | GATEXX_TRY_IGNORE({ |
| 452 | sink->onResize(sink->getSurface(), width, height); | ||
| 453 | }); | ||
| 454 | 1 | } | |
| 455 | ✗ | static void GATE_CALL surface_events_on_key_down(gate_gl_surface_t* surface, gate_input_keycode_t keyboard_key, | |
| 456 | gate_input_keystates_t keyboard_states, void* user_param) | ||
| 457 | { | ||
| 458 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 459 | ✗ | GATEXX_TRY_IGNORE({ | |
| 460 | sink->onKeyDown(sink->getSurface(), Keyboard::KeyEnum(keyboard_key), keyboard_states); | ||
| 461 | }); | ||
| 462 | ✗ | } | |
| 463 | ✗ | static void GATE_CALL surface_events_on_key_up(gate_gl_surface_t* surface, gate_input_keycode_t keyboard_key, | |
| 464 | gate_input_keystates_t keyboard_states, void* user_param) | ||
| 465 | { | ||
| 466 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 467 | ✗ | GATEXX_TRY_IGNORE({ | |
| 468 | sink->onKeyUp(sink->getSurface(), Keyboard::KeyEnum(keyboard_key), keyboard_states); | ||
| 469 | }); | ||
| 470 | ✗ | } | |
| 471 | ✗ | static void GATE_CALL surface_events_on_pointer_down(gate_gl_surface_t* surface, gate_uint32_t pointer_type, gate_real32_t x, gate_real32_t y, void* user_param) | |
| 472 | { | ||
| 473 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 474 | ✗ | GATEXX_TRY_IGNORE({ | |
| 475 | sink->onPointerDown(sink->getSurface(), pointer_type, x, y); | ||
| 476 | }); | ||
| 477 | ✗ | } | |
| 478 | ✗ | static void GATE_CALL surface_events_on_pointer_move(gate_gl_surface_t* surface, gate_uint32_t pointer_type, gate_real32_t x, gate_real32_t y, void* user_param) | |
| 479 | { | ||
| 480 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 481 | ✗ | GATEXX_TRY_IGNORE({ | |
| 482 | sink->onPointerMove(sink->getSurface(), pointer_type, x, y); | ||
| 483 | }); | ||
| 484 | ✗ | } | |
| 485 | ✗ | static void GATE_CALL surface_events_on_pointer_up(gate_gl_surface_t* surface, gate_uint32_t pointer_type, gate_real32_t x, gate_real32_t y, void* user_param) | |
| 486 | { | ||
| 487 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 488 | ✗ | GATEXX_TRY_IGNORE({ | |
| 489 | sink->onPointerUp(sink->getSurface(), pointer_type, x, y); | ||
| 490 | }); | ||
| 491 | ✗ | } | |
| 492 | ✗ | static void GATE_CALL surface_events_on_scroll(gate_gl_surface_t* surface, gate_int32_t x_direction, gate_int32_t y_direction, void* user_param) | |
| 493 | { | ||
| 494 | ✗ | GlSurfaceEventSink* sink = static_cast<GlSurfaceEventSink*>(user_param); | |
| 495 | ✗ | GATEXX_TRY_IGNORE({ | |
| 496 | sink->onScroll(sink->getSurface(), x_direction, y_direction); | ||
| 497 | }); | ||
| 498 | ✗ | } | |
| 499 | |||
| 500 | static gate_gl_surface_events_t cpp_dispatcher = | ||
| 501 | { | ||
| 502 | &surface_events_on_resize, | ||
| 503 | &surface_events_on_render, | ||
| 504 | &surface_events_on_exit, | ||
| 505 | |||
| 506 | &surface_events_on_key_down, | ||
| 507 | &surface_events_on_key_up, | ||
| 508 | &surface_events_on_pointer_down, | ||
| 509 | &surface_events_on_pointer_move, | ||
| 510 | &surface_events_on_pointer_up, | ||
| 511 | &surface_events_on_scroll | ||
| 512 | }; | ||
| 513 | |||
| 514 | 1 | void GlSurface::runEventLoop(GlSurfaceEventSink& eventHandler) | |
| 515 | { | ||
| 516 | 1 | eventHandler.connectSurface(*this); | |
| 517 | 1 | result_t result = gate_gl_surface_run_event_loop(&this->impl, &cpp_dispatcher, static_cast<void*>(&eventHandler)); | |
| 518 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 519 | 1 | } | |
| 520 | 1 | void GlSurface::exitEventLoop() | |
| 521 | { | ||
| 522 | 1 | result_t result = gate_gl_surface_exit_event_loop(&this->impl); | |
| 523 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
|
1 | GATEXX_CHECK_ERROR(result); |
| 524 | 1 | } | |
| 525 | 20 | void GlSurface::swapBuffers() | |
| 526 | { | ||
| 527 | 20 | result_t result = gate_gl_surface_swap_buffers(&this->impl); | |
| 528 |
1/2✗ Branch 0 not taken.
✓ Branch 1 taken 20 times.
|
20 | GATEXX_CHECK_ERROR(result); |
| 529 | 20 | } | |
| 530 | |||
| 531 | 21 | GlApi& GlSurface::getGlApi() | |
| 532 | { | ||
| 533 | 21 | return this->api; | |
| 534 | } | ||
| 535 | |||
| 536 | } // end of namespace graph | ||
| 537 | } // end of namespace gate | ||
| 538 |