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_rect(Rec2Di, Rec2Di, Rec2Di *);
72
73zboolean lg_recs_overlap(Rec2Df *, Rec2Df *);
74
76
78
80
81Rec2Di lg_rec_i(int, int, int, int);
82
83Rec2Df lg_rec_f(float, float, float, float);
84
86
88
89Point2Di lg_point2d_i(int32_t, int32_t);
90
91Point2Df lg_point2d_f(float, float);
92
94
96
97void gl_coords_from_screen_coords(float *, float *, int, int, int, int);
98
99void logical_coords_from_viewport_coords(int *, int *, int, int);
100
102
103void logical_coords_from_touchscreen_coords(int *, int *, float, float);
104
105void lg_set_touchscreen_coords_margins(float, float);
106
108
109uint32_t lg_point2df_is_inside_rec2df_from_array(Point2Df, Rec2Df **, uint32_t);
110
111int32_t sdl_to_gl_int_x(int32_t);
112
113int32_t sdl_to_gl_int_y(int32_t);
114
115float sdl_to_gl_float_x(int32_t);
116
117float sdl_to_gl_float_y(int32_t);
118
119#if 0
120// That's horrifying -> substitute
121lg_get_lg_color_u_from_str() -> color_u_from_str()
122
123lg_color_u_from_sdl_color() -> color_u_from_sdl_color()
124
125lg_set_lg_color_u_from_str() -> set_color_u_from_str()
126
127lg_get_color_str_from_color_index() -> color_str_from_color_index()
128
129lg_get_sdl_color_from_str() -> sdl_color_from_str()
130
131lg_sdl_color_from_lg_color_u() -> sdl_color_from_color_u()
132
133lg_set_sdl_color_from_str() -> set_sdl_color_from_str()
134#endif
135
137
139
140SDL_Color *lg_set_sdl_color_from_str(SDL_Color *, const char *);
141
142SDL_Color lg_get_sdl_color_from_str(const char *);
143
145
147
149
151
153
154void v_flip_sdl_surf(SDL_Surface *);
155
156#endif /* LG_GR_FUNC_H */
void lg_rec_i_copy(Rec2Di *dest, Rec2Di src)
Definition lg_gr_func.c:250
Point2Df lg_rec_f_center(Rec2Df r)
Definition lg_gr_func.c:388
int32_t sdl_to_gl_int_x(int32_t x)
Definition lg_gr_func.c:548
void v_flip_sdl_surf(SDL_Surface *surf)
Definition lg_gr_func.c:749
void lg_rec_f_copy(Rec2Df *dest, Rec2Df src)
Definition lg_gr_func.c:264
void logical_coords_from_viewport_coords_btaskbar_adjustment(int bth_adj)
Definition lg_gr_func.c:446
Rec2Di lg_rec_i(int x, int y, int w, int h)
Definition lg_gr_func.c:281
Rec2Df lg_rec_f_from_rec_i(Rec2Di r)
Definition lg_gr_func.c:320
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:30
SDL_Color lg_get_sdl_color_from_str(const char *str)
Definition lg_gr_func.c:668
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:406
LG_Color_u lg_color_u_from_sdl_color(SDL_Color c)
Definition lg_gr_func.c:626
uint32_t lg_point2di_is_inside_rec2di_from_array(Point2Di p, Rec2Di **r, uint32_t n_rect_max)
Definition lg_gr_func.c:504
SDL_Color * lg_set_sdl_color_from_str(SDL_Color *c, const char *str)
Definition lg_gr_func.c:645
float sdl_to_gl_float_x(int32_t x)
Definition lg_gr_func.c:574
SDL_Color lg_sdl_color_from_lg_color_u(LG_Color_u c)
Definition lg_gr_func.c:637
Point2Di lg_point2d_i(int32_t x, int32_t y)
Definition lg_gr_func.c:352
void logical_coords_from_touchscreen_coords(int *x2, int *y2, float x1, float y1)
Definition lg_gr_func.c:467
void lg_draw_rect(Rec2Di r, LG_Color_u c)
Definition lg_gr_func.c:46
LG_Color_u lg_get_lg_color_u_from_str(const char *str)
Definition lg_gr_func.c:688
zboolean lg_recs_overlap(Rec2Df *r1, Rec2Df *r2)
Definition lg_gr_func.c:219
Rec2Di lg_rec_i_from_rec_f(Rec2Df r)
Definition lg_gr_func.c:333
void lg_fill_rect(Rec2Di r, LG_Color_u c)
Definition lg_gr_func.c:89
void lg_clear_rect(Rec2Di r, LG_Color_u c)
Definition lg_gr_func.c:116
const char * lg_get_color_str_from_color_index(int i)
Definition lg_gr_func.c:708
Rec2Df lg_rec_f(float x, float y, float w, float h)
Definition lg_gr_func.c:302
int lg_get_n_color_str()
Definition lg_gr_func.c:697
void logical_coords_from_viewport_coords(int *x2, int *y2, int x1, int y1)
Definition lg_gr_func.c:428
void lg_set_touchscreen_coords_margins(float left, float top)
Definition lg_gr_func.c:488
Point2Df lg_point2d_f(float x, float y)
Definition lg_gr_func.c:364
int32_t sdl_to_gl_int_y(int32_t y)
Definition lg_gr_func.c:559
float sdl_to_gl_float_y(int32_t y)
Definition lg_gr_func.c:588
LG_Color_u * lg_set_lg_color_u_from_str(LG_Color_u *c, const char *str)
Definition lg_gr_func.c:679
zboolean lg_clip_rect(Rec2Di clip, Rec2Di rect, Rec2Di *clipped_rect)
Definition lg_gr_func.c:163
Point2Di lg_rec_i_center(Rec2Di r)
Definition lg_gr_func.c:377
void lg_color_str_list_info()
Definition lg_gr_func.c:720
void lg_copy_rect(Rec2Di src, Rec2Di *dest)
Definition lg_gr_func.c:236
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