summaryrefslogtreecommitdiff
path: root/prb_types.h
blob: 8760513fd70147a4d19dd28f3710ccecc88c7d98 (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
85
86
87
88
89
90
91
92
93
94
95
96
#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 only use right-handed coordiante system (for now) */

#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;
	F32	y;
} V2;

#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;
	F32	y;
	F32	z;
} V3;

#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 {
	F32	x;
	F32	y;
	F32	z;
	F32	w;
} V4;

#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 {
	V4	m0;
	V4	m1;
	V4	m2;
	V4	m3;
} MAT4;

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

/* NOTE(pryazha): Fixed-length string */
typedef struct  {
	U8	*p;
	U64	len;
} FLS;

typedef struct FLSNode {
	FLS		str;
	struct FLSNode	*next;
	struct FLSNode	*prev;
} FLSNode;

typedef struct {
	struct FLSNode	*first;
	struct FLSNode	*last;
	U64		len;
	U32		ncnt;
} FLSList;

#endif /* PRB_TYPES_H */