LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2026 ETMSoftware
Loading...
Searching...
No Matches
lg_gr_func.h
1/*
2 * LibGame - Copyright (C) Emmanuel Thomas-Maurin 2011-2026
3 * All rights reserved
4 */
5
6#ifndef LG_GR_FUNC_H
7#define LG_GR_FUNC_H
8
9/*
10 * === A few 2D structs and graphical funcs ===
11 *
12 * Plus colors funcs
13 */
14
15typedef struct {
16 int32_t x;
17 int32_t y;
18} Point2Di;
19
20typedef struct {
21 float x;
22 float y;
23} Point2Df;
24
25typedef struct {
26 int32_t x1;
27 int32_t y1;
28 int32_t x2;
29 int32_t y2;
30} Line2Di;
31
32typedef struct {
33 float x1;
34 float y1;
35 float x2;
36 float y2;
37} Line2Df;
38
39/*
40 * Rec = rectangle (floats) with OpenGL coords sys orientation
41 * ^
42 * |
43 * x,y+h |--------
44 * | |
45 * | |
46 * ------------->
47 * x,y x+w,y
48 */
49typedef struct {
50 int32_t x;
51 int32_t y;
52 int32_t w;
53 int32_t h;
54} Rec2Di;
55
56typedef struct {
57 float x;
58 float y;
59 float w;
60 float h;
61} Rec2Df;
62
63void lg_draw_line(int32_t, int32_t, int32_t, int32_t, LG_Color_u);
64
66
68
70
71zboolean lg_clip_rec(Rec2Di, Rec2Di, Rec2Di *);
72
73zboolean lg_recs_overlap(Rec2Df *, Rec2Df *);
74
76
78
80
81zboolean lg_rec_i_are_equal(Rec2Di *, Rec2Di *);
82
83zboolean lg_rec_f_are_equal(Rec2Df *, Rec2Df *);
84
85Rec2Di lg_rec_i(int, int, int, int);
86
87Rec2Df lg_rec_f(float, float, float, float);
88
90
92
93Point2Di lg_point2d_i(int32_t, int32_t);
94
95Point2Df lg_point2d_f(float, float);
96
98
100
101void gl_coords_from_screen_coords(float *, float *, int, int, int, int);
102
103void logical_coords_from_viewport_coords(int *, int *, int, int);
104
106
107void logical_coords_from_touchscreen_coords(int *, int *, float, float);
108
109void lg_set_touchscreen_coords_margins(float, float);
110
112
113uint32_t lg_point2df_is_inside_rec2df_from_array(Point2Df, Rec2Df **, uint32_t);
114
115int32_t sdl_to_gl_int_x(int32_t);
116
117int32_t sdl_to_gl_int_y(int32_t);
118
119float sdl_to_gl_float_x(int32_t);
120
121float sdl_to_gl_float_y(int32_t);
122
123#if 0
124// That's horrifying -> substitute
125lg_get_lg_color_u_from_str() -> color_u_from_str()
126
127lg_color_u_from_sdl_color() -> color_u_from_sdl_color()
128
129lg_set_lg_color_u_from_str() -> set_color_u_from_str()
130
131lg_get_color_str_from_color_index() -> color_str_from_color_index()
132
133lg_get_sdl_color_from_str() -> sdl_color_from_str()
134
135lg_sdl_color_from_lg_color_u() -> sdl_color_from_color_u()
136
137lg_set_sdl_color_from_str() -> set_sdl_color_from_str()
138#endif
139
141
143
144SDL_Color *lg_set_sdl_color_from_str(SDL_Color *, const char *);
145
146SDL_Color lg_get_sdl_color_from_str(const char *);
147
149
151
153
154const char *lg_get_color_str_from_color_index(int);
155
157
158void v_flip_sdl_surf(SDL_Surface *);
159
160#endif /* LG_GR_FUNC_H */
void lg_rec_i_copy(Rec2Di *dest, Rec2Di src)
Definition lg_gr_func.c:254
zboolean lg_rec_f_are_equal(Rec2Df *r1, Rec2Df *r2)
Definition lg_gr_func.c:295
void lg_copy_rec(Rec2Di src, Rec2Di *dest)
Definition lg_gr_func.c:240
Point2Df lg_rec_f_center(Rec2Df r)
Definition lg_gr_func.c:419
int32_t sdl_to_gl_int_x(int32_t x)
Definition lg_gr_func.c:579
void lg_clear_rec(Rec2Di r, LG_Color_u c)
Definition lg_gr_func.c:120
void v_flip_sdl_surf(SDL_Surface *surf)
Definition lg_gr_func.c:782
void lg_rec_f_copy(Rec2Df *dest, Rec2Df src)
Definition lg_gr_func.c:268
void logical_coords_from_viewport_coords_btaskbar_adjustment(int bth_adj)
Definition lg_gr_func.c:477
Rec2Di lg_rec_i(int x, int y, int w, int h)
Definition lg_gr_func.c:312
Rec2Df lg_rec_f_from_rec_i(Rec2Di r)
Definition lg_gr_func.c:351
void lg_draw_line(int32_t x1, int32_t y1, int32_t x2, int32_t y2, LG_Color_u c)
Definition lg_gr_func.c:32
zboolean lg_rec_i_are_equal(Rec2Di *r1, Rec2Di *r2)
Definition lg_gr_func.c:283
SDL_Color lg_get_sdl_color_from_str(const char *str)
Definition lg_gr_func.c:701
void gl_coords_from_screen_coords(float *x2, float *y2, int x1, int y1, int viewport_w, int viewport_h)
Definition lg_gr_func.c:437
LG_Color_u lg_color_u_from_sdl_color(SDL_Color c)
Definition lg_gr_func.c:659
SDL_Color * lg_set_sdl_color_from_str(SDL_Color *c, const char *str)
Definition lg_gr_func.c:678
float sdl_to_gl_float_x(int32_t x)
Definition lg_gr_func.c:605
SDL_Color lg_sdl_color_from_lg_color_u(LG_Color_u c)
Definition lg_gr_func.c:670
Point2Di lg_point2d_i(int32_t x, int32_t y)
Definition lg_gr_func.c:383
void logical_coords_from_touchscreen_coords(int *x2, int *y2, float x1, float y1)
Definition lg_gr_func.c:498
LG_Color_u lg_get_lg_color_u_from_str(const char *str)
Definition lg_gr_func.c:721
void lg_draw_rec(Rec2Di r, LG_Color_u c)
Definition lg_gr_func.c:48
zboolean lg_recs_overlap(Rec2Df *r1, Rec2Df *r2)
Definition lg_gr_func.c:223
Rec2Di lg_rec_i_from_rec_f(Rec2Df r)
Definition lg_gr_func.c:364
zboolean lg_clip_rec(Rec2Di clip, Rec2Di rec, Rec2Di *clipped_rec)
Definition lg_gr_func.c:167
uint32_t lg_point2di_is_inside_rec2di_from_array(Point2Di p, Rec2Di **r, uint32_t n_rec_max)
Definition lg_gr_func.c:535
const char * lg_get_color_str_from_color_index(int i)
Definition lg_gr_func.c:741
Rec2Df lg_rec_f(float x, float y, float w, float h)
Definition lg_gr_func.c:333
int lg_get_n_color_str()
Definition lg_gr_func.c:730
void logical_coords_from_viewport_coords(int *x2, int *y2, int x1, int y1)
Definition lg_gr_func.c:459
void lg_set_touchscreen_coords_margins(float left, float top)
Definition lg_gr_func.c:519
Point2Df lg_point2d_f(float x, float y)
Definition lg_gr_func.c:395
int32_t sdl_to_gl_int_y(int32_t y)
Definition lg_gr_func.c:590
float sdl_to_gl_float_y(int32_t y)
Definition lg_gr_func.c:619
LG_Color_u * lg_set_lg_color_u_from_str(LG_Color_u *c, const char *str)
Definition lg_gr_func.c:712
Point2Di lg_rec_i_center(Rec2Di r)
Definition lg_gr_func.c:408
void lg_fill_rec(Rec2Di r, LG_Color_u c)
Definition lg_gr_func.c:93
void lg_color_str_list_info()
Definition lg_gr_func.c:753
Definition lg_vertex.h:111
Definition lg_gr_func.h:32
Definition lg_gr_func.h:25
Definition lg_gr_func.h:20
Definition lg_gr_func.h:15
Definition lg_gr_func.h:56
Definition lg_gr_func.h:49