-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutil.h
57 lines (47 loc) · 1.06 KB
/
util.h
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
#ifndef UTIL_H
#define UTIL_H
#include "render.h"
#include "types.h"
typedef struct {
cvec_vec3 *v;
cvec_vec4 *t;
cvec_vec2 *vt;
cvec_vec4 *tt; /* x,y,z idx and valid */
} model_t;
typedef struct {
float s;
vec3 r;
vec3 tr;
} transform_t;
typedef struct {
model_t *m;
transform_t tr;
uint32_t *tx;
vec2 tx_dim;
} instance_t;
/*
type 0: ambient
type 1: directional
type 2: point
p stores L for type 1 and coordinate for type2
*/
typedef struct {
int type;
vec4 p;
} light_t;
scene_t *construct_scene(instance_t *inst, int isize, transform_t cam,
light_t *l, int lsize);
model_t *generate_sphere(int divs, int color);
model_t *load_model(char *file);
void free_model(model_t *m);
uint32_t *load_texture(char *file, vec2 *dim);
cvec_vec4 *generate_fov90_planes();
void swap_vec2(vec2 *, vec2 *);
void swap_vec3(vec3 *, vec3 *);
void swap_vec4(vec4 *, vec4 *);
void swap_int(int *, int *);
vec3 compute_vector(vec3 A, vec3 B);
vec3 vector_cross(vec3 A, vec3 B);
float vector_dot(vec3 A, vec3 B);
float vector_len(vec3 A);
#endif