38 if (key_data.key == MLX_KEY_ESCAPE)
39 mlx_close_window((
mlx_t *) arg);
53 if (x < (map.
width - 1))
78 while ((d->
y < d->
map.
height) && (d->
y - init_y) < FDF_ROWS_PER_ITERATION)
81 while (x < d->map.width)
98 mlx_set_window_size(
mlx, size[0], size[1]);
99 mlx_set_window_pos(
mlx, 0, 0);
100 d.
img = mlx_new_image(
mlx, size[0], size[1]);
103 ft_printf(
"%>mlx_new_image() failed: %s\n", 2, mlx_strerror(mlx_errno));
106 if (mlx_image_to_window(
mlx, d.
img, 0, 0) == -1)
108 ft_printf(
"%>mlx_image_to_window() failed: %s\n",
109 2, mlx_strerror(mlx_errno));
110 mlx_delete_image(
mlx, d.
img);
117 mlx_delete_image(
mlx, d.
img);
119 ft_printf(
"%>MLX error with unknown source: %s\n",
120 2, mlx_strerror(mlx_errno));
138 mlx = mlx_init(1, 1, FDF_WINDOW_TITLE, 0);
141 ft_printf(
"%>mlx_init() failed:%s\n", 2, mlx_strerror(mlx_errno));
int ft_printf(const char *format,...)
Prints and formats a variable set of arguments.
static void keyhook(mlx_key_data_t key_data, void *arg)
Runs when a key is pressed to check whether the escape key was used, so the window can be closed.
int fdf(t_map map)
Initialize mlx, run map projection and scaling, execute mlx, and cleanup.
void draw_line(mlx_image_t *img, int x1, int y1, int *p2)
Multi-directional implementation of the Bresenham incremental error line drawing algorithm.
static int fdf_mlx(mlx_t *mlx, t_loop_data d, int *size)
Bulk of mlx functions used in fdf, to set up the key press and drawing hooks, set up the image,...
static void lines_from_point(mlx_image_t *img, t_map map, int x, int y)
Checks if adjacent points are available, and draws lines to them.
int project_map(t_map map, int *size)
Project map and attempt to automatically scale to viewport.
static void fdf_row(void *data)
Draw rows in between frames if the image isn't complete.
Data structure passed to the drawing loop.
int y
Starting row index for the drawing loop.
mlx_image_t * img
Pointer to mlx image on which to draw lines.
int width
Number of columns in the map.
int height
Number of rows in the map.
t_point ** point
2d array of points in [y][x] order
int projected[2]
Projected coordinates for this point.