LibGame  v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
lg_gr_func.h
1 /*
2  * LibGame - Copyright (C) Emmanuel Thomas-Maurin 2011-2024
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 
13 typedef struct {
14  int32_t x;
15  int32_t y;
16 } Point2Di;
17 
18 typedef struct {
19  float x;
20  float y;
21 } Point2Df;
22 
23 typedef struct {
24  int32_t x1;
25  int32_t y1;
26  int32_t x2;
27  int32_t y2;
28 } Line2Di;
29 
30 typedef struct {
31  float x1;
32  float y1;
33  float x2;
34  float y2;
35 } Line2Df;
36 
37 /*
38  * Rec = rectangle (floats) with OpenGL coord sys orientation
39  * ^
40  * |
41  * x,y+h |--------
42  * | |
43  * | |
44  * ------------->
45  * x,y x+w,y
46  */
47 typedef struct {
48  int32_t x;
49  int32_t y;
50  int32_t w;
51  int32_t h;
52 } Rec2Di;
53 
54 typedef struct {
55  float x;
56  float y;
57  float w;
58  float h;
59 } Rec2Df;
60 
61 void lg_draw_line(int32_t, int32_t, int32_t, int32_t, LG_Color_u);
62 
64 
65 void lg_fill_rect(Rec2Di r, LG_Color_u c);
66 
68 
69 zboolean lg_clip_rect(Rec2Di, Rec2Di, Rec2Di *);
70 
71 zboolean lg_recs_overlap(Rec2Df *, Rec2Df *);
72 
73 void lg_copy_rect(Rec2Di, Rec2Di *);
74 
75 void lg_rec_i_copy(Rec2Di *, Rec2Di);
76 
77 void lg_rec_f_copy(Rec2Df *, Rec2Df);
78 
79 Rec2Di lg_rec_i(int, int, int, int);
80 
81 Rec2Df lg_rec_f(float, float, float, float);
82 
84 
86 
87 Point2Di lg_point2d_i(int32_t, int32_t);
88 
89 Point2Df lg_point2d_f(float, float);
90 
92 
94 
95 int32_t sdl_to_gl_int_x(int32_t);
96 
97 int32_t sdl_to_gl_int_y(int32_t);
98 
99 float sdl_to_gl_float_x(int32_t);
100 
101 float sdl_to_gl_float_y(int32_t);
102 
104 
106 
107 SDL_Color *lg_set_sdl_color_from_str(SDL_Color *, const char *);
108 
109 SDL_Color lg_get_sdl_color_from_str(const char *);
110 
112 
114 
115 int lg_get_n_color_str();
116 
118 
119 void v_flip_sdl_surf(SDL_Surface *);
120 
121 #endif /* LG_GR_FUNC_H */
sdl_to_gl_int_x
int32_t sdl_to_gl_int_x(int32_t x)
Definition: lg_gr_func.c:397
lg_point2d_f
Point2Df lg_point2d_f(float x, float y)
Definition: lg_gr_func.c:362
lg_rec_f_center
Point2Df lg_rec_f_center(Rec2Df r)
Definition: lg_gr_func.c:386
Rec2Df
Definition: lg_gr_func.h:54
Point2Df
Definition: lg_gr_func.h:18
sdl_to_gl_int_y
int32_t sdl_to_gl_int_y(int32_t y)
Definition: lg_gr_func.c:408
lg_rec_f_copy
void lg_rec_f_copy(Rec2Df *dest, Rec2Df src)
Definition: lg_gr_func.c:262
lg_get_lg_color_u_from_str
LG_Color_u lg_get_lg_color_u_from_str(const char *str)
Definition: lg_gr_func.c:536
lg_sdl_color_from_lg_color_u
SDL_Color lg_sdl_color_from_lg_color_u(LG_Color_u c)
Definition: lg_gr_func.c:485
Point2Di
Definition: lg_gr_func.h:13
lg_point2d_i
Point2Di lg_point2d_i(int32_t x, int32_t y)
Definition: lg_gr_func.c:350
lg_get_sdl_color_from_str
SDL_Color lg_get_sdl_color_from_str(const char *str)
Definition: lg_gr_func.c:516
Line2Df
Definition: lg_gr_func.h:30
lg_recs_overlap
zboolean lg_recs_overlap(Rec2Df *r1, Rec2Df *r2)
Definition: lg_gr_func.c:217
lg_get_color_str_from_color_index
const char * lg_get_color_str_from_color_index(int i)
Definition: lg_gr_func.c:556
lg_clear_rect
void lg_clear_rect(Rec2Di r, LG_Color_u c)
Definition: lg_gr_func.c:114
lg_draw_rect
void lg_draw_rect(Rec2Di r, LG_Color_u c)
Definition: lg_gr_func.c:44
lg_rec_i_from_rec_f
Rec2Di lg_rec_i_from_rec_f(Rec2Df r)
Definition: lg_gr_func.c:331
lg_set_lg_color_u_from_str
LG_Color_u * lg_set_lg_color_u_from_str(LG_Color_u *c, const char *str)
Definition: lg_gr_func.c:527
lg_rec_i
Rec2Di lg_rec_i(int x, int y, int w, int h)
Definition: lg_gr_func.c:279
lg_color_u_from_sdl_color
LG_Color_u lg_color_u_from_sdl_color(SDL_Color c)
Definition: lg_gr_func.c:474
lg_fill_rect
void lg_fill_rect(Rec2Di r, LG_Color_u c)
Definition: lg_gr_func.c:87
lg_rec_i_center
Point2Di lg_rec_i_center(Rec2Di r)
Definition: lg_gr_func.c:375
lg_draw_line
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:28
lg_rec_f
Rec2Df lg_rec_f(float x, float y, float w, float h)
Definition: lg_gr_func.c:300
LG_Color_u
Definition: lg_vertex.h:91
Line2Di
Definition: lg_gr_func.h:23
sdl_to_gl_float_y
float sdl_to_gl_float_y(int32_t y)
Definition: lg_gr_func.c:437
sdl_to_gl_float_x
float sdl_to_gl_float_x(int32_t x)
Definition: lg_gr_func.c:423
v_flip_sdl_surf
void v_flip_sdl_surf(SDL_Surface *surf)
Definition: lg_gr_func.c:579
lg_copy_rect
void lg_copy_rect(Rec2Di src, Rec2Di *dest)
Definition: lg_gr_func.c:234
lg_rec_f_from_rec_i
Rec2Df lg_rec_f_from_rec_i(Rec2Di r)
Definition: lg_gr_func.c:318
lg_clip_rect
zboolean lg_clip_rect(Rec2Di clip, Rec2Di rect, Rec2Di *clipped_rect)
Definition: lg_gr_func.c:161
lg_rec_i_copy
void lg_rec_i_copy(Rec2Di *dest, Rec2Di src)
Definition: lg_gr_func.c:248
lg_set_sdl_color_from_str
SDL_Color * lg_set_sdl_color_from_str(SDL_Color *c, const char *str)
Definition: lg_gr_func.c:493
Rec2Di
Definition: lg_gr_func.h:47
lg_get_n_color_str
int lg_get_n_color_str()
Definition: lg_gr_func.c:545