Added deprecation for pixel_put functions (OFF BY DEFAULT) as well as warnings in their descriptions

This commit is contained in:
Daemo
2026-08-09 02:56:36 +02:00
parent 83b9f8f9da
commit 0491089463
3 changed files with 29 additions and 0 deletions
+3
View File
@@ -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 x X coordinate
* @param y Y coordinate * @param y Y coordinate
* @param color Color of the pixel * @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); MLX_API void mlx_pixel_put(mlx_context mlx, mlx_window win, int x, int y, mlx_color color);
+7
View File
@@ -85,7 +85,12 @@ MLX_API void mlx_restore_window(mlx_context mlx, mlx_window win);
* @param y Y coordinate * @param y Y coordinate
* @param pixels Array of pixels * @param pixels Array of pixels
* @param pixels_number Number 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); 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 * Note: it is responsability of the user to make sure the size of `pixels` is
* big enough for the given region. * 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); MLX_API void mlx_pixel_put_region(mlx_context mlx, mlx_window win, int x, int y, int w, int h, mlx_color* pixels);
+19
View File
@@ -83,6 +83,25 @@
#define MLX_API #define MLX_API
#endif #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__) #if defined(__GNUC__) || (defined(__MWERKS__) && (__MWERKS__ >= 0x3000)) || (defined(__ICC) && (__ICC >= 600)) || defined(__ghs__)
#define MLX_FUNC_SIG __PRETTY_FUNCTION__ #define MLX_FUNC_SIG __PRETTY_FUNCTION__
#elif defined(__DMC__) && (__DMC__ >= 0x810) #elif defined(__DMC__) && (__DMC__ >= 0x810)