-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfdf.h
144 lines (128 loc) · 5.82 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
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* fdf.h :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: masoares <masoares@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/07 15:30:35 by masoares #+# #+# */
/* Updated: 2023/12/07 15:35:09 by masoares ### ########.fr */
/* */
/* ************************************************************************** */
#ifndef FDF_H
# define FDF_H
# define WIN_L 1920
# define WIN_H 1080
# include "./minilibx-linux/mlx.h"
# include <X11/X.h>
# include <X11/keysym.h>
# include <unistd.h>
# include <stdlib.h>
# include <math.h>
# include <fcntl.h>
# include "./libft/libft.h"
typedef struct s_point
{
int x;
int y;
float z;
unsigned int color;
float zz;
double u;
double v;
} t_point;
typedef struct s_data
{
void *mlx;
void *mlx_win;
void *img;
void *addr;
int bitspp;
int line_length;
int endian;
int color;
int map_l;
int map_w;
double ang_x;
double ang_y;
double ang_z;
double zoom;
int ctrl_p;
int shift_p;
int alt_p;
int prev_x;
int prev_y;
int mouse2;
int trans_u;
int trans_v;
int z_changer;
t_point ***map;
} t_data;
/* ************************************************************************** */
/* FDF_UTILS */
/* ************************************************************************** */
void pixel_put(t_data *data, int x, int y, int color);
int color_make(int i, int j);
int color_z_based(int z, int x);
/* ************************************************************************** */
/* FDF_RENDER */
/* ************************************************************************** */
int render(t_data *img, t_point **map);
void render_view(t_data *img, t_point **map);
void render_rect(t_data *img);
void render_rect2(t_data *img);
void render_rect3(t_data *img);
/* ************************************************************************** */
/* IMAGE_CREATOR */
/* ************************************************************************** */
int image_creator(t_data *img, t_point **map);
/* ************************************************************************** */
/* HANDLERS */
/* ************************************************************************** */
int handle_destroy(t_data *img);
int handle_input(int keysym, t_data *img);
int handle_input_2(int keysym, t_data *img);
int handle_release(int keysym, t_data *img);
int close_all(t_data *img);
/* ************************************************************************** */
/* CONTROLS */
/* ************************************************************************** */
int controls(int mousecode, int x, int y, t_data *img);
int control_zoom(int mousecode, int x, int y, t_data *img);
int control_angles(int x, int y, t_data *img);
int controls_release(int mousecode, int x, int y, t_data *img);
int control_views(int view, t_data *img);
/* ************************************************************************** */
/* CONTROLS_2 */
/* ************************************************************************** */
int control_trans(int key, t_data *img);
/* ************************************************************************** */
/* MAP_CONVERTER */
/* ************************************************************************** */
t_point **map_converter(char *filename, int *x, int *y);
int find_dimension(int *x, int *y, char *filename);
int create_array(int x, int y, char *filename, t_point ***map);
int add_to_map(t_point **map, int x, int y, char **splited);
void coordinate_converter(t_data *img, t_point **map);
/* ************************************************************************** */
/* FREEING */
/* ************************************************************************** */
int splited_free(char **splited);
int map_free(t_point **map, int x, int y);
/* ************************************************************************** */
/* ERROR_HANDLING */
/* ************************************************************************** */
int errors(int i);
/* ************************************************************************** */
/* MATHINGS */
/* ************************************************************************** */
int rot_calculator(t_data *img, t_point *map, double *u1, double *v1);
void mat_multiplier_x(t_data *img, double *v, float *z);
void mat_multiplier_y(t_data *img, double *u, float *z);
void mat_multiplier_z(t_data *img, double *u, double *v);
/* ************************************************************************** */
/* BRESENHAM */
/* ************************************************************************** */
int bresenham(t_point map, double u1, double v1, t_data *img);
int max_finder(double varu, double varv);
#endif