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/color.h>
6
7#include <assert.h>
8
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17typedef enum {
18 KINC_G1_TEXTURE_FILTER_POINT,
19 KINC_G1_TEXTURE_FILTER_LINEAR,
20 KINC_G1_TEXTURE_FILTER_ANISOTROPIC,
21} kinc_g1_texture_filter_t;
22
23typedef enum {
24 KINC_G1_MIPMAP_FILTER_NONE,
25 KINC_G1_MIPMAP_FILTER_POINT,
26 KINC_G1_MIPMAP_FILTER_LINEAR,
27} kinc_g1_mipmap_filter_t;
28
34KINC_FUNC void kinc_g1_init(int width, int height);
35
39KINC_FUNC void kinc_g1_begin(void);
40
45KINC_FUNC void kinc_g1_end(void);
46
47extern uint32_t *kinc_internal_g1_image;
48extern int kinc_internal_g1_w, kinc_internal_g1_h, kinc_internal_g1_tex_width;
49extern kinc_g1_texture_filter_t kinc_internal_g1_texture_filter_min;
50extern kinc_g1_texture_filter_t kinc_internal_g1_texture_filter_mag;
51extern kinc_g1_mipmap_filter_t kinc_internal_g1_mipmap_filter;
52
53#if defined(KINC_DYNAMIC_COMPILE) || defined(KINC_DYNAMIC) || defined(KINC_DOCS)
54
63KINC_FUNC void kinc_g1_set_pixel(int x, int y, float red, float green, float blue);
64
69KINC_FUNC int kinc_g1_width(void);
70
75KINC_FUNC int kinc_g1_height(void);
76
82KINC_FUNC void kinc_g1_set_texture_magnification_filter(kinc_g1_texture_filter_t filter);
83
89KINC_FUNC void kinc_g1_set_texture_minification_filter(kinc_g1_texture_filter_t filter);
90
96KINC_FUNC void kinc_g1_set_texture_mipmap_filter(kinc_g1_mipmap_filter_t filter);
97
98#else
99
100// implementation moved to the header to allow easy inlining
101
102static inline void kinc_g1_set_pixel(int x, int y, float red, float green, float blue) {
103 assert(x >= 0 && x < kinc_internal_g1_w && y >= 0 && y < kinc_internal_g1_h);
104 int r = (int)(red * 255);
105 int g = (int)(green * 255);
106 int b = (int)(blue * 255);
107 kinc_internal_g1_image[y * kinc_internal_g1_tex_width + x] = 0xff << 24 | b << 16 | g << 8 | r;
108}
109
110static inline int kinc_g1_width(void) {
111 return kinc_internal_g1_w;
112}
113
114static inline int kinc_g1_height(void) {
115 return kinc_internal_g1_h;
116}
117
118static inline void kinc_g1_set_texture_magnification_filter(kinc_g1_texture_filter_t filter) {
119 kinc_internal_g1_texture_filter_mag = filter;
120}
121
122static inline void kinc_g1_set_texture_minification_filter(kinc_g1_texture_filter_t filter) {
123 kinc_internal_g1_texture_filter_min = filter;
124}
125
126static inline void kinc_g1_set_texture_mipmap_filter(kinc_g1_mipmap_filter_t filter) {
127 kinc_internal_g1_mipmap_filter = filter;
128}
129
130#endif
131
132#ifdef __cplusplus
133}
134#endif
Provides some utility functionality for handling 32 bit ARGB color values.
Provides basic functionality that's used all over the place. There's usually no need to manually incl...
KINC_FUNC void kinc_g1_set_texture_minification_filter(kinc_g1_texture_filter_t filter)
Set the texture-sampling-mode for downscaled textures.
KINC_FUNC void kinc_g1_set_texture_magnification_filter(kinc_g1_texture_filter_t filter)
Set the texture-sampling-mode for upscaled textures.
KINC_FUNC void kinc_g1_end(void)
Typically called once per frame after all G1-drawing is finished. This also swaps the framebuffers so...
KINC_FUNC void kinc_g1_begin(void)
Typically called once per frame before other G1-functions are called.
KINC_FUNC int kinc_g1_height(void)
Returns the height used by G1.
KINC_FUNC void kinc_g1_init(int width, int height)
Initializes the G1-API.
KINC_FUNC int kinc_g1_width(void)
Returns the width used by G1.
KINC_FUNC void kinc_g1_set_pixel(int x, int y, float red, float green, float blue)
Sets a single pixel to a color.
KINC_FUNC void kinc_g1_set_texture_mipmap_filter(kinc_g1_mipmap_filter_t filter)
Sets the mipmap-sampling-mode which defines whether mipmaps are used at all and if so whether the two...