aboutsummaryrefslogtreecommitdiff
path: root/headers/TZR_render.h
blob: 1fb3e956ec50d7e1109e0dfe792e52690e8de6fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#pragma once
#include "TZR_types.h"
#include <SDL2/SDL_render.h>
#include <limits.h>

/* All draw calls should happen between TZR_DrawBegin and TZR_DrawEnd.
 * Return -1 on error. */
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
int TZR_DrawBegin(void);

/* Return -1 on error. */
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
int TZR_DrawEnd(void);

/* Return -1 on error. */
#define TZR_DrawSetColor(...) ({ const TZR_Color ____arg = { \
	.r=-1.0f, .g=-1.0f, .b=-1.0f, .a=-1.0f, ._=0, __VA_ARGS__ }; \
	_TZR_DrawSetColor(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int _TZR_DrawSetColor(const TZR_Color *color);

/* Return -1 on error. */
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int TZR_DrawSetColor8(uint8_t r, uint8_t g, uint8_t b, uint8_t a);

/* Return -1 on error. */
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int TZR_DrawClear(void);

/* Return -1 on error. Draw point on `x`;`y` in the framebuffer. */
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int TZR_DrawPoint(int x, int y);

/* Return -1 on error. Draw line between `x0`;`y0` and `x1`;`y1` in the
 * framebuffer. */
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int TZR_DrawLine(int x0, int y0, int x1, int y1);

/* Return -1 on error. Draw rectangle at `x`;`y` position of size `w`x`h` in the
 * framebuffer. */
#define TZR_DrawRectangle(...) ({ const TZR_DrawRectangleArgs ____arg = { \
	.x=0, .y=0, .w=0, .h=0, .fill=false, .center=false, ._=0, __VA_ARGS__ }; \
	_TZR_DrawRectangle(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int _TZR_DrawRectangle(const TZR_DrawRectangleArgs *args);

/* Return -1 on error. Draw texture ressource `id` at `x`;`y` position of
 * the framebuffer. */
#define TZR_DrawImage(...) ({ const TZR_DrawImageArgs ____arg = { \
	.x=0, .y=0, .ix=0, .iy=0, .w=INT_MIN, .h=INT_MIN, .r=0.0f, .sx=1.0f, \
	.sy=1.0f, .center=false, .flip_x=false, .flip_y=false, ._=0, \
	__VA_ARGS__ }; \
	_TZR_DrawImage(&____arg); })
#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int _TZR_DrawImage(const TZR_DrawImageArgs *args);

void TZR_ScreenTransform(int *x, int *y);

#ifdef TZR_PARANOID
#if __STDC_VERSION__ > 201710L
[[nodiscard]]
#endif
#endif
int TZR_BlendMode(SDL_BlendMode mode);