![]() |
LibGame v0.4.0
The LG Game Engine - Copyright (C) 2024-2025 ETMSoftware
|
Functions | |
| void | lg_enable_transparency () |
| void | lg_disable_transparency () |
| int | lg_check_gl_errors (long long log_time, const char *file, int line, const char *func) |
| int | lg_check_gl_context () |
| lg_endianness | lg_get_arch_endianness () |
| float | lg_tv_diff (struct timeval *t_diff, struct timeval *t2, struct timeval *t1) |
| int | delta_i (int i) |
| float | delta_f (float f) |
| zboolean | has_changed_i (int i) |
| zboolean | has_changed_f (float f) |
| double | clamp (double v, double min, double max) |
| void * | lg_align_up_to_next_4_bytes_boundary (void *addr) |
| void * | lg_align_up_to_next_8_bytes_boundary (void *addr) |
| void | lg_swap_values (void *x, void *y, WidthInBytes width) |
| void | debug_start_max_int_in_loop () |
| void | debug_max_int_in_loop (unsigned long i, const char *file, int line) |
| void | debug_end_max_int_in_loop () |
| void | debug_start_max_float_in_loop () |
| void | debug_max_float_in_loop (float f, const char *file, int line) |
| void | debug_end_max_float_in_loop () |
| int | lg_check_datatype_sizes () |
| void | lg_show_struct_sizes (zboolean everything) |
| int | lg_show_pixel_format_info_from_sdl_display_mode (SDL_DisplayMode *display_mode) |
| void | lg_show_utf8_drawings (zboolean extra_n) |
A loose collection of funcs that don't belong to a specific module (so far ...)
| void lg_enable_transparency | ( | ) |
Enabling transparency before calling glDraw* funcs
| void lg_disable_transparency | ( | ) |
Disabling transparency (default)
| int lg_check_gl_errors | ( | long long | log_time, |
| const char * | file, | ||
| int | line, | ||
| const char * | func | ||
| ) |
Check GL errors
| log_time | lg_log_time() |
| file | __ FILE __ (without spaces) |
| line | __ LINE __ (without spaces) |
| func | __ func __ (without spaces) |
| int lg_check_gl_context | ( | ) |
Check OpenGL context, ie if the current context is not NULL and whether it has changed since app startup
| lg_endianness lg_get_arch_endianness | ( | ) |
Get architecture endianness
From: https://developer.ibm.com/articles/au-endianc/
| float lg_tv_diff | ( | struct timeval * | t_diff, |
| struct timeval * | t2, | ||
| struct timeval * | t1 | ||
| ) |
Compute t2 - t1 (in s and µs), store the result in t_diff (in s and µs), and return diff in ms (as a float)
Example use:
| t_diff | A pointer to a struct timeval |
| t2 | A pointer to a struct timeval |
| t1 | A pointer to a struct timeval |
| int delta_i | ( | int | i | ) |
Return delta of an int value since last call
| i | An int value |
| float delta_f | ( | float | f | ) |
Return delta of a float value since last call
| f | A float value |
| zboolean has_changed_i | ( | int | i | ) |
Check if an int value has changed since last call
| i | An int value |
| zboolean has_changed_f | ( | float | f | ) |
Check if a float value has changed since last call, using LG_FLOAT_EPSILON for comparison
| f | A float value |
| double clamp | ( | double | v, |
| double | min, | ||
| double | max | ||
| ) |
Clamp implementation
| v | Value to clamp |
| min | Min value |
| max | Max value |
| void * lg_align_up_to_next_4_bytes_boundary | ( | void * | addr | ) |
Align memory addr up to next 4 bytes boundary, unless already aligned
| addr | Memory address |
| void * lg_align_up_to_next_8_bytes_boundary | ( | void * | addr | ) |
Align memory addr up to next 8 bytes boundary, unless already aligned
| addr | Memory address |
| void lg_swap_values | ( | void * | x, |
| void * | y, | ||
| WidthInBytes | width | ||
| ) |
Portable value swapping
No input checking is done
Helper typdef for width in bytes
| x | Pointer to value #1 |
| y | Pointer to value #2 |
| width | Width in bytes of value type |
| void debug_start_max_int_in_loop | ( | ) |
For debugging purposes - 'Reset' max_int_in_loop
| void debug_max_int_in_loop | ( | unsigned long | i, |
| const char * | file, | ||
| int | line | ||
| ) |
For debugging purposes - Print out max value found so far while running loop
Example use:
i = 0;
debug_start_max_int_in_loop();
for (y = 0; y < h; y++) {
for (x = 0; x < w; x++) {
debug_max_int_in_loop((unsigned long)i, __FILE__, __LINE__);
// ...
terrain->vbo_data[i].x = (float)x / (float)w;
terrain->vbo_data[i].y = heightmap[x + y * w] * vert_scaling_k;
terrain->vbo_data[i].z = (float)y / (float)h;
// ...
i++;
}
}
debug_end_max_int_in_loop();
| i | Integer to test |
| file | Should be "__FILE__" |
| line | Should be "__LINE__" |
| void debug_end_max_int_in_loop | ( | ) |
For debugging purposes - Just print out closing '\n'
| void debug_start_max_float_in_loop | ( | ) |
For debugging purposes - 'Reset' max_float_in_loop
| void debug_max_float_in_loop | ( | float | f, |
| const char * | file, | ||
| int | line | ||
| ) |
For debugging purposes - Print out max value found so far while running loop
Example use: same as above with float instead of int
| f | float to test |
| file | Should be "__FILE__" |
| line | Should be "__LINE__" |
| void debug_end_max_float_in_loop | ( | ) |
For debugging purposes - Just print out closing '\n'
| int lg_check_datatype_sizes | ( | ) |
Check C and OpenGL types at runtime - should be called early at init time
Also see: https://www.khronos.org/opengl/wiki/OpenGL_Type
| void lg_show_struct_sizes | ( | zboolean | everything | ) |
Mainly for internal testing, but quite informative about memory consumption
Make sure to add new structs
| everything | Every structs if TRUE , only big or new/interesting ones otherwise |
| int lg_show_pixel_format_info_from_sdl_display_mode | ( | SDL_DisplayMode * | display_mode | ) |
Show pixel format info bla bla
See: https://wiki.libsdl.org/SDL_PixelFormat
| display_mode | Pointer to a SDL_DisplayMode struct |
| void lg_show_utf8_drawings | ( | zboolean | extra_n | ) |
Helper func to draw some UTF-8 stuff like arrows, lines, and corners, along with their hex codes and tokens
Is that any useful actually ?
Pretty handy when trying to draw UTF-8 boxes
| extra_n | Add an extra "\n" at end of lines (will look less "compact") |