This commit is contained in:
Angel Ortigosa Perez
2026-02-12 17:45:06 +01:00
parent 6579882198
commit 2707e12133
80 changed files with 185 additions and 1489 deletions

0
lib/mlx/include/KHR/khrplatform.h Executable file → Normal file
View File

110
lib/mlx/include/MLX42/MLX42.h Executable file → Normal file
View File

@@ -6,7 +6,7 @@
/* By: W2Wizard <main@w2wizard.dev> +#+ */
/* +#+ */
/* Created: 2021/12/28 02:29:06 by W2Wizard #+# #+# */
/* Updated: 2025/11/16 13:00:19 by w2wizard ######## odam.nl */
/* Updated: 2023/03/30 16:23:19 by ntamayo- ######## odam.nl */
/* */
/* ************************************************************************** */
@@ -32,17 +32,6 @@
# include <stddef.h>
# include <stdint.h>
# include <stdbool.h>
#if defined(_WIN32)
# if defined(MLX42_BUILD_SHARED)
# define MLX_API __declspec(dllexport)
# else
# define MLX_API __declspec(dllimport)
# endif
#else
#define MLX_API __attribute__((visibility("default")))
#endif
# ifdef __cplusplus
extern "C" {
# endif
@@ -489,14 +478,7 @@ typedef void mlx_win_cursor_t;
* @param[in] val The error code.
* @return The error string that describes the error code.
*/
MLX_API const char* mlx_strerror(mlx_errno_t val);
/**
* Gets the current global error code of MLX. Useful for FFI bindings.
* @example printf("Error: %s\n", mlx_strerror(get_mlx_errno()));
* @return The current global error code.
*/
MLX_API mlx_errno_t mlx_get_errno(void);
const char* mlx_strerror(mlx_errno_t val);
//= Generic Functions =//
@@ -509,7 +491,7 @@ MLX_API mlx_errno_t mlx_get_errno(void);
* @param[in] resize Enable window resizing.
* @returns Ptr to the MLX handle or null on failure.
*/
MLX_API mlx_t* mlx_init(int32_t width, int32_t height, const char* title, bool resize);
mlx_t* mlx_init(int32_t width, int32_t height, const char* title, bool resize);
/**
* Set a setting for MLX42.
@@ -518,7 +500,7 @@ MLX_API mlx_t* mlx_init(int32_t width, int32_t height, const char* title, bool r
* @param[in] setting The settings value, See mlx_settings_t type.
* @param[in] value Settings value to determine the state of the setting. Can be a boolean or an enum / macro.
*/
MLX_API void mlx_set_setting(mlx_settings_t setting, int32_t value);
void mlx_set_setting(mlx_settings_t setting, int32_t value);
/**
* Notifies MLX that it should stop rendering and exit the main loop.
@@ -526,7 +508,7 @@ MLX_API void mlx_set_setting(mlx_settings_t setting, int32_t value);
*
* @param[in] mlx The MLX instance handle.
*/
MLX_API void mlx_close_window(mlx_t* mlx);
void mlx_close_window(mlx_t* mlx);
/**
* Initializes the rendering of MLX, this function won't return until
@@ -535,7 +517,7 @@ MLX_API void mlx_close_window(mlx_t* mlx);
*
* @param[in] mlx The MLX instance handle.
*/
MLX_API void mlx_loop(mlx_t* mlx);
void mlx_loop(mlx_t* mlx);
/**
* Lets you set a custom image as the program icon.
@@ -547,7 +529,7 @@ MLX_API void mlx_loop(mlx_t* mlx);
* @param[in] mlx The MLX instance handle.
* @param[in] image The image to use as icon.
*/
MLX_API void mlx_set_icon(mlx_t* mlx, mlx_texture_t* image);
void mlx_set_icon(mlx_t* mlx, mlx_texture_t* image);
/**
* Terminates MLX and cleans up any of its used resources.
@@ -556,14 +538,14 @@ MLX_API void mlx_set_icon(mlx_t* mlx, mlx_texture_t* image);
*
* @param[in] mlx The MLX instance handle.
*/
MLX_API void mlx_terminate(mlx_t* mlx);
void mlx_terminate(mlx_t* mlx);
/**
* Gets the elapsed time since MLX was initialized.
*
* @return The amount of time elapsed in seconds.
*/
MLX_API double mlx_get_time(void);
double mlx_get_time(void);
//= Window/Monitor Functions =//
@@ -576,7 +558,7 @@ MLX_API double mlx_get_time(void);
*
* @param[in] mlx The MLX instance handle.
*/
MLX_API void mlx_focus(mlx_t* mlx);
void mlx_focus(mlx_t* mlx);
/**
* Gets the size of the specified monitor.
@@ -585,7 +567,7 @@ MLX_API void mlx_focus(mlx_t* mlx);
* @param[in] width The width of the window.
* @param[in] height The height of the window.
*/
MLX_API void mlx_get_monitor_size(int32_t index, int32_t* width, int32_t* height);
void mlx_get_monitor_size(int32_t index, int32_t* width, int32_t* height);
/**
* Sets the window's position.
@@ -597,7 +579,7 @@ MLX_API void mlx_get_monitor_size(int32_t index, int32_t* width, int32_t* height
* @param[in] xpos The x position.
* @param[in] ypos The y position.
*/
MLX_API void mlx_set_window_pos(mlx_t* mlx, int32_t xpos, int32_t ypos);
void mlx_set_window_pos(mlx_t* mlx, int32_t xpos, int32_t ypos);
/**
* Gets the window's position.
@@ -606,7 +588,7 @@ MLX_API void mlx_set_window_pos(mlx_t* mlx, int32_t xpos, int32_t ypos);
* @param[out] xpos The x position.
* @param[out] ypos The y position.
*/
MLX_API void mlx_get_window_pos(mlx_t* mlx, int32_t* xpos, int32_t* ypos);
void mlx_get_window_pos(mlx_t* mlx, int32_t* xpos, int32_t* ypos);
/**
* Changes the window size to the newly specified values.
@@ -616,7 +598,7 @@ MLX_API void mlx_get_window_pos(mlx_t* mlx, int32_t* xpos, int32_t* ypos);
* @param[in] new_width The new desired width.
* @param[in] new_height The new desired height.
*/
MLX_API void mlx_set_window_size(mlx_t* mlx, int32_t new_width, int32_t new_height);
void mlx_set_window_size(mlx_t* mlx, int32_t new_width, int32_t new_height);
/**
* Sets the size limits of the specified window.
@@ -631,7 +613,7 @@ MLX_API void mlx_set_window_size(mlx_t* mlx, int32_t new_width, int32_t new_heig
* @param[in] min_h The min height of the window.
* @param[in] max_h The max height of the window.
*/
MLX_API void mlx_set_window_limit(mlx_t* mlx, int32_t min_w, int32_t min_h, int32_t max_w, int32_t max_h);
void mlx_set_window_limit(mlx_t* mlx, int32_t min_w, int32_t min_h, int32_t max_w, int32_t max_h);
/**
* Sets the title of the window.
@@ -639,7 +621,7 @@ MLX_API void mlx_set_window_limit(mlx_t* mlx, int32_t min_w, int32_t min_h, int3
* @param[in] mlx The MLX instance handle.
* @param[in] title The window title.
*/
MLX_API void mlx_set_window_title(mlx_t* mlx, const char* title);
void mlx_set_window_title(mlx_t* mlx, const char* title);
//= Input Functions =//
@@ -650,7 +632,7 @@ MLX_API void mlx_set_window_title(mlx_t* mlx, const char* title);
* @param[in] key The keycode to check, use MLX_KEY_... to specify!
* @returns True or false if the key is down or not.
*/
MLX_API bool mlx_is_key_down(mlx_t* mlx, keys_t key);
bool mlx_is_key_down(mlx_t* mlx, keys_t key);
/**
* Checks whether a mouse button is pressed or not.
@@ -659,7 +641,7 @@ MLX_API bool mlx_is_key_down(mlx_t* mlx, keys_t key);
* @param[in] key A specific mouse key. e.g MLX_MOUSE_BUTTON_0
* @returns True or false if the mouse key is down or not.
*/
MLX_API bool mlx_is_mouse_down(mlx_t* mlx, mouse_key_t key);
bool mlx_is_mouse_down(mlx_t* mlx, mouse_key_t key);
/**
* Returns the current, relative, mouse cursor position on the window, starting
@@ -672,7 +654,7 @@ MLX_API bool mlx_is_mouse_down(mlx_t* mlx, mouse_key_t key);
* @param[out] x The position.
* @param[out] y The position.
*/
MLX_API void mlx_get_mouse_pos(mlx_t* mlx, int32_t* x, int32_t* y);
void mlx_get_mouse_pos(mlx_t* mlx, int32_t* x, int32_t* y);
/**
* Sets the mouse position.
@@ -680,7 +662,7 @@ MLX_API void mlx_get_mouse_pos(mlx_t* mlx, int32_t* x, int32_t* y);
* @param[in] mlx The MLX instance handle.
* @param[in] pos The position.
*/
MLX_API void mlx_set_mouse_pos(mlx_t* mlx, int32_t x, int32_t y);
void mlx_set_mouse_pos(mlx_t* mlx, int32_t x, int32_t y);
/**
* Defines the state for the cursor.
@@ -688,7 +670,7 @@ MLX_API void mlx_set_mouse_pos(mlx_t* mlx, int32_t x, int32_t y);
* @param[in] mlx The MLX instance handle.
* @param[in] mode A specified mouse mode.
*/
MLX_API void mlx_set_cursor_mode(mlx_t* mlx, mouse_mode_t mode);
void mlx_set_cursor_mode(mlx_t* mlx, mouse_mode_t mode);
/**
* Retrieves the system standard cursor.
@@ -696,7 +678,7 @@ MLX_API void mlx_set_cursor_mode(mlx_t* mlx, mouse_mode_t mode);
* @param[in] type The standard cursor type to create.
* @return The cursor object or null on failure.
*/
MLX_API mlx_win_cursor_t* mlx_create_std_cursor(cursor_t type);
mlx_win_cursor_t* mlx_create_std_cursor(cursor_t type);
/**
* Allows for the creation of custom cursors with a given texture.
@@ -707,14 +689,14 @@ MLX_API mlx_win_cursor_t* mlx_create_std_cursor(cursor_t type);
* @param[in] texture The texture to use as cursor.
* @returns The cursor object or null on failure.
*/
MLX_API mlx_win_cursor_t* mlx_create_cursor(mlx_texture_t* texture);
mlx_win_cursor_t* mlx_create_cursor(mlx_texture_t* texture);
/**
* Destroys the given cursor object.
*
* @param[in] cursor The cursor object to destroy.
*/
MLX_API void mlx_destroy_cursor(mlx_win_cursor_t* cursor);
void mlx_destroy_cursor(mlx_win_cursor_t* cursor);
/**
* Sets the current cursor to the given custom cursor.
@@ -722,7 +704,7 @@ MLX_API void mlx_destroy_cursor(mlx_win_cursor_t* cursor);
* @param[in] mlx The MLX instance handle.
* @param[in] cursor The cursor object to display, if null default cursor is selected.
*/
MLX_API void mlx_set_cursor(mlx_t* mlx, mlx_win_cursor_t* cursor);
void mlx_set_cursor(mlx_t* mlx, mlx_win_cursor_t* cursor);
//= Hooks =//
@@ -734,7 +716,7 @@ MLX_API void mlx_set_cursor(mlx_t* mlx, mlx_win_cursor_t* cursor);
* @param[in] func The scroll wheel callback function.
* @param[in] param An additional optional parameter.
*/
MLX_API void mlx_scroll_hook(mlx_t* mlx, mlx_scrollfunc func, void* param);
void mlx_scroll_hook(mlx_t* mlx, mlx_scrollfunc func, void* param);
/**
* This function sets the mouse callback, which is called when a mouse
@@ -744,7 +726,7 @@ MLX_API void mlx_scroll_hook(mlx_t* mlx, mlx_scrollfunc func, void* param);
* @param[in] func The mouse callback function.
* @param[in] param An additional optional parameter.
*/
MLX_API void mlx_mouse_hook(mlx_t* mlx, mlx_mousefunc func, void* param);
void mlx_mouse_hook(mlx_t* mlx, mlx_mousefunc func, void* param);
/**
* This function sets the cursor callback, which is called when the
@@ -754,7 +736,7 @@ MLX_API void mlx_mouse_hook(mlx_t* mlx, mlx_mousefunc func, void* param);
* @param[in] func The cursor callback function.
* @param[in] param An additional optional parameter.
*/
MLX_API void mlx_cursor_hook(mlx_t* mlx, mlx_cursorfunc func, void* param);
void mlx_cursor_hook(mlx_t* mlx, mlx_cursorfunc func, void* param);
/**
* This function sets the key callback, which is called when a key is pressed
@@ -764,7 +746,7 @@ MLX_API void mlx_cursor_hook(mlx_t* mlx, mlx_cursorfunc func, void* param);
* @param[in] func The keypress callback function.
* @param[in] param An additional optional parameter.
*/
MLX_API void mlx_key_hook(mlx_t* mlx, mlx_keyfunc func, void* param);
void mlx_key_hook(mlx_t* mlx, mlx_keyfunc func, void* param);
/**
* This function sets the close callback, which is called in attempt to close
@@ -774,7 +756,7 @@ MLX_API void mlx_key_hook(mlx_t* mlx, mlx_keyfunc func, void* param);
* @param[in] func The close callback function.
* @param[in] param An additional optional parameter.
*/
MLX_API void mlx_close_hook(mlx_t* mlx, mlx_closefunc func, void* param);
void mlx_close_hook(mlx_t* mlx, mlx_closefunc func, void* param);
/**
* This function sets the resize callback, which is called when the window is
@@ -784,7 +766,7 @@ MLX_API void mlx_close_hook(mlx_t* mlx, mlx_closefunc func, void* param);
* @param[in] func The resize callback function.
* @param[in] param An additional optional parameter.
*/
MLX_API void mlx_resize_hook(mlx_t* mlx, mlx_resizefunc func, void* param);
void mlx_resize_hook(mlx_t* mlx, mlx_resizefunc func, void* param);
/**
* Generic loop hook for any custom hooks to add to the main loop.
@@ -795,7 +777,7 @@ MLX_API void mlx_resize_hook(mlx_t* mlx, mlx_resizefunc func, void* param);
* @param[in] param The parameter to pass on to the function.
* @returns Whether or not the hook was added successfully.
*/
MLX_API bool mlx_loop_hook(mlx_t* mlx, void (*f)(void*), void* param);
bool mlx_loop_hook(mlx_t* mlx, void (*f)(void*), void* param);
//= Texture Functions =//
@@ -805,7 +787,7 @@ MLX_API bool mlx_loop_hook(mlx_t* mlx, void (*f)(void*), void* param);
* @param[in] path Path to the PNG file.
* @return If successful the texture data is returned, else NULL.
*/
MLX_API mlx_texture_t* mlx_load_png(const char* path);
mlx_texture_t* mlx_load_png(const char* path);
/**
* Loads an XPM42 texture from the given file path.
@@ -813,14 +795,14 @@ MLX_API mlx_texture_t* mlx_load_png(const char* path);
* @param[in] path The file path to the XPM texture.
* @returns The XPM texture struct containing its information.
*/
MLX_API xpm_t* mlx_load_xpm42(const char* path);
xpm_t* mlx_load_xpm42(const char* path);
/**
* Deletes a texture by freeing its allocated data.
*
* @param[in] texture The texture to free.
*/
MLX_API void mlx_delete_texture(mlx_texture_t* texture);
void mlx_delete_texture(mlx_texture_t* texture);
/**
* Deletes an XPM42 texture by freeing its allocated data.
@@ -830,7 +812,7 @@ MLX_API void mlx_delete_texture(mlx_texture_t* texture);
*
* @param[in] xpm The xpm texture to delete.
*/
MLX_API void mlx_delete_xpm42(xpm_t* xpm);
void mlx_delete_xpm42(xpm_t* xpm);
/**
* Converts a given texture to an image.
@@ -839,7 +821,7 @@ MLX_API void mlx_delete_xpm42(xpm_t* xpm);
* @param[in] texture The texture to use to create the image from.
* @return mlx_image_t* The image created from the texture.
*/
MLX_API mlx_image_t* mlx_texture_to_image(mlx_t* mlx, mlx_texture_t* texture);
mlx_image_t* mlx_texture_to_image(mlx_t* mlx, mlx_texture_t* texture);
//= Image Functions =//
@@ -854,7 +836,7 @@ MLX_API mlx_image_t* mlx_texture_to_image(mlx_t* mlx, mlx_texture_t* texture);
* @param[in] y The Y coordinate position.
* @param[in] color The color value to put.
*/
MLX_API void mlx_put_pixel(mlx_image_t* image, uint32_t x, uint32_t y, uint32_t color);
void mlx_put_pixel(mlx_image_t* image, uint32_t x, uint32_t y, uint32_t color);
/**
* Creates and allocates a new image buffer.
@@ -864,7 +846,7 @@ MLX_API void mlx_put_pixel(mlx_image_t* image, uint32_t x, uint32_t y, uint32_t
* @param[in] height The desired height of the image.
* @return Pointer to the image buffer, if it failed to allocate then NULL.
*/
MLX_API mlx_image_t* mlx_new_image(mlx_t* mlx, uint32_t width, uint32_t height);
mlx_image_t* mlx_new_image(mlx_t* mlx, uint32_t width, uint32_t height);
/**
* Draws a new instance of an image, it will then share the same
@@ -883,7 +865,7 @@ MLX_API mlx_image_t* mlx_new_image(mlx_t* mlx, uint32_t width, uint32_t height);
* @param[in] y The Y position.
* @return Index to the instance, or -1 on failure.
*/
MLX_API int32_t mlx_image_to_window(mlx_t* mlx, mlx_image_t* img, int32_t x, int32_t y);
int32_t mlx_image_to_window(mlx_t* mlx, mlx_image_t* img, int32_t x, int32_t y);
/**
* Deleting an image will remove it from the render queue as well as any and all
@@ -896,7 +878,7 @@ MLX_API int32_t mlx_image_to_window(mlx_t* mlx, mlx_image_t* img, int32_t x, int
* @param[in] mlx The MLX instance handle.
* @param[in] image The image to delete.
*/
MLX_API void mlx_delete_image(mlx_t* mlx, mlx_image_t* image);
void mlx_delete_image(mlx_t* mlx, mlx_image_t* image);
/**
* Allows you to resize an image, a new pixel buffer is allocated
@@ -907,7 +889,7 @@ MLX_API void mlx_delete_image(mlx_t* mlx, mlx_image_t* image);
* @param[in] nheight The new height.
* @return True if image was resized or false on error.
*/
MLX_API bool mlx_resize_image(mlx_image_t* img, uint32_t nwidth, uint32_t nheight);
bool mlx_resize_image(mlx_image_t* img, uint32_t nwidth, uint32_t nheight);
/**
* Sets the depth / Z axis value of an instance.
@@ -919,7 +901,7 @@ MLX_API bool mlx_resize_image(mlx_image_t* img, uint32_t nwidth, uint32_t nheigh
* @param[in] instance The instance on which to change the depth.
* @param[in] zdepth The new depth value.
*/
MLX_API void mlx_set_instance_depth(mlx_instance_t* instance, int32_t zdepth);
void mlx_set_instance_depth(mlx_instance_t* instance, int32_t zdepth);
//= String Functions =//
@@ -932,14 +914,14 @@ MLX_API void mlx_set_instance_depth(mlx_instance_t* instance, int32_t zdepth);
* @param[in] y The Y location.
* @return Image ptr to the string.
*/
MLX_API mlx_image_t* mlx_put_string(mlx_t* mlx, const char* str, int32_t x, int32_t y);
mlx_image_t* mlx_put_string(mlx_t* mlx, const char* str, int32_t x, int32_t y);
/**
* Retrieve the texture data for the built-in font.
*
* @return Pointer to the built-in font texture.
*/
MLX_API const mlx_texture_t* mlx_get_font(void);
const mlx_texture_t* mlx_get_font(void);
/**
* This function lets you retrieve the X offset
@@ -950,7 +932,7 @@ MLX_API const mlx_texture_t* mlx_get_font(void);
* @param[in] c The character to get the offset from.
* @return Non-negative if found or -1 if not found.
*/
MLX_API int32_t mlx_get_texoffset(char c);
int32_t mlx_get_texoffset(char c);
# ifdef __cplusplus
}

0
lib/mlx/include/MLX42/MLX42_Int.h Executable file → Normal file
View File

0
lib/mlx/include/glad/glad.h Executable file → Normal file
View File

0
lib/mlx/include/lodepng/lodepng.h Executable file → Normal file
View File