Añadiendo mlx
This commit is contained in:
34
lib/mlx/src/mlx_put_pixel.c
Normal file
34
lib/mlx/src/mlx_put_pixel.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* :::::::: */
|
||||
/* mlx_put_pixel.c :+: :+: */
|
||||
/* +:+ */
|
||||
/* By: W2Wizard <main@w2wizard.dev> +#+ */
|
||||
/* +#+ */
|
||||
/* Created: 2021/12/28 03:30:13 by W2Wizard #+# #+# */
|
||||
/* Updated: 2022/06/29 16:00:30 by lde-la-h ######## odam.nl */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "MLX42/MLX42_Int.h"
|
||||
|
||||
// BUG: Linux may experience a red hue instead due to endianness
|
||||
void mlx_draw_pixel(uint8_t* pixel, uint32_t color)
|
||||
{
|
||||
*(pixel++) = (uint8_t)(color >> 24);
|
||||
*(pixel++) = (uint8_t)(color >> 16);
|
||||
*(pixel++) = (uint8_t)(color >> 8);
|
||||
*(pixel++) = (uint8_t)(color & 0xFF);
|
||||
}
|
||||
|
||||
//= Public =//
|
||||
|
||||
void mlx_put_pixel(mlx_image_t* image, uint32_t x, uint32_t y, uint32_t color)
|
||||
{
|
||||
MLX_NONNULL(image);
|
||||
MLX_ASSERT(x < image->width, "Pixel is out of bounds");
|
||||
MLX_ASSERT(y < image->height, "Pixel is out of bounds");
|
||||
|
||||
uint8_t* pixelstart = &image->pixels[(y * image->width + x) * BPP];
|
||||
mlx_draw_pixel(pixelstart, color);
|
||||
}
|
||||
Reference in New Issue
Block a user