Kore
Loading...
Searching...
No Matches
graphics.h
Go to the documentation of this file.
1#pragma once
2
3#include <kinc/global.h>
4
5#include <kinc/math/matrix.h>
6
7#include "constantlocation.h"
8#include "pipeline.h"
9#include "textureunit.h"
10
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
20struct kinc_g4_pipeline;
22struct kinc_g4_texture;
24#ifdef KINC_OPENGL
25struct kinc_shader_storage_buffer;
26#endif
27
28typedef enum {
29 KINC_G4_TEXTURE_ADDRESSING_REPEAT,
30 KINC_G4_TEXTURE_ADDRESSING_MIRROR,
31 KINC_G4_TEXTURE_ADDRESSING_CLAMP,
32 KINC_G4_TEXTURE_ADDRESSING_BORDER
33} kinc_g4_texture_addressing_t;
34
35typedef enum { KINC_G4_TEXTURE_DIRECTION_U, KINC_G4_TEXTURE_DIRECTION_V, KINC_G4_TEXTURE_DIRECTION_W } kinc_g4_texture_direction_t;
36
37typedef enum { KINC_G4_TEXTURE_FILTER_POINT, KINC_G4_TEXTURE_FILTER_LINEAR, KINC_G4_TEXTURE_FILTER_ANISOTROPIC } kinc_g4_texture_filter_t;
38
39typedef enum {
40 KINC_G4_MIPMAP_FILTER_NONE,
41 KINC_G4_MIPMAP_FILTER_POINT,
42 KINC_G4_MIPMAP_FILTER_LINEAR // linear texture filter + linear mip filter -> trilinear filter
43} kinc_g4_mipmap_filter_t;
44
50
56
62
68
74
79KINC_FUNC int kinc_g4_max_bound_textures(void);
80
84KINC_FUNC void kinc_g4_flush(void);
85
90KINC_FUNC void kinc_g4_begin(int window);
91
97KINC_FUNC void kinc_g4_end(int window);
98
102KINC_FUNC bool kinc_g4_swap_buffers(void);
103
104#define KINC_G4_CLEAR_COLOR 1
105#define KINC_G4_CLEAR_DEPTH 2
106#define KINC_G4_CLEAR_STENCIL 4
107
115KINC_FUNC void kinc_g4_clear(unsigned flags, unsigned color, float depth, int stencil);
116
125KINC_FUNC void kinc_g4_viewport(int x, int y, int width, int height);
126
134KINC_FUNC void kinc_g4_scissor(int x, int y, int width, int height);
135
139KINC_FUNC void kinc_g4_disable_scissor(void);
140
145KINC_FUNC void kinc_g4_draw_indexed_vertices(void);
146
153KINC_FUNC void kinc_g4_draw_indexed_vertices_from_to(int start, int count);
154
162KINC_FUNC void kinc_g4_draw_indexed_vertices_from_to_from(int start, int count, int vertex_offset);
163
164KINC_FUNC void kinc_g4_draw_indexed_vertices_instanced(int instanceCount);
165
166KINC_FUNC void kinc_g4_draw_indexed_vertices_instanced_from_to(int instanceCount, int start, int count);
167
168KINC_FUNC void kinc_g4_set_texture_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing);
169
170KINC_FUNC void kinc_g4_set_texture3d_addressing(kinc_g4_texture_unit_t unit, kinc_g4_texture_direction_t dir, kinc_g4_texture_addressing_t addressing);
171
176KINC_FUNC void kinc_g4_set_pipeline(struct kinc_g4_pipeline *pipeline);
177
178KINC_FUNC void kinc_g4_set_stencil_reference_value(int value);
179
183KINC_FUNC void kinc_g4_set_blend_constant(float r, float g, float b, float a);
184
190KINC_FUNC void kinc_g4_set_int(kinc_g4_constant_location_t location, int value);
191
198KINC_FUNC void kinc_g4_set_int2(kinc_g4_constant_location_t location, int value1, int value2);
199
207KINC_FUNC void kinc_g4_set_int3(kinc_g4_constant_location_t location, int value1, int value2, int value3);
208
217KINC_FUNC void kinc_g4_set_int4(kinc_g4_constant_location_t location, int value1, int value2, int value3, int value4);
218
225KINC_FUNC void kinc_g4_set_ints(kinc_g4_constant_location_t location, int *values, int count);
226
232KINC_FUNC void kinc_g4_set_float(kinc_g4_constant_location_t location, float value);
233
240KINC_FUNC void kinc_g4_set_float2(kinc_g4_constant_location_t location, float value1, float value2);
241
249KINC_FUNC void kinc_g4_set_float3(kinc_g4_constant_location_t location, float value1, float value2, float value3);
250
259KINC_FUNC void kinc_g4_set_float4(kinc_g4_constant_location_t location, float value1, float value2, float value3, float value4);
260
267KINC_FUNC void kinc_g4_set_floats(kinc_g4_constant_location_t location, float *values, int count);
268
274KINC_FUNC void kinc_g4_set_bool(kinc_g4_constant_location_t location, bool value);
275
281KINC_FUNC void kinc_g4_set_matrix3(kinc_g4_constant_location_t location, kinc_matrix3x3_t *value);
282
288KINC_FUNC void kinc_g4_set_matrix4(kinc_g4_constant_location_t location, kinc_matrix4x4_t *value);
289
295KINC_FUNC void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t unit, kinc_g4_texture_filter_t filter);
296
302KINC_FUNC void kinc_g4_set_texture3d_magnification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter);
303
309KINC_FUNC void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t unit, kinc_g4_texture_filter_t filter);
310
316KINC_FUNC void kinc_g4_set_texture3d_minification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter);
317
323KINC_FUNC void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t unit, kinc_g4_mipmap_filter_t filter);
324
331KINC_FUNC void kinc_g4_set_texture3d_mipmap_filter(kinc_g4_texture_unit_t texunit, kinc_g4_mipmap_filter_t filter);
332
333KINC_FUNC void kinc_g4_set_texture_compare_mode(kinc_g4_texture_unit_t unit, bool enabled);
334
335KINC_FUNC void kinc_g4_set_texture_compare_func(kinc_g4_texture_unit_t unit, kinc_g4_compare_mode_t mode);
336
337KINC_FUNC void kinc_g4_set_cubemap_compare_mode(kinc_g4_texture_unit_t unit, bool enabled);
338
339KINC_FUNC void kinc_g4_set_cubemap_compare_func(kinc_g4_texture_unit_t unit, kinc_g4_compare_mode_t mode);
340
341KINC_FUNC void kinc_g4_set_texture_max_anisotropy(kinc_g4_texture_unit_t unit, uint16_t max_anisotropy);
342
343KINC_FUNC void kinc_g4_set_cubemap_max_anisotropy(kinc_g4_texture_unit_t unit, uint16_t max_anisotropy);
344
345KINC_FUNC void kinc_g4_set_texture_lod(kinc_g4_texture_unit_t unit, float lod_min_clamp, float lod_max_clamp);
346
347KINC_FUNC void kinc_g4_set_cubemap_lod(kinc_g4_texture_unit_t unit, float lod_min_clamp, float lod_max_clamp);
348
352KINC_FUNC void kinc_g4_restore_render_target(void);
353
359KINC_FUNC void kinc_g4_set_render_targets(struct kinc_g4_render_target **targets, int count);
360
361KINC_FUNC void kinc_g4_set_render_target_face(struct kinc_g4_render_target *texture, int face);
362
368KINC_FUNC void kinc_g4_set_texture(kinc_g4_texture_unit_t unit, struct kinc_g4_texture *texture);
369
377KINC_FUNC void kinc_g4_set_image_texture(kinc_g4_texture_unit_t unit, struct kinc_g4_texture *texture);
378
379KINC_FUNC bool kinc_g4_init_occlusion_query(unsigned *occlusionQuery);
380
381KINC_FUNC void kinc_g4_delete_occlusion_query(unsigned occlusionQuery);
382
383KINC_FUNC void kinc_g4_start_occlusion_query(unsigned occlusionQuery);
384
385KINC_FUNC void kinc_g4_end_occlusion_query(unsigned occlusionQuery);
386
387KINC_FUNC bool kinc_g4_are_query_results_available(unsigned occlusionQuery);
388
389KINC_FUNC void kinc_g4_get_query_results(unsigned occlusionQuery, unsigned *pixelCount);
390
396KINC_FUNC void kinc_g4_set_texture_array(kinc_g4_texture_unit_t unit, struct kinc_g4_texture_array *array);
397
402KINC_FUNC int kinc_g4_antialiasing_samples(void);
403
409KINC_FUNC void kinc_g4_set_antialiasing_samples(int samples);
410
411#ifdef KINC_OPENGL
415KINC_FUNC void kinc_g4_set_shader_storage_buffer(struct kinc_shader_storage_buffer *buffer, int index);
416#endif
417
423
430KINC_FUNC void kinc_g4_compute(int x, int y, int z);
431
432#ifndef KINC_DOCS
433void kinc_g4_internal_init(void);
434void kinc_g4_internal_init_window(int window, int depth_buffer_bits, int stencil_buffer_bits, bool vsync);
435void kinc_g4_internal_destroy_window(int window);
436void kinc_g4_internal_destroy(void);
437#endif
438
439#ifdef __cplusplus
440}
441#endif
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
Provides the constant_location-struct which is used for setting constants/uniforms in a shader.
KINC_FUNC void kinc_g4_set_bool(kinc_g4_constant_location_t location, bool value)
Assigns a bool to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_set_antialiasing_samples(int samples)
Sets the number of samples used for hardware-antialiasing. This typically uses multisampling and typi...
Definition graphics.c.h:9
KINC_FUNC bool kinc_g4_swap_buffers(void)
Needs to be called to make the rendered frame visible. Typically called at the very end of each frame...
KINC_FUNC void kinc_g4_set_texture_magnification_filter(kinc_g4_texture_unit_t unit, kinc_g4_texture_filter_t filter)
Set the texture-sampling-mode for upscaled textures.
KINC_FUNC void kinc_g4_set_blend_constant(float r, float g, float b, float a)
Sets the blend constant used for KINC_G4_BLEND_CONSTANT or KINC_G4_INV_BLEND_CONSTANT.
KINC_FUNC void kinc_g4_set_texture3d_mipmap_filter(kinc_g4_texture_unit_t texunit, kinc_g4_mipmap_filter_t filter)
Sets the mipmap-sampling-mode for a 3D-texture which defines whether mipmaps are used at all and if s...
KINC_FUNC void kinc_g4_set_float2(kinc_g4_constant_location_t location, float value1, float value2)
Assigns two floats to a constant/uniform in the currently set pipeline.
KINC_FUNC bool kinc_g4_supports_compute_shaders(void)
Returns whether GPU-compute (the functions in kinc/compute/compute.h) is supported.
KINC_FUNC void kinc_g4_set_float4(kinc_g4_constant_location_t location, float value1, float value2, float value3, float value4)
Assigns four floats to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_disable_scissor(void)
Disables the scissor-rect.
KINC_FUNC void kinc_g4_draw_indexed_vertices(void)
Draws the entire content of the currently set index-buffer and vertex-buffer. G4 can only draw triang...
KINC_FUNC void kinc_g4_set_texture_array(kinc_g4_texture_unit_t unit, struct kinc_g4_texture_array *array)
Assigns a texture-array to a texture-unit.
KINC_FUNC void kinc_g4_set_ints(kinc_g4_constant_location_t location, int *values, int count)
Assigns a bunch of integers to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_set_float(kinc_g4_constant_location_t location, float value)
Assigns a float to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_draw_indexed_vertices_from_to_from(int start, int count, int vertex_offset)
Draws a part of the content of the currently set index-buffer and vertex-buffer and additionally appl...
KINC_FUNC void kinc_g4_compute(int x, int y, int z)
Fire off a compute-run on x * y * z elements.
KINC_FUNC void kinc_g4_set_int4(kinc_g4_constant_location_t location, int value1, int value2, int value3, int value4)
Assigns four integers to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_set_matrix4(kinc_g4_constant_location_t location, kinc_matrix4x4_t *value)
Assigns a 4x4-matrix to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_begin(int window)
Needs to be called before rendering to a window. Typically called at the start of each frame.
KINC_FUNC void kinc_g4_set_texture_minification_filter(kinc_g4_texture_unit_t unit, kinc_g4_texture_filter_t filter)
Set the texture-sampling-mode for downscaled textures.
KINC_FUNC void kinc_g4_set_float3(kinc_g4_constant_location_t location, float value1, float value2, float value3)
Assigns three floats to a constant/uniform in the currently set pipeline.
KINC_FUNC bool kinc_g4_render_targets_inverted_y(void)
Returns whether render-targets are upside down. This happens in OpenGL and there is currently no auto...
KINC_FUNC void kinc_g4_clear(unsigned flags, unsigned color, float depth, int stencil)
Clears the color, depth and/or stencil-components of the current framebuffer or render-target.
KINC_FUNC void kinc_g4_restore_render_target(void)
Sets the framebuffer (aka the actual contents of the current window) to be the target of any future d...
KINC_FUNC void kinc_g4_set_floats(kinc_g4_constant_location_t location, float *values, int count)
Assigns a bunch of floats to a constant/uniform in the currently set pipeline.
KINC_FUNC int kinc_g4_antialiasing_samples(void)
Returns the currently used number of samples for hardware-antialiasing.
Definition graphics.c.h:5
KINC_FUNC void kinc_g4_scissor(int x, int y, int width, int height)
Enables and defines the scissor-rect. When the scissor-rect is enabled, anything that's rendered outs...
KINC_FUNC void kinc_g4_set_matrix3(kinc_g4_constant_location_t location, kinc_matrix3x3_t *value)
Assigns a 3x3-matrix to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_set_texture3d_minification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter)
Set the texture-sampling-mode for downscaled 3D-textures.
KINC_FUNC void kinc_g4_set_render_targets(struct kinc_g4_render_target **targets, int count)
Sets the passed render-targets to be the target of any future draw-calls.
KINC_FUNC bool kinc_g4_supports_instanced_rendering(void)
Returns whether instanced rendering (kinc_g4_draw_indexed_vertices_instanced and pals) is supported.
KINC_FUNC int kinc_g4_max_bound_textures(void)
Returns how many textures can be used at the same time in a fragment-shader.
KINC_FUNC bool kinc_g4_supports_blend_constants(void)
Returns whether blend-constants (see kinc_g4_set_blend_constant and the blending-properties for pipel...
KINC_FUNC bool kinc_g4_supports_non_pow2_textures(void)
Returns whether textures are supported which have widths/heights which are not powers of two.
KINC_FUNC void kinc_g4_set_image_texture(kinc_g4_texture_unit_t unit, struct kinc_g4_texture *texture)
Assigns a texture to a texture-unit for direct access via GLSL's texelFetch (as opposed to GLSL's tex...
KINC_FUNC void kinc_g4_set_int(kinc_g4_constant_location_t location, int value)
Assigns an integer to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_set_int2(kinc_g4_constant_location_t location, int value1, int value2)
Assigns two integers to a constant/uniform in the currently set pipeline.
KINC_FUNC void kinc_g4_set_texture_mipmap_filter(kinc_g4_texture_unit_t unit, kinc_g4_mipmap_filter_t filter)
Sets the mipmap-sampling-mode which defines whether mipmaps are used at all and if so whether the two...
KINC_FUNC void kinc_g4_set_compute_shader(struct kinc_g4_compute_shader *shader)
Sets a shader for the next compute-run.
KINC_FUNC void kinc_g4_draw_indexed_vertices_from_to(int start, int count)
Draws a part of the content of the currently set index-buffer and vertex-buffer. G4 can only draw tri...
KINC_FUNC void kinc_g4_end(int window)
Needs to be called after rendering to a window. Typically called at the end of each frame.
KINC_FUNC void kinc_g4_viewport(int x, int y, int width, int height)
Sets the viewport which defines the portion of the framebuffer or render-target things are rendered i...
KINC_FUNC void kinc_g4_set_pipeline(struct kinc_g4_pipeline *pipeline)
Sets the pipeline for the next draw-call. The pipeline defines most rendering-state including the sha...
KINC_FUNC void kinc_g4_set_texture(kinc_g4_texture_unit_t unit, struct kinc_g4_texture *texture)
Assigns a texture to a texture-unit for sampled access via GLSL's texture.
KINC_FUNC void kinc_g4_flush(void)
Kicks off lingering work - may or may not actually do anything depending on the underlying graphics-A...
KINC_FUNC void kinc_g4_set_texture3d_magnification_filter(kinc_g4_texture_unit_t texunit, kinc_g4_texture_filter_t filter)
Set the texture-sampling-mode for upscaled 3D-textures.
KINC_FUNC void kinc_g4_set_int3(kinc_g4_constant_location_t location, int value1, int value2, int value3)
Assigns three integers to a constant/uniform in the currently set pipeline.
Provides functions for creating and using pipelines which configure the GPU for rendering.
Provides a texture-unit-struct which is used for setting textures in a shader.
Provides basic matrix types and a few functions which create transformation-matrices....
Definition compute.h:23
Definition pipeline.h:69
Definition rendertarget.h:30
Definition texturearray.h:17
Definition texture.h:18