Exemple #1
0
Fichier : main.c Projet : Daykz/FdF
int			main(int ac, char **av)
{
	t_coor	coor;

	if (ac == 1)
		ft_putstr("No file\n");
	else if (ac == 2)
	{
		if ((coor.fd = open(av[1], O_RDONLY)) == -1)
		{
			ft_putstr("Can't read the map.");
			return (0);
		}
		count_line(&coor);
		coor.fd = open(av[1], O_RDONLY);
		init(&coor);
		stock_fd(&coor);
		close(coor.fd);
		coor.mlx = mlx_init();
		coor.win = mlx_new_window(coor.mlx, 1200, 1200, "FdF");
		mlx_expose_hook(coor.win, expose_hook, &coor);
		mlx_key_hook(coor.win, key_hook, &coor);
		mlx_loop(coor.mlx);
	}
	return (0);
}
Exemple #2
0
t_ptr		*my_init(void)
{
  t_ptr		*ptr;

  if ((ptr = malloc(sizeof(t_ptr))) == NULL)
    return (NULL);
  if ((ptr->mlx = mlx_init()) == NULL)
    {
      free(ptr);
      return (NULL);
    }
  if ((ptr->win = my_init_window(W_NAME, ptr->mlx, W_SIZE_X,
				 W_SIZE_Y)) == NULL)
    {
      free(ptr->mlx);
      free(ptr);
      return (NULL);
    }
  if ((ptr->pic = my_init_picture(ptr->mlx, W_SIZE_X, W_SIZE_Y)) == NULL)
    {
      my_free_win(ptr->win, ptr->mlx);
      free(ptr->mlx);
      free(ptr);
      return (NULL);
    }
  return (ptr);
}
Exemple #3
0
t_env				*init_env(char *filename)
{
	t_env		*e;

	if ((e = (t_env *)malloc(sizeof(t_env))) == NULL)
		error(1, 0, "Malloc struct environment!");
	e->persp = init_persp();
	if (filename != NULL)
		e->filename = ft_strdup(filename);
	else
		e->filename = NULL;
	e->map = init_map(e, filename);
	check_gates(e->map);
	e->width = (int)512 * 2.2;
	e->height = (int)512 * 1.7;
	e->mlx = mlx_init();
	e->view = init_img(e, e->width, e->height);
	e->mmap = init_img(e, e->map->column * 4, e->map->line * 4);
	e->wall = init_texture(e, "greystone.xpm");
	e->door = init_texture(e, "greystone_door.xpm");
	e->sky = init_texture(e, "sky2.xpm");
	e->win = mlx_new_window(e->mlx, e->width, e->height, "Wolf3D");
	e->key.strafe = 0;
	e->init = 0;
	e->key.run = 0;
	e->key.turn = 0;
	return (e);
}
Exemple #4
0
int	main(int argc, char **argv)
{
	t_mlxenv	*e;
	t_mlxp		*list;
	t_data		*data;
	char		*data_mlx;

	if (argc != 2)
		ft_error(ARG_ERROR);
	if ((e = malloc(sizeof(t_mlxenv))) == NULL)
		ft_error(ALLOC_ERROR);
	if ((data = malloc(sizeof(t_data))) == NULL)
		ft_error(ALLOC_ERROR);
	list = NULL;
	ft_parsing(&list, argv, data);
	ft_proj_iso_list(&list, data);
	if ((e->mlx = mlx_init()) == NULL)
		ft_error(END_PROG);
	e->img = mlx_new_image(e->mlx, 1650, 1000);
	data_mlx = mlx_get_data_addr(e->img, &(data->bpp),
								&(data->sizelin), &(data->endian));
	ft_display_map(&list, data, data_mlx);
	e->win = mlx_new_window(e->mlx, 1650, 1000, "FdF");
	mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
	ft_hook(e, &list);
	return (0);
}
Exemple #5
0
int		main(void)
{
	t_glob		*gl;
	t_bitmap	*bmp;

	gl = (t_glob *)malloc(sizeof(t_glob));
	if (!gl)
		return (0);
	bmp = (t_bitmap *)malloc(sizeof(t_bitmap));
	if (!bmp)
		return (0);
	ft_init(gl);
	texture_grey(gl, bmp);
	texture_wood(gl, bmp);
	texture_me(gl, bmp);
	ft_skybox(gl, bmp);
	gl->mlx = mlx_init();
	gl->win = mlx_new_window(gl->mlx, gl->s_x, gl->s_y, "Wolf 3D");
	ft_wolf3d(gl);
	mlx_loop_hook(gl->mlx, ft_wolf3d, gl);
	mlx_hook(gl->win, 2, (1L << 0), ft_key_press, gl);
	mlx_hook(gl->win, 3, (1L << 1), ft_key_release, gl);
	mlx_hook(gl->win, 17, 0, ft_close, gl);
	mlx_loop(gl->mlx);
	return (0);
}
Exemple #6
0
void		ft_mandelbrot(void)
{
	t_env	*e;
	int		bpp;
	int		ls;
	int		endian;

	e = (t_env *)malloc(sizeof(t_env));
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, SIZE_W, SIZE_W, "fractal de Mandelbrot");
	bpp = 4;
	ls = 4 * SIZE_W;
	endian = 0;
	e->xmin = -2;
	e->xmax = 2;
	e->ymin = -2;
	e->ymax = 2;
	e->data = NULL;
	e->img = mlx_new_image(e->mlx, SIZE_W, SIZE_W);
	e->data = mlx_get_data_addr(e->img, &bpp, &ls, &endian);
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_mouse_hook(e->win, mouse_hook, e);
	mlx_key_hook(e->win, key_hook, e);
	mlx_loop(e->mlx);
}
Exemple #7
0
void	init_mlx(t_data *d, int n)
{
	d->cur_frac = n <= NB_FRACTAL - 1 ? n : 0;
	d->cur_pal = 0;
	d->mlx = mlx_init();
	d->win = mlx_new_window(d->mlx, X_WIN, Y_WIN, "Fract'ol");
}
Exemple #8
0
int			main(int argc, char **argv)
{
	t_env	e;
	int		i_x;
	int		i_y;

	i_x = WIN_X * 2 / 5;
	i_y = WIN_Y * 2 / 5;
	if (argc == 2)
	{
		ft_parse(&e, argv[1]);
		ft_drawsettings(&e);
		e.mlx = mlx_init();
		e.win = mlx_new_window(e.mlx, WIN_X, WIN_Y, "mlx42");
		e.im = mlx_new_image(e.mlx, WIN_X, WIN_Y);
		e.imc = mlx_get_data_addr(e.im, &e.bpp, &e.imlen, &e.endi);
		mlx_string_put(e.mlx, e.win, i_x, i_y, 0xccccff, WELCOME);
		mlx_string_put(e.mlx, e.win, i_x + 16, i_y + 20, 0xccccff, START);
		mlx_hook(e.win, KEYPRESS, KEYPRESSMASK, ft_key_settings, &e);
		mlx_loop(e.mlx);
	}
	else
		ft_error("error : invalid number of arguments");
	return (0);
}
Exemple #9
0
int	main(int argc, char *argv[])
{
	int		fd;
	int		i;
	void	*mlx;

	if (argc >= 2)
	{
		mlx = mlx_init();
		i = 0;
		while (++i < argc)
		{
			if ((fd = open(argv[i], O_RDONLY)) == -1)
				perror(argv[i]);
			else
				make_env(mlx, argv[i], fd);
			close(fd);
		}
		check_env_number();
		printf("start loop\n");
		mlx_loop(mlx);
	}
	else
	{
		ft_putstr("usage: rt_v1 [files...]\n");
		return (-1);
	}
	return (0);
}
Exemple #10
0
int main ()
{
	int x;
	int y;
	void *mlx;
	void *win;// va receuillir l'identifiant de la fenetre ! on peux ouvrir plusieur fenetre grace a sa et travailler sur la fenetre desire

	y = 0;
	x = 0;
	mlx = mlx_init();
	win = mlx_new_window(mlx, 400, 400, "MLX 42");
	while (y < 150)
	{
		x = 50;
		while (x < 150)
		{
			mlx_pixel_put(mlx, win, x,y, 0x00FFFFFF);			
			x++;
		}
		y++;
	}
//	mlx_pixel_put(mlx, win, 200, 200, 0x00FFFFFF);

	mlx_key_hook(win, my_key_funct, 0);
	mlx_loop(mlx); // sans mlx loop aps de fgestion d'evenement
	
		return(0);
}
Exemple #11
0
t_env	*new_env()
{
	t_env	*env;

	env = (t_env *)malloc(sizeof(t_env));
	if (env)
	{
		env->mlx = mlx_init();
		env->win = mlx_new_window(env->mlx, MAP_HEIGHT * 30, MAP_WIDTH * 30, "wolf3d");
		env->player = new_player();
		env->time = 0;
		env->oldtime = 0;
		env->step = new_int2Dvect(0,0);
		if (! (env->step && env->player))
		{
			//free(player);
			free(env);
			return (NULL);
		}
		env->hit = 0;
		env->side = 0;
		env->draw_start = 0;
		env->draw_end = 0;
	}
	return (env);
}
Exemple #12
0
void	ft_open_window(t_pos *wolf)
{
	if (!(wolf->head->mlx))
	{
		wolf->head->mlx = mlx_init();
		if (init_img(wolf) == -1)
			ft_error(10);
		ft_init_val(wolf, 0);
		ft_init_val2(wolf, 0);
		ft_init_pos(wolf);
	}
	else
	{
		ft_init_val2(wolf, 1);
		ft_init_val(wolf, 2);
	}
	ft_raycasting(wolf);
	if (!(wolf->head->win))
		wolf->head->win = mlx_new_window(wolf->head->mlx, SCREEN_X
			+ 1, SCREEN_Y + 1, "Wolf3D");
	mlx_put_image_to_window(wolf->head->mlx,
		wolf->head->win, wolf->head->img, 0, 0);
	mlx_key_hook(wolf->head->win, ft_stop, wolf);
	mlx_hook(wolf->head->win, 2, (1L << 0), move, wolf);
	mlx_loop(wolf->head->mlx);
}
Exemple #13
0
void	init(t_env *e)
{
	e->l = 0;
	e->o.pos.x = 0;
	e->o.pos.y = 0;
	e->o.pos.z = 0;
	e->o.dir.x = 0;
	e->o.dir.y = 0;
	e->o.dir.z = 1;
	superparsator(e);
	e->o = initcam(e->o);
	if (e->l == 0)
		error("pas de lumiere");
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, TV, TH, "RVT1");
	e->img = mlx_new_image(e->mlx, TV, TH);
	e->addr = mlx_get_data_addr(e->img, &(e->bpp), &(e->sizel), &(e->endian));
	e->o.d = 1;
	e->o.h = 0.35;
	e->o.l = 0.5;
	e->o.vpul = vpulcalculator(e->o);
	e->c.x = 0;
	e->c.y = 0;
	e->c.z = 0;
	e->c2.x = 1;
	e->c2.y = 1;
	e->c2.z = 1;
	e->test2 = 0;
	// printf("vpulx = %f vpuly = %f vpulz = %f\n", (double)e->o.vpul.x, (double)e->o.vpul.y, (double)e->o.vpul.z);
}
Exemple #14
0
int			main(int ac, char **av)
{
    t_env	e;

    if (ac == 2 && av)
    {
        if (!(e.mlx = mlx_init()))
            exit_gracefully("mlx_init: Connexion to Xserver failed.");
        if (!(e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, "Wolf3D")))
            exit_gracefully("mlx_new_window: Could not create window.");
        if (!(e.img = mlx_new_image(e.mlx, WIDTH, HEIGHT)))
            exit_gracefully("mlx_new_image: Could not create image.");
        if (!(e.table = mlx_get_data_addr(e.img, &e.bpp, &e.size, &e.endian)))
            exit_gracefully("mlx_get_data_addr: Could not read data.");
        ft_count_columns(&e, av[1]);
        e.x = e.map_line / 2;
        e.y = e.map_col / 2;
        ft_line(&e, 1.2);
        ft_draw(&e);
        mlx_expose_hook(e.win, &ft_exposehook, &e);
        mlx_hook(e.win, KeyPress, KeyPressMask, &ft_keypress, &e);
        mlx_loop(e.mlx);
    }
    else
        exit_gracefully("\033[33mUsage : ./wolf3d <map.name>\033[0m");
    return (0);
}
Exemple #15
0
int				main(int argc, char **argv)
{
	t_data	d;
	t_file	*file;
	t_file	*tmp;

	file = NULL;
	if (argc != 2)
		ft_putendl_fd("Usage: ./rt scene", 2);
	else
	{
		tmp = ft_init(&file, &d, argv[1]);
		ft_parsing(file, &d);
		ft_get_light(file, &d);
		if ((d.mlx = mlx_init()) == NULL)
			return (-1);
		d.win = mlx_new_window(d.mlx, d.width, d.height, "RT");
		d.img = mlx_new_image(d.mlx, d.width, d.height);
		ft_get_data(&d);
		ft_free_file(tmp);
		ft_raytracing(&d);
		mlx_key_hook(d.win, &ft_key_hook, &d);
		mlx_expose_hook(d.win, &ft_expose_hook, &d);
		mlx_loop(d.mlx);
	}
	return (0);
}
Exemple #16
0
static void	init_mlx(t_fol *f)
{
	f->mlx = mlx_init();
	f->win = mlx_new_window(f->mlx, WIN_W, WIN_H, "Fractol");
	f->im = mlx_new_image(f->mlx, WIN_W, WIN_H);
	f->imc = mlx_get_data_addr(f->im, &f->bpp, &f->imlen, &f->endi);
}
Exemple #17
0
int			main(int ac, char **av)
{
	t_env	e;

	if (ac != 2)
		ft_error("Voir Usage a la compilation.");
	ft_getinput(&e, av[1]);
	if (!(e.mlx = mlx_init()))
		ft_error("mlx_init: Connexion au Xserver echouee.");
	if (!(e.win = mlx_new_window(e.mlx, WIDTH, HEIGHT, "fdf")))
		ft_error("mlx_new_window: La fenetre n'a pas pu etre creee.");
	if (!(e.img = mlx_new_image(e.mlx, WIDTH, HEIGHT)))
		ft_error("mlx_new_image: L'image n'a pas pu etre creee.");
	if (!(e.table = mlx_get_data_addr(e.img, &e.bpp, &e.size, &e.endian)))
		ft_error("mlx_get_data_addr: Les donnees n'ont pas pu etre lues.");
	e.zoom = 10;
	e.r = 0xcc;
	e.g = 0xcc;
	e.b = 0xcc;
	ft_center(&e, 0, 0, 0);
	ft_draw(&e);
	mlx_expose_hook(e.win, &ft_exposehook, &e);
	mlx_mouse_hook(e.win, &ft_mousehook, &e);
	mlx_hook(e.win, KeyPress, KeyPressMask, &ft_keypress, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #18
0
void				init_cfg(t_cfg *cfg, int argc, char **argv)
{
	cfg->mlx = mlx_init();
	cfg->win = mlx_new_window(cfg->mlx, WIDTH, HEIGHT, "Fractol");
	cfg->img.img = mlx_new_image(cfg->mlx, WIDTH, HEIGHT);
	cfg->img.data = mlx_get_data_addr(cfg->img.img, &cfg->img.bpp,
		&cfg->img.sl, &cfg->img.endian);
	cfg->type = ftype(argc, argv);
	cfg->iter = 50;
	cfg->cr = -0.75;
	cfg->ci = 0.27015;
	cfg->zoom = 1.0;
	cfg->theme = 0;
	cfg->themev = 0;
	cfg->offset = (t_dvec2){.x = 0.0, .y = 0.0};
	cfg->color = (t_color){.r = 0.0, .g = 0.0, .b = 0.0};
	init_sval(cfg);
}

int					main(int argc, char **argv)
{
	t_cfg			cfg;

	init_cfg(&cfg, argc, argv);
	mlx_put_image_to_window(cfg.mlx, cfg.win, cfg.img.img, 0, 0);
	mlx_hook(cfg.win, 2, 1, key_hook, &cfg);
	mlx_hook(cfg.win, 6, 64, &mouse, &cfg);
	mlx_expose_hook(cfg.win, expose_hook, &cfg);
	mlx_loop(cfg.mlx);
	return (0);
}
Exemple #19
0
Fichier : new.c Projet : ItsJimi/42
t_mlx	*new_mlx(t_mlx *mlx, int av, char *name)
{
	mlx->w = 500;
	mlx->h = 500;
	mlx->av = av;
	mlx->menu = 0;
	mlx->mouse_on = 0;
	mlx->x1 = -1.5;
	mlx->x2 = 1.5;
	mlx->y1 = -1.5;
	mlx->y2 = 1.5;
	mlx->max = 20;
	mlx->movex = 0;
	mlx->movey = 0;
	mlx->zoom = 1;
	if (av == 6)
		mlx->max = 1;
	mlx->change_color = 0;
	if (!(mlx->mlx = mlx_init()))
		str_exit(-1, "new.c : Error line 75");
	if (!(mlx->win = mlx_new_window(mlx->mlx, mlx->w, mlx->h, str_maj(name))))
		str_exit(-1, "new.c : Error line 77");
	mlx->img = new_img(mlx);
	return (mlx);
}
Exemple #20
0
void	init_env(t_env *env)
{
	srand(time(NULL));
	env->mlx = mlx_init();
	env->win = mlx_new_window(env->mlx, WINX, WINY, "fractol");
	env->winop = mlx_new_window(env->mlx, 450, 370, "commandes");
	env->img = mlx_new_image(env->mlx, WINX, WINY);
	env->pix = mlx_get_data_addr(env->img, &env->bpp, &env->s_l, &env->endian);
	env->fract = 'm';
	env->maxiter = 23;
	env->movx = 0;
	env->movy = 0;
	env->zoom = 1.0;
	env->palette = 1;
	env->cx = 0.0;
	env->cy = 0.0;
	env->njul = 2;
	env->rdmclr = 0;
	env->riter = 2;
	env->rzoom = 1.0;
	env->rmovx = 0;
	env->rmovy = 0;
	env->music = 0;
	env->modif = 0;
	set_colors(env);
	draw_options(env);
}
Exemple #21
0
t_env		*wolf3d_init(int ac, char **av)
{
	t_env *env;

	if (!(env = (t_env*)malloc(sizeof(t_env))))
		wolf3d_exit(&env, "wolf3d_init: malloc");
	env->color = color_get(255, 255, 255, 0);
	env->dist = 0;
	env->ac = ac;
	env->av = av;
	env->ray.dir.x = 0;
	env->ray.inter.x = 0;
	env->ev_draw_map = 0;
	env->ev_color = 0;
	env->i = 0;
	wolf3d_map_load(env);
	if (wolf3d_player_init(env) == 0)
		wolf3d_exit(&env, "Place a '#' in map to have a spawn !");
	if (((env)->mlx = mlx_init()) == NULL)
		wolf3d_exit(&env, "wolf3d_init: mlx_init");
	if ((env->win = mlx_new_window(env->mlx, WIDTH, HEIGHT, TITLE)) == NULL)
		wolf3d_exit(&env, "wolf3d_init: mlx_new_window");
	(env)->img = NULL;
	img_clear(env);
	init_texture(env);
	return (env);
}
Exemple #22
0
int			main(void)
{
	t_env	e;

	e = *(t_env*)malloc(sizeof(t_env));
	e.mlx = (void *)malloc(sizeof(void *));
	e.win = (void *)malloc(sizeof(void *));
	e.mlx = mlx_init();
	e.win = mlx_new_window(e.mlx, WIN_WIDTH, WIN_HEIGH, "The Wolf");
	e.img.img = (void *)malloc(4096);
	e.player.pos.x = 22;
	e.player.pos.y = 12;
	e.player.dir.x = -1;
	e.player.dir.y = 0;
	e.r.plane.x = 0;
	e.r.plane.y = 0.80;
	e.time = 0;
	e.oldtime = 0;
	read_file(&e);
	mlx_loop_hook(e.mlx, &loop_hook, &e);
	mlx_hook(e.win, 2, (1L << 0), &key_press, &e);
	mlx_hook(e.win, 3, (1L << 1), &key_release, &e);
	mlx_hook(e.win, 17, 0L, &quit, &e);
	mlx_loop(e.mlx);
	return (0);
}
Exemple #23
0
void	w_init(t_env *e)
{
	e->cam->pos.x = 0;
	e->cam->pos.y = 0;
	e->cam->dir.x = 1;
	e->cam->dir.y = 0;
	e->cam->fov.x = 0;
	e->cam->fov.y = 0.66;
	e->width = 600;
	e->height = 9 * e->width / 16;
	e->map = NULL;
	e->disp = 0;
	e->spot_placed = 0;
	e->game = 0;
	e->prev_game = 0;
	e->anim = 0;
	e->up = 0;
	e->down = 0;
	e->left = 0;
	e->right = 0;
	e->space = 0;
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, e->width, e->height, "wolf3d");
	e->img = NULL;
	w_init_settings(e);
}
Exemple #24
0
int			main(int ac, char **av)
{
	t_env	e;

	e.inf.h = 0.2;
	e.div = 2;
	if (ac >= 2 && ac <= 7)
	{
		if (ft_strcmp(av[1], "-help") == 0)
			aff_help();
		e.mlx = mlx_init();
		init_env(&e);
		read_args(&e, ac, av);
		parsing(&e, av[1]);
		e.inf.scale = (((e.arg.winx + e.arg.winy) / (e.p.lenx + e.p.leny)) / 2);
		e.inf.scale = e.inf.scale <= 0 ? 0.8 : e.inf.scale;
		e.orix = e.arg.winx / 2;
		e.oriy = e.arg.winy / e.p.leny;
		backup(&e);
		draw(&e);
	}
	else
		aff_help();
	return (0);
}
Exemple #25
0
int		main(int ac, char **av)
{
	t_all	all;

	if (ac >= 2)
	{
		all.mlx = mlx_init();
		all.win_x = (ac >= 4 && check_arg(av[2])) ? ft_atoi(av[2]) : 500;
		all.win_y = (ac >= 4 && check_arg(av[3])) ? ft_atoi(av[3]) : 500;
		all.win = mlx_new_window(all.mlx, all.win_x, all.win_y, "FdF");
		init_all(&all);
		if (ac == 5)
			check_color(av[4], &all);
		all.fd = open(av[1], O_RDONLY);
		if (all.fd == -1)
			exit(EXIT_FAILURE);
		parser(all.fd, &all);
		mlx_hook(all.win, 2, (1L << 0), key_hook_first, &all);
		draw_map_x(&all);
		mlx_loop(all.mlx);
	}
	else
		help_main();
	return (0);
}
Exemple #26
0
int		main(int argc, char **argv)
{
	t_env	e;
	int		fd;

	set_variables(&e);
	if (argc == 2)
	{
		fd = open(argv[1], O_RDONLY);
		if (fd == -1)
		{
			perror(argv[1]);
			exit(0);
		}
		get_tab(fd, &e);
		e.mlx = mlx_init();
		if (e.mlx == NULL)
			exit(0);
		e.win = mlx_new_window(e.mlx, 1500, 1200, "42");
		mlx_key_hook(e.win, key_hook, &e);
		mlx_expose_hook(e.win, expose_hook, &e);
		mlx_loop(e.mlx);
	}
	else
		write(1, "usage : ./fdf file_name\n", 24);
	return (0);
}
Exemple #27
0
void		all_init(t_all *all)
{
	int				i;

	if (!(all->env.mlx = mlx_init()))
	{
		ft_putendl_fd("Can't display (No X server)", 2);
		exit(2);
	}
	all->env.win = mlx_new_window(all->env.mlx, WIN_SZ_X, WIN_SZ_Y, "Fractol");
	all->img.img = mlx_new_image(all->env.mlx, WIN_SZ_X, WIN_SZ_Y);
	all->img.data = mlx_get_data_addr(all->img.img, &all->img.bpp,
	&all->img.sizeline, &all->img.endian);
	all->img.clrline = 0xFFC700;
	all->zoom = 300;
	all->off.x = -100;
	all->off.y = -200;
	all->ite_max = 200;
	all->re = 1;
	all->f = 1;
	all->filter = -1;
	all->color = 1;
	all->inc = all->img.bpp / 8;
	i = 0;
	while (i++ <= NB_COLOR)
		all->pallette[i - 1] = color((i - 1) / (double)NB_COLOR);
}
Exemple #28
0
int main(int argc, char **argv)
{
	t_id s;
	int fd;
	char *line;
	(void)argc;

	fd = open(argv[1], O_RDONLY);
	s.nl = 0;

	while ((get_next_line(fd, &line)) > 0) 
				++s.nl;
	s.map = (int **)malloc(sizeof(int *) * s.nl);
	s.nl = 0;
	close(fd);
	fd = open(argv[1], O_RDONLY);
	while ((get_next_line(fd, &line)) > 0)
	{	
		s.map[s.nl] = ft_parsing(line);
		s.nc = (int)ft_get_number_of_words(line, ' ');
		s.nl++;
	}
	s.mlx = mlx_init();
	s.win = mlx_new_window(s.img, W_X, W_Y, WIN_NAME);
	

	mlx_key_hook(s.win, key_reaction, &s);
	mlx_loop(s.mlx);
	return (0);
}
Exemple #29
0
t_mlx	init_mlx(t_letubbies po)
{
	t_mlx	list;

	list.color = 0xFFFFFF;
	list.gap = 5;
	list.ori = 0;
	list.default_gap = list.gap;
	list.width_w = 1500;
	list.height_w = 1500;
	list.pos_x_image = -500;
	list.pos_y_image = -500;
	list.pas_width = 1000;
	list.pas_height = 1000;
	list.mlx = mlx_init();
	list.win = mlx_new_window(list.mlx, list.width_w, list.height_w, "FDF");
	list.xmax = po.xmax;
	list.ymax = po.ymax;
	list.po_tab = po.tab;
	list.lp = boucle_lpoint(list);
	list.width_image = list.pas_width * 2 + list.xmax * (list.gap * 2) * 3;
	list.height_image = list.pas_height * 2 + list.ymax * (list.gap * 2) * 3;
	list = ft_create_image(list);
	return (list);
}
Exemple #30
0
void	check_error(t_all *all)
{
  if ((all->my.mlx_ptr = mlx_init()) == NULL)
    {
      my_putstr("mlx_init: ERROR\n");
      exit(0);
    }
  if ((all->my.win_ptr = mlx_new_window(all->my.mlx_ptr, all->my.x_size,
					all->my.y_size, "RTV1\n")) == NULL)
    {
      my_putstr("mlx_new_window: ERROR\n");
      exit(0);
    }
  if ((all->my.img_ptr = mlx_new_image(all->my.mlx_ptr, all->my.x_size,
				       all->my.y_size)) == NULL)
    {
      my_putstr("mlx_new_image: ERROR\n");
      exit(0);
    }
  if ((all->my.data =
       mlx_get_data_addr(all->my.img_ptr, &(all->my.bpp),
			 &(all->my.size_l), &(all->my.endian))) == NULL)
    {
      my_putstr("mlx_get_data_addr: ERROR\n");
      exit(0);
    }
}