forked from fogleman/Craft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.h
59 lines (49 loc) · 1.85 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
58
59
#ifndef _util_h_
#define _util_h_
#ifndef __APPLE_CC__
#include <GL/glew.h>
#endif
#include <GLFW/glfw3.h>
#define PI 3.14159265359
#define DEGREES(radians) ((radians) * 180 / PI)
#define RADIANS(degrees) ((degrees) * PI / 180)
#define ABS(x) ((x) < 0 ? (-(x)) : (x))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
typedef struct {
unsigned int frames;
double since;
} FPS;
int rand_int(int n);
double rand_double();
void update_fps(FPS *fps, int show);
GLuint make_buffer(GLenum target, GLsizei size, const void *data);
GLuint make_shader(GLenum type, const char *source);
GLuint load_shader(GLenum type, const char *path);
GLuint make_program(GLuint shader1, GLuint shader2);
GLuint load_program(const char *path1, const char *path2);
void normalize(float *x, float *y, float *z);
void mat_identity(float *matrix);
void mat_translate(float *matrix, float dx, float dy, float dz);
void mat_rotate(float *matrix, float x, float y, float z, float angle);
void mat_vec_multiply(float *vector, float *a, float *b);
void mat_multiply(float *matrix, float *a, float *b);
void mat_frustum(
float *matrix, float left, float right, float bottom,
float top, float znear, float zfar);
void mat_perspective(
float *matrix, float fov, float aspect,
float near, float far);
void mat_ortho(
float *matrix,
float left, float right, float bottom, float top, float near, float far);
void make_plant(
float *vertex, float *normal, float *texture,
float x, float y, float z, float n, int w, float rotation);
void make_cube(
float *vertex, float *normal, float *texture,
int left, int right, int top, int bottom, int front, int back,
float x, float y, float z, float n, int w);
void make_cube_wireframe(float *vertex, float x, float y, float z, float n);
void load_png_texture(const char *file_name);
#endif