From 0491089463f6b311fd2bf4b8708e4fafc5e71ba4 Mon Sep 17 00:00:00 2001 From: Daemo Date: Sun, 9 Aug 2026 02:55:24 +0200 Subject: [PATCH] Added deprecation for pixel_put functions (OFF BY DEFAULT) as well as warnings in their descriptions --- includes/mlx.h | 3 +++ includes/mlx_extended.h | 7 +++++++ includes/mlx_profile.h | 19 +++++++++++++++++++ 3 files changed, 29 insertions(+) diff --git a/includes/mlx.h b/includes/mlx.h index 25a1a1e..ce9d630 100644 --- a/includes/mlx.h +++ b/includes/mlx.h @@ -313,7 +313,10 @@ MLX_API void mlx_on_event(mlx_context mlx, mlx_window win, mlx_event_type event, * @param x X coordinate * @param y Y coordinate * @param color Color of the pixel + * + * WARNING: This function isn't performant, consider drawing to an image beforehand. */ +MLX_DEPRECATED("Use an image rather than directly communicating with the window") MLX_API void mlx_pixel_put(mlx_context mlx, mlx_window win, int x, int y, mlx_color color); diff --git a/includes/mlx_extended.h b/includes/mlx_extended.h index d668104..48cae93 100644 --- a/includes/mlx_extended.h +++ b/includes/mlx_extended.h @@ -85,7 +85,12 @@ MLX_API void mlx_restore_window(mlx_context mlx, mlx_window win); * @param y Y coordinate * @param pixels Array of pixels * @param pixels_number Number of pixels + * + * Note: it is responsability of the user to make sure the size of `pixels` is + * big enough for the given array. + * WARNING: This function isn't performant, consider drawing to an image beforehand. */ +MLX_DEPRECATED("Use an image rather than directly communicating with the window") MLX_API void mlx_pixel_put_array(mlx_context mlx, mlx_window win, int x, int y, mlx_color* pixels, size_t pixels_number); /** @@ -101,7 +106,9 @@ MLX_API void mlx_pixel_put_array(mlx_context mlx, mlx_window win, int x, int y, * * Note: it is responsability of the user to make sure the size of `pixels` is * big enough for the given region. + * WARNING: This function isn't performant, consider drawing to an image beforehand. */ +MLX_DEPRECATED("Use an image rather than directly communicating with the window") MLX_API void mlx_pixel_put_region(mlx_context mlx, mlx_window win, int x, int y, int w, int h, mlx_color* pixels); diff --git a/includes/mlx_profile.h b/includes/mlx_profile.h index a98d5ec..5ac5a5d 100644 --- a/includes/mlx_profile.h +++ b/includes/mlx_profile.h @@ -83,6 +83,25 @@ #define MLX_API #endif +#define MLX_NO_DEPRECATE +#ifdef MLX_NO_DEPRECATE + #define MLX_DEPRECATED(msg) +#elif defined(__has_c_attribute) + #if __has_c_attribute(deprecated) + #define MLX_DEPRECATED(msg) [[deprecated(msg)]] + #endif +#endif + +#ifndef MLX_DEPRECATED + #if defined(__GNUC__) || defined(__clang__) + #define MLX_DEPRECATED(msg) __attribute__((deprecated(msg))) + #elif defined(_MSC_VER) + #define MLX_DEPRECATED(msg) __declspec(deprecated(msg)) + #else + #define MLX_DEPRECATED(msg) + #endif +#endif + #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__) #define MLX_FUNC_SIG __PRETTY_FUNCTION__ #elif defined(__DMC__) && (__DMC__ >= 0x810)