Shipwright/libultraship/libultraship/color.h

51 lines
702 B
C
Raw Normal View History

#ifndef COLOR_H
#define COLOR_H
2022-07-31 14:50:28 -04:00
#include <stdint.h>
2022-07-27 17:50:56 -04:00
#include "endianness.h"
2022-07-31 14:50:28 -04:00
#ifdef __cplusplus
extern "C"
{
#endif
typedef struct {
2022-07-25 23:11:45 -04:00
uint8_t r, g, b;
} Color_RGB8;
typedef struct {
2022-07-25 23:11:45 -04:00
uint8_t r, g, b, a;
} Color_RGBA8;
// only use when necessary for alignment purposes
typedef union {
struct {
2022-07-27 17:50:56 -04:00
#ifdef IS_BIGENDIAN
2022-07-31 14:50:28 -04:00
uint8_t r, g, b, a;
2022-07-27 17:50:56 -04:00
#else
2022-07-31 14:50:28 -04:00
uint8_t a, b, g, r;
2022-07-27 17:50:56 -04:00
#endif
};
2022-07-25 23:11:45 -04:00
uint32_t rgba;
} Color_RGBA8_u32;
typedef struct {
2022-07-25 23:11:45 -04:00
float r, g, b, a;
} Color_RGBAf;
typedef union {
struct {
2022-07-25 23:11:45 -04:00
uint16_t r : 5;
uint16_t g : 5;
uint16_t b : 5;
uint16_t a : 1;
};
2022-07-25 23:11:45 -04:00
uint16_t rgba;
} Color_RGBA16;
2022-05-31 00:59:35 -04:00
#ifdef __cplusplus
};
#endif
#endif