-
Notifications
You must be signed in to change notification settings - Fork 0
/
fdf.h
97 lines (82 loc) · 2.4 KB
/
fdf.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
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
97
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: juhan <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/15 15:47:16 by juhan #+# #+# */
/* Updated: 2022/04/15 17:33:12 by juhan ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FDF_H
# define FDF_H
# include "get_next_line.h"
# include "libft/libft.h"
# include <fcntl.h>
# include <math.h>
# include "minilibx/mlx.h"
# define BUFFER_SIZE 30
# define WIN_WIDTH 800
# define WIN_HEIGHT 800
# define KEY_ESC 53
# define KEY_UP 13
# define KEY_LEFT 0
# define KEY_DOWN 1
# define KEY_RIGHT 2
# define KEY_ROTATE_X_POS 125
# define KEY_ROTATE_X_NEG 126
# define KEY_ROTATE_Y_POS 124
# define KEY_ROTATE_Y_NEG 123
# define KEY_ROTATE_Z_POS 14
# define KEY_ROTATE_Z_NEG 12
# define KEY_PROJECTION 15
# define KEY_ZOOM_POS 27
# define KEY_ZOOM_NEG 24
# define KEY_ZVAL_POS 43
# define KEY_ZVAL_NEG 47
typedef struct s_coord
{
int x;
int y;
int z;
} t_coord;
typedef struct s_map
{
int is_iso;
int height;
int width;
t_coord *map;
int tile_length;
int z_val;
int camera_x_offset;
int camera_y_offset;
int translate_x;
int translate_y;
double angle_x;
double angle_y;
double angle_z;
double zoom;
void *mlx;
void *win;
void *img;
void *addr;
int bpp;
int line_length;
int endian;
} t_map;
void init_map(t_map *m);
void set_coord(t_map *m);
void handle_error(t_map *m);
int handle_key(int key, t_map *m);
int render_frame(t_map *m);
void set_projection(t_map *m);
t_coord project(t_map *m, t_coord coord);
void draw_line(t_map *m, t_coord a, t_coord b, int color);
void draw(t_map *m);
void rotate_x(int *y, int *z, double angle);
void rotate_y(int *x, int *z, double angle);
void rotate_z(int *x, int *y, double angle);
int handle_exit(t_map *m);
void close_fd_on_error(int fd);
#endif