implementing endianness check on mlx_color struct

This commit is contained in:
Kbz-8
2024-12-17 00:19:13 +01:00
parent 42e62ac3eb
commit 213a8f6a6d
2 changed files with 17 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
/* By: maldavid <contact@kbz8.me> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/10/04 16:56:35 by maldavid #+# #+# */
/* Updated: 2024/12/16 23:11:59 by maldavid ### ########.fr */
/* Updated: 2024/12/17 00:15:34 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -48,10 +48,17 @@ typedef union mlx_color
{
struct
{
uint8_t a;
uint8_t b;
uint8_t g;
uint8_t r;
#if MLX_ENDIAN_ORDER == MLX_LITTLE_ENDIAN
uint8_t a;
uint8_t b;
uint8_t g;
uint8_t r;
#else
uint8_t r;
uint8_t g;
uint8_t b;
uint8_t a;
#endif
};
uint32_t rgba;
} mlx_color;

View File

@@ -6,7 +6,7 @@
/* By: maldavid <kbz_8.dev@akel-engine.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/10 08:49:17 by maldavid #+# #+# */
/* Updated: 2024/12/16 16:16:07 by maldavid ### ########.fr */
/* Updated: 2024/12/17 00:14:47 by maldavid ### ########.fr */
/* */
/* ************************************************************************** */
@@ -142,6 +142,10 @@
#endif
#endif
#define MLX_LITTLE_ENDIAN 0x41424344UL
#define MLX_BIG_ENDIAN 0x44434241UL
#define MLX_ENDIAN_ORDER ('ABCD')
#include <stdint.h>
#define MLX_MAKE_VERSION(major, minor, patch) ((((uint32_t)(major)) << 22U) | (((uint32_t)(minor)) << 12U) | ((uint32_t)(patch)))