You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.3 KiB
79 lines
2.3 KiB
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* fdf_utils.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: narnaud <narnaud@student.42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2022/02/19 12:07:55 by narnaud #+# #+# */
|
|
/* Updated: 2022/02/24 13:49:50 by narnaud ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "fdf.h"
|
|
|
|
char *get_info(char *ret, const char *name, int value)
|
|
{
|
|
int len;
|
|
|
|
len = ft_strlen(name);
|
|
ft_memcpy(ret, name, len);
|
|
ft_memcpy(ret + len, ft_itoa(value), 4);
|
|
ft_memcpy(ret + len + 4, "\0", 1);
|
|
return (ret);
|
|
}
|
|
|
|
void draw_infos(t_datas *datas)
|
|
{
|
|
char *str;
|
|
|
|
str = ft_calloc(255, sizeof(char));
|
|
mlx_string_put(datas->mlx, datas->win, 10, 10, 255 * 255 * 255, \
|
|
get_info(str, "Zoom: ", (int)datas->cam->zoom));
|
|
mlx_string_put(datas->mlx, datas->win, 10, 20, 255 * 255 * 255, \
|
|
get_info(str, "Z_multiplier: ", (int)datas->map->z_mult));
|
|
mlx_string_put(datas->mlx, datas->win, 10, 30, 255 * 255 * 255, \
|
|
get_info(str, "Yaw: ", (int)(datas->cam->ang.yaw.raw * 57.3)));
|
|
mlx_string_put(datas->mlx, datas->win, 10, 40, 255 * 255 * 255, \
|
|
get_info(str, "Pitch: ", (int)(datas->cam->ang.pitch.raw * 57.3)));
|
|
free(str);
|
|
}
|
|
|
|
int error_msg(char *msg, int sys)
|
|
{
|
|
if (sys)
|
|
perror(msg);
|
|
else
|
|
ft_putstr_fd(msg, 2);
|
|
return (1);
|
|
}
|
|
|
|
t_trigo trigo_calc(float rad)
|
|
{
|
|
t_trigo ret;
|
|
|
|
ret.raw = rad;
|
|
ret.cos = cos(rad);
|
|
ret.sin = sin(rad);
|
|
return (ret);
|
|
}
|
|
|
|
void clean_exit(t_datas *datas)
|
|
{
|
|
static int y = 0;
|
|
|
|
while (y < datas->map->depth)
|
|
{
|
|
free(datas->cam->render[y]);
|
|
free(datas->map->altitude[y]);
|
|
y++;
|
|
}
|
|
free(datas->map->altitude);
|
|
free(datas->cam->render);
|
|
free(datas->map);
|
|
free(datas->cam);
|
|
mlx_destroy_window(datas->mlx, datas->win);
|
|
free(datas->mlx);
|
|
free(datas);
|
|
exit(0);
|
|
}
|
|
|