lignes fonctionnent un tout petit peu
This commit is contained in:
BIN
builds/fdf.o
BIN
builds/fdf.o
Binary file not shown.
@@ -6,6 +6,36 @@
|
||||
# include <unistd.h> // for sleep()
|
||||
# include <math.h> // for M_PI
|
||||
|
||||
typedef struct s_fdf
|
||||
{
|
||||
void *mlx_ptr;
|
||||
void *win_ptr;
|
||||
void *img_ptr;
|
||||
char *img_addr;
|
||||
int **map;
|
||||
int offset;
|
||||
int margin;
|
||||
int altitude;
|
||||
int win_size_x;
|
||||
int win_size_y;
|
||||
int img_size_x;
|
||||
int img_size_y;
|
||||
int map_size_x;
|
||||
int map_size_y;
|
||||
int map_width;
|
||||
int map_height;
|
||||
int rot_x;
|
||||
int rot_y;
|
||||
double rad_x;
|
||||
double rad_y;
|
||||
int mov_x;
|
||||
int mov_y;
|
||||
int max_z;
|
||||
int img_bpp;
|
||||
int img_sizel;
|
||||
int img_endian;
|
||||
} t_fdf;
|
||||
|
||||
# define ESCAPE 65307
|
||||
# define UP 65362
|
||||
# define DOWN 65364
|
||||
@@ -38,34 +68,4 @@
|
||||
# define Y 121
|
||||
# define Z 122
|
||||
|
||||
typedef struct s_fdf
|
||||
{
|
||||
void *mlx_ptr;
|
||||
void *win_ptr;
|
||||
void *img_ptr;
|
||||
char *img_addr;
|
||||
int **map;
|
||||
int offset;
|
||||
int margin;
|
||||
int altitude;
|
||||
int win_size_x;
|
||||
int win_size_y;
|
||||
int img_size_x;
|
||||
int img_size_y;
|
||||
int map_size_x;
|
||||
int map_size_y;
|
||||
int map_width;
|
||||
int map_height;
|
||||
int rot_x;
|
||||
int rot_y;
|
||||
double rad_x;
|
||||
double rad_y;
|
||||
int mov_x;
|
||||
int mov_y;
|
||||
int max_z;
|
||||
int img_bpp;
|
||||
int img_sizel;
|
||||
int img_endian;
|
||||
} t_fdf;
|
||||
|
||||
#endif
|
||||
|
||||
59
srcs/fdf.c
59
srcs/fdf.c
@@ -12,15 +12,66 @@ void rotation_state(t_fdf *fdf);
|
||||
int **parse_map(t_fdf *fdf);
|
||||
int *new_coordinates(t_fdf *fdf, int i, int j);
|
||||
|
||||
void draw_lines(t_fdf *fdf, int *start, int *end)
|
||||
{
|
||||
int dx;
|
||||
int dy;
|
||||
int dz;
|
||||
int i;
|
||||
int j;
|
||||
int slope_big;
|
||||
int slope_small;
|
||||
int pixel;
|
||||
int z;
|
||||
|
||||
if (end)
|
||||
{
|
||||
dx = end[0] - start[0];
|
||||
dy = end[1] - start[1];
|
||||
//dz = end[2] - start[2];
|
||||
i = 0;
|
||||
j = 0;
|
||||
while (i < dx && j < dy)
|
||||
{
|
||||
draw_color_pixel(fdf, start[0] + i, start[1] + j, start[2]);
|
||||
if (j < i * dy / dx)
|
||||
j++;
|
||||
else
|
||||
i++;
|
||||
}
|
||||
/*
|
||||
slope_big = ft_greater(ft_absolute(dx), ft_absolute(dy));
|
||||
slope_small = ft_smaller(ft_absolute(dx), ft_absolute(dy));
|
||||
i = 0;
|
||||
while (++i <= slope_big)
|
||||
{
|
||||
pixel = slope_small / slope_big * i * ft_sign(dx);
|
||||
z = start[3] + (dz / slope_big * i);
|
||||
draw_color_pixel(fdf, start[0] + i, start[1] + pixel, z);
|
||||
}
|
||||
*/
|
||||
}
|
||||
(void)dx;
|
||||
(void)dy;
|
||||
(void)dz;
|
||||
(void)slope_big;
|
||||
(void)slope_small;
|
||||
(void)i;
|
||||
(void)pixel;
|
||||
(void)z;
|
||||
}
|
||||
|
||||
// point[0], point[1], point[2] -> new x, new y, new z
|
||||
void draw_lines(t_fdf *fdf, int i, int j)
|
||||
void draw_point_n_lines(t_fdf *fdf, int i, int j)
|
||||
{
|
||||
int *point_start;
|
||||
int *point_end;
|
||||
|
||||
point_start = new_coordinates(fdf, i, j);
|
||||
point_end = new_coordinates(fdf, i, j);
|
||||
draw_color_pixel(fdf, point_start[0], point_start[1], point_start[2]);
|
||||
point_end = NULL;
|
||||
if (i + 1 < fdf->map_width)
|
||||
point_end = new_coordinates(fdf, i + 1, j);
|
||||
draw_lines(fdf, point_start, point_end);
|
||||
}
|
||||
|
||||
void draw_image(t_fdf *fdf)
|
||||
@@ -38,7 +89,7 @@ void draw_image(t_fdf *fdf)
|
||||
{
|
||||
i = -1;
|
||||
while (++i < fdf->map_width)
|
||||
draw_lines(fdf, i, j);
|
||||
draw_point_n_lines(fdf, i, j);
|
||||
}
|
||||
// put image on screen
|
||||
mlx_put_image_to_window(fdf->mlx_ptr, fdf->win_ptr, fdf->img_ptr, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user