summaryrefslogtreecommitdiff
path: root/prb_types.h
blob: a1ac3bae2a23c7d5327db3db5ab21c3255cd39f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef PRB_TYPES_H
#define PRB_TYPES_H

typedef int8_t S8;
typedef int16_t S16;
typedef int32_t S32;
typedef int64_t S64;
typedef uint8_t U8;
typedef uint16_t U16;
typedef uint32_t U32;
typedef uint64_t U64;
typedef S32 B32;
typedef float F32;
typedef double F64;

/* NOTE(pryazha): The library uses a right-handed coordiante system (for now) */

typedef struct {
	F32 x, y;
} V2;

#define V2_ZERO  (V2){ 0.0f,  0.0f }
#define V2_ONE   (V2){ 1.0f,  1.0f }
#define V2_RIGHT (V2){ 1.0f,  0.0f }
#define V2_UP    (V2){ 0.0f,  1.0f }
#define V2_LEFT  (V2){-1.0f,  0.0f }
#define V2_DOWN  (V2){ 0.0f, -1.0f }

typedef struct {
	F32 x, y, z;
} V3;

#define V3_ZERO     (V3){ 0.0f,  0.0f,  0.0f }
#define V3_ONE      (V3){ 1.0f,  1.0f,  1.0f }
#define V3_RIGHT    (V3){ 1.0f,  0.0f,  0.0f }
#define V3_UP       (V3){ 0.0f,  1.0f,  0.0f }
#define V3_LEFT     (V3){-1.0f,  0.0f,  0.0f }
#define V3_DOWN     (V3){ 0.0f, -1.0f,  0.0f }
#define V3_FORWARD  (V3){ 0.0f,  0.0f,  1.0f }
#define V3_BACKWARD (V3){ 0.0f,  0.0f, -1.0f }

typedef struct {
	F32 x, y, z, w;
} V4;

#define V4_ZERO (V4){ 0.0f, 0.0f, 0.0f, 0.0f }
#define V4_ONE (V4){ 1.0f, 1.0f, 1.0f, 1.0f }

typedef struct {
	V4 m0, m1, m2, m3;
} Mat4;

#define MAT4_IDENTITY (Mat4) { \
	{ 1.0f, 0.0f, 0.0f, 0.0f }, \
	{ 0.0f, 1.0f, 0.0f, 0.0f }, \
	{ 0.0f, 0.0f, 1.0f, 0.0f }, \
	{ 0.0f, 0.0f, 0.0f, 1.0f } }

typedef struct {
	U8 *mem;
	U64 cap;
	U64 used;
} Arena;

/* NOTE(pryazha): Strings */
typedef struct  {
	U8 *ptr;
	U64 length;
} Str8;

typedef struct Str8Node {
	Str8 str;
	struct Str8Node *next;
	struct Str8Node *prev;
} Str8Node;

typedef struct {
	Str8Node *first;
	Str8Node *last;
	U64 total_length;
	U32 node_count;
} Str8List;

#endif /* PRB_TYPES_H */