define short-hand types for int32/uint32 et cetera

This commit is contained in:
2025-06-20 19:54:34 +02:00
parent ad66d9465a
commit 80b8b65b73
10 changed files with 103 additions and 82 deletions

View File

@@ -3,18 +3,20 @@
#pragma once
#include <stdint.h>
#include "types.h"
// stores colour in a rgba format stored as little-endian, each channel being a 8 bits wide.
typedef union colour32 {
uint32_t dat; // full colour data; little-endian
u32 dat; // full colour data; little-endian
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
// colour channel information for little-endian systems
struct {
uint8_t a, b, g, r;
u8 a, b, g, r;
} ch;
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
// colour channel information for big-endian systems
struct {
uint8_t r, g, b, a;
u8 r, g, b, a;
} ch;
#endif
} colour32;