LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
|
=== A few 2D structs and graphical funcs === Quite messy, also a lot of convenience conversion funcs
void lg_draw_line | ( | int32_t | x1, |
int32_t | y1, | ||
int32_t | x2, | ||
int32_t | y2, | ||
LG_Color_u | c | ||
) |
Draw a line from (x1, y1) to (x2, y2)
Expect SDL coord sys (logical coords, ie inside [0 -> env->top_win_logical_w] x [0 -> env->top_win_logical_h])
x1 | Origin x coord |
y1 | Origin y coord |
x2 | Dest x coord |
y2 | Dest y coord |
c | A LG_Color_u |
void lg_draw_rect | ( | Rec2Di | r, |
LG_Color_u | c | ||
) |
Draw a rectangle
Expect SDL coord sys (logical coords, ie inside [0 -> env->top_win_logical_w] x [0 -> env->top_win_logical_h])
r | A Rec2Di |
c | A LG_Color_u |
void lg_fill_rect | ( | Rec2Di | r, |
LG_Color_u | c | ||
) |
Fill a rectangle with color - now just call lg_render_rect_2d()
Expect SDL coord sys (logical coords, ie inside [0 -> env->top_win_logical_w] x [0 -> env->top_win_logical_h])
lg_fill_rect() is about three times faster than lg_clear_rect()
In test/test.c: test_lg_draw_fill_rect()): - Time to draw with lg_clear_rect() = 6.582 ms - Time to draw with lg_fill_rect() = 1.925 ms
r | A Rec2Di |
c | A LG_Color_u |
void lg_clear_rect | ( | Rec2Di | r, |
LG_Color_u | c | ||
) |
Clear a rectangle with color
Expect SDL coord sys (logical coords, ie inside [0 -> env->top_win_logical_w] x [0 -> env->top_win_logical_h])
lg_clear_rect() is about three times slower than lg_fill_rect() (see above)
r | A Rec2Di |
c | A LG_Color_u |
Return FALSE if rect is fully outside clip. Otherwise, set clipped_rect (rect is unchanged) and return TRUE.
TODO: should be lg_copy_rect(dest, src) for consistency sake
DEPRECATED anyways
src | |
dest |
Rec2Df lg_rec_f | ( | float | x, |
float | y, | ||
float | w, | ||
float | h | ||
) |
Point2Di lg_point2d_i | ( | int32_t | x, |
int32_t | y | ||
) |
int32_t sdl_to_gl_int_x | ( | int32_t | x | ) |
Convert from SDL coords to OpenGL coords
x |
int32_t sdl_to_gl_int_y | ( | int32_t | y | ) |
Convert from SDL coords to OpenGL coords
y |
float sdl_to_gl_float_x | ( | int32_t | x | ) |
Convert from SDL coords to OpenGL coords
About the 0.375 value, see: https://www.opengl.org/archives/resources/faq/technical/transformations.htm
x |
float sdl_to_gl_float_y | ( | int32_t | y | ) |
Convert from SDL coords to OpenGL coords
About the 0.375 value, see: https://www.opengl.org/archives/resources/faq/technical/transformations.htm
y |
LG_Color_u lg_color_u_from_sdl_color | ( | SDL_Color | c | ) |
SDL_Color lg_sdl_color_from_lg_color_u | ( | LG_Color_u | c | ) |
SDL_Color* lg_set_sdl_color_from_str | ( | SDL_Color * | c, |
const char * | str | ||
) |
Bla bla (self-explanatory)
SDL_Color lg_get_sdl_color_from_str | ( | const char * | str | ) |
Bla bla (self-explanatory)
LG_Color_u* lg_set_lg_color_u_from_str | ( | LG_Color_u * | c, |
const char * | str | ||
) |
Bla bla (self-explanatory)
LG_Color_u lg_get_lg_color_u_from_str | ( | const char * | str | ) |
Bla bla (self-explanatory)
int lg_get_n_color_str | ( | ) |
Bla bla (self-explanatory)
const char* lg_get_color_str_from_color_index | ( | int | i | ) |
Bla bla (self-explanatory)
void v_flip_sdl_surf | ( | SDL_Surface * | surf | ) |
Flip (vertical one) SDL surf
TODO: fix the compilation warning
(From gcc doc) === gcc option -Wpointer-arith ===
Warn about anything that depends on the “size of” a function type or of void. GNU C assigns these types a size of 1, for convenience in calculations with void * pointers and pointers to functions.
(WTF ?)