-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfdf.h
More file actions
executable file
·122 lines (107 loc) · 2.58 KB
/
Copy pathfdf.h
File metadata and controls
executable file
·122 lines (107 loc) · 2.58 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: awoimbee <awoimbee@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/11/20 15:26:34 by awoimbee #+# #+# */
/* Updated: 2019/06/18 23:29:55 by awoimbee ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FDF_H
# define FDF_H
# include "mlx.h"
# include "libft/libft.h"
# include <stdlib.h>
# include <fcntl.h>
# include <unistd.h>
# include <math.h>
# ifdef __APPLE__
# define K_UP 126
# define K_DWN 125
# define K_LFT 123
# define K_RGT 124
# define K_Q 12
# define K_E 14
# define K_W 13
# define K_S 1
# define K_A 0
# define K_D 2
# define K_ESC 53
# elif __linux__
# define K_UP 65362
# define K_DWN 65364
# define K_LFT 65361
# define K_RGT 65363
# define K_Q 113
# define K_E 101
# define K_W 119
# define K_S 115
# define K_A 97
# define K_D 100
# define K_ESC 65307
# endif
# define PX_END_OF_LINE ((uint16_t)-1)
# define PX_OUTSIDE ((uint16_t)-2)
typedef unsigned char t_uchar;
typedef struct s_img
{
void *ptr;
int *data;
int line_s;
int bpp;
int endian;
} t_img;
typedef struct s_mlx
{
void *ptr;
void *win;
t_img img;
} t_mlx;
typedef struct s_vertex
{
float x;
float y;
float z;
} t_vertex;
typedef struct s_vertices
{
uint16_t x;
uint16_t y;
int color;
} t_vertices;
typedef struct s_map
{
int **heightmap;
t_vertices size;
float delta;
float median;
int min;
int max;
} t_map;
/*
** fov doesn't really contains the fov but tan(fov / 2)
*/
typedef struct s_data
{
t_mlx mlx;
t_map map;
t_vertices **zbuff;
t_vec4 rot_mat[4] __attribute__((aligned(16)));
t_vertex rot;
float mv;
float zoom;
int rgb;
float zh;
int win_height;
int win_width;
float fov;
} t_data;
void draw_all_lines(t_vertices **buffer,
int h, int win_w, int *imgdata);
t_map *read_map(t_map *map, char *filename);
void render(t_mlx *mlx, t_map *map, t_data *data);
void chaos(void *fate);
void ft_exit(t_data *data);
#endif