2024-10-07 07:44:18 +00:00
|
|
|
#ifndef TWN_TYPES_H
|
|
|
|
#define TWN_TYPES_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
/* plain data aggregates that are accepted between public procedure boundaries */
|
|
|
|
|
|
|
|
/* 32-bit color data */
|
|
|
|
typedef struct Color {
|
|
|
|
_Alignas(4)
|
|
|
|
uint8_t r;
|
|
|
|
uint8_t g;
|
|
|
|
uint8_t b;
|
|
|
|
uint8_t a;
|
|
|
|
} Color;
|
|
|
|
|
|
|
|
|
|
|
|
/* a rectangle with the origin at the upper left (integer) */
|
|
|
|
typedef struct Recti {
|
|
|
|
_Alignas(16)
|
|
|
|
int32_t x;
|
|
|
|
int32_t y;
|
|
|
|
int32_t w;
|
|
|
|
int32_t h;
|
|
|
|
} Recti;
|
|
|
|
|
|
|
|
|
|
|
|
/* a rectangle with the origin at the upper left (floating point) */
|
|
|
|
typedef struct Rect {
|
|
|
|
_Alignas(16)
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float w;
|
|
|
|
float h;
|
|
|
|
} Rect;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct Matrix4 {
|
|
|
|
Vec4 row[4];
|
|
|
|
} Matrix4;
|
|
|
|
|
2024-10-07 12:55:53 +00:00
|
|
|
|
|
|
|
/* a point in some space (integer) */
|
|
|
|
typedef struct Vec2i {
|
|
|
|
_Alignas(8)
|
|
|
|
int32_t x;
|
|
|
|
int32_t y;
|
|
|
|
} Vec2i;
|
|
|
|
|
|
|
|
|
|
|
|
/* a point in some space (floating point) */
|
|
|
|
typedef struct Vec2 {
|
|
|
|
_Alignas(8)
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
} Vec2;
|
|
|
|
|
|
|
|
|
|
|
|
/* a point in some three dimension space (floating point) */
|
|
|
|
/* y goes up, x goes to the right */
|
|
|
|
typedef struct Vec3 {
|
|
|
|
_Alignas(16)
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
} Vec3;
|
|
|
|
|
|
|
|
|
|
|
|
/* a point in some three dimension space (floating point) */
|
|
|
|
/* y goes up, x goes to the right */
|
|
|
|
typedef struct Vec4 {
|
|
|
|
_Alignas(16)
|
|
|
|
float x;
|
|
|
|
float y;
|
|
|
|
float z;
|
|
|
|
float w;
|
|
|
|
} Vec4;
|
|
|
|
|
|
|
|
|
2024-10-07 07:44:18 +00:00
|
|
|
#endif
|