Example #1
0
void		fract_init(t_a *a)
{
	ft_init_info(a);
	fractol_init_var(a);
	if (!(a->mlx = mlx_init()))
		ft_error("mlx_init error");
	if (!(a->win = mlx_new_window(a->mlx, MAX_X, MAX_Y + 200, TITLE)))
		ft_error("mlx_new_windows error");
}
Example #2
0
static void		ft_init_image(t_windata *t_fdf)
{
	ZOOM = 15;
	t_fdf->mlx = mlx_init();
	t_fdf->win = mlx_new_window(t_fdf->mlx, HEIGHT, WIDTH, "mlx");
	t_fdf->img = mlx_new_image(t_fdf->mlx, HEIGHT, WIDTH);
	t_fdf->data = mlx_get_data_addr(t_fdf->img, &t_fdf->bpp, &t_fdf->size_line,
			&t_fdf->endian);
}
Example #3
0
static	void		set_mlx(char *av, t_img *img)
{
	if (!(img->mlx = mlx_init()))
		return ;
	img->win = mlx_new_window(img->mlx, WINDOW_W, WINDOW_H, av);
	img->img = mlx_new_image(img->mlx, WINDOW_W, WINDOW_H);
	img->data = mlx_get_data_addr(img->img, &img->bpp, &img->sline,
	&img->endian);
}
Example #4
0
File: main.c Project: mnaki/fractol
void	new_env(ssize_t width, ssize_t height, char *title, t_env *e)
{
	e->core = mlx_init();
	e->win = mlx_new_window(e->core, width, height, title);
	e->img = mlx_new_image(e->core, width, height);
	e->finish = mlx_new_image(e->core, width, height);
	init_callbacks(e->callback);
	init_mouse_callbacks(e->mouse_callback);
}
Example #5
0
void			draw_map(t_env *env, t_map *map)
{
	env->mlx = mlx_init();
	env->win = mlx_new_window(env->mlx, env->x_win, env->y_win, "FdF");
	map->mlx = env->mlx;
	map->win = env->win;
	map->x_win = env->x_win;
	map->y_win = env->y_win;
	draw_again(map);
}
Example #6
0
void	launch_menu(t_box *box)
{
	box->width = 1000;
	box->height = 1000;
	box->win = mlx_new_window(MLX, box->width, box->height, "fractol MENU");
	box->img = mlx_new_image(MLX, box->width, box->height);
	box->data = mlx_get_data_addr(box->img, &box->bpx, &box->sl, &box->endian);
	print_title(box);
	print_menu(box);
}
Example #7
0
File: fdf.c Project: Afxsoft/fdf
t_mlx	*ft_mlx_init()
{
	t_mlx	*mlx;

	mlx = (t_mlx *)malloc(sizeof(t_mlx *));
	mlx->mlx = mlx_init();
	mlx->win = mlx_new_window(mlx->mlx, 2000, 2000, "FDF by Afxsoft");
	mlx->offset = 40;
	return (mlx);
}
Example #8
0
void		ft_init_win(t_env *e)
{
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, e->width, e->height, "Frct");
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_hook(e->win, 4, 5, button_hook, e);
	mlx_hook(e->win, 2, 3, key_hook, e);
	mlx_hook(e->win, 6, 64, motion_hook, e);
	mlx_loop(e->mlx);
}
Example #9
0
File: aff.c Project: vklaouse/FDF
void	aff(t_env *win)
{
	win->mlx = mlx_init();
	win->win = mlx_new_window(win->mlx, 1280, 1024, "fdf");
	win->base_x = 100;
	win->base_y = 100;
	win->size = 10;
	mlx_expose_hook(win->win, draw, &*win);
	mlx_key_hook(win->win, keyboard, &*win);
	mlx_loop(win->mlx);
}
Example #10
0
/*
init_conf() va lire le ficher conf.cf et stocker les different obj dans t_rtv1;
start_rt() lance le calcule des couleur par pixel.
*/
void		start_rt(t_rtv1 *rt)
{
  if ((rt->img->mlx_ptr = mlx_init()) == NULL)
    exit(1);
  rt->img->img_ptr = mlx_new_image(rt->img->mlx_ptr,
                                   rt->img->imgx, rt->img->imgy);
  rt->img->win_ptr = mlx_new_window(rt->img->mlx_ptr,
                                    rt->win->winx, rt->win->winy, "RT-V1");
  mlx_key_hook(rt->img->win_ptr, gere_key, rt);
  mlx_loop(rt->img->mlx_ptr);
}
Example #11
0
File: main.c Project: barug/Epitech
int		start_minilibx(t_imgdata *imgdata)
{
  imgdata->mlx_ptr = mlx_init();
  imgdata->img_ptr = mlx_new_image(imgdata->mlx_ptr,
				   WIN_WIDTH, WIN_HEIGHT);
  imgdata->win_ptr = mlx_new_window(imgdata->mlx_ptr,
				    WIN_WIDTH, WIN_HEIGHT, "display");
  imgdata->data = mlx_get_data_addr(imgdata->img_ptr,
				    &imgdata->bpp, &imgdata->sizeline, &imgdata->endian);
  return (0);
}
Example #12
0
int		main(int argc, char **argv)
{
	t_env	e;

	e.mlx = mlx_init();
	e.win = mlx_new_window(e.mlx, 420, 420, "fenetre de fouuuuuuuuu !!!!!!");
	mlx_key_hook(e.win, key_hook, &e);
	mlx_expose_hook(e.win, expose_hook, &e);
	mlx_mouse_hook(e.win, mouse_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}
Example #13
0
void screen_it(t_screen *screen, char *title, int x, int y)
{
  t_image *screensaver;

  screen->x = x;
  screen->y = y;
  screen->win_ptr = mlx_new_window(screen->mlx_ptr, screen->x, screen->y, title);
  screensaver = malloc(sizeof(*screensaver));
  screensaver->height = y;
  screensaver->width = x;
  screen->screensave = screensaver;
}
Example #14
0
int			ft_init_mlx(t_window *w) // initialise les valeurs ainsi que la fenetre
{
	if (!(w->mlx = mlx_init()))
		return (1);
	w->win = mlx_new_window(w->mlx, 800, 500, "FDF@RW");
	w->r = 100;
	w->g = 100;
	w->b = 100;
	w->zoom = 30;
	w->z_ch = 1;
	return (0);
}
Example #15
0
File: main.c Project: mbarbari/RTv1
void		init_env(t_env *env)
{
	env->mlx = mlx_init();
	env->resolution.width = WIDTH;
	env->resolution.height = HEIGHT;
	env->win = mlx_new_window(env->mlx, WIDTH, HEIGHT, "RayTracer");
	env->img.ptr = mlx_new_image(env->mlx, WIDTH, HEIGHT);
	env->img.data = mlx_get_data_addr(env->img.ptr, &env->img.bpp,
			&env->img.sizeline, &env->img.endianness);
	env->fov = 45;
	env->pos_absolute_camera = (t_vertex3){
		.x = json_get(parser(env->file).data.obj, "pos_camera.x").data.number,
		.y = json_get(parser(env->file).data.obj, "pos_camera.y").data.number,
		.z = json_get(parser(env->file).data.obj, "pos_camera.z").data.number};
	env->matrice = malloc(sizeof(t_color3) * (WIDTH * HEIGHT) + 1);
	env->angle = tanf(M_PI * 0.5f * env->fov / 180.);
	env->ratio = env->resolution.width / (float)env->resolution.height;
	env->invw = 1 / (float)env->resolution.width;
	env->invh = 1 / (float)env->resolution.height;
	env->nb_thread = 14;
	env->sampling = 4;
	env->anglex = 0;
	env->angley = 0;
}

int			main(int argc, char **argv)
{
	t_env		env;
	struct stat	file_stat;

	if (argc == 2)
	{
		env.file = argv[1];
		if (stat(env.file, &file_stat) < 0)
		{
			ft_printf("file not exists\n");
			exit(0);
		}
		file_is_modified(env.file, &env.oldtime, 1);
		init_env(&env);
		ft_setup_inter(env.fctinter);
		ft_setup_normal(env.fctnormal);
		mlx_do_key_autorepeatoff(env.mlx);
		mlx_hook(env.win, 2, (1L << 0), &key_press, &env);
		mlx_loop_hook(env.mlx, &loop_hook, &env);
		mlx_expose_hook(env.win, &rt_expose_hook, &env);
		mlx_loop(env.mlx);
		free(env.matrice);
	}
	else
		ft_printf("Usage: %s scene.json\n", argv[0]);
	return (0);
}
Example #16
0
static void	x_init(t_var *v)
{
  if ((v->mlx = mlx_init()) == NULL)
    exit(EXIT_FAILURE);
  v->img = mlx_new_image(v->mlx, LEN_X, LEN_Y);
  v->win = mlx_new_window(v->mlx, LEN_X, LEN_Y, "Ray-Tracer");
  v->data = mlx_get_data_addr(v->img, &v->bpp, &v->sizeline, &v->endian);
  v->pix_th[0] = 0;
  v->pix_th[1] = 0;
  v->pix_th[2] = 0;
  v->pix_th[3] = 0;
}
Example #17
0
void			init_mlx(t_data *d)
{
	d->mlx = mlx_init();
	if(!(d->win = mlx_new_window(d->mlx, X_WIN, Y_WIN, "RT")))
		exit(tt_pl("window open failed"));
	if(!(d->img = mlx_new_image(d->mlx, X_WIN, Y_WIN)))
		exit(tt_pl("image creation failed"));
	if(!(d->dimg = mlx_get_data_addr(d->img, &d->bpp, &d->size, &d->endian)))
		exit(tt_pl("Get image data failed"));
	d->bpp /= 8;
	d->max_size = (unsigned int)(d->size * Y_WIN);
}
Example #18
0
void			mlx_var(t_env *init, char *av)
{
	init->mlx = mlx_init();
	ft_initenv(init, av);
	init->win = mlx_new_window(init->mlx, init->width, init->height,
	"Fractol");
	mlx_hook(init->win, 2, 0, key_hook, init);
	mlx_hook(init->win, 6, 0, mouse_julia, init);
	mlx_hook(init->win, 4, 0, mouse_hook, init);
	mlx_expose_hook(init->win, expose_hook, init);
	mlx_loop(init->mlx);
}
Example #19
0
File: main.c Project: sbran/42
void		init_libx(t_param *param, char *file)
{
  param->mlx_ptr = mlx_init();
  if (param->mlx_ptr == 0)
    my_puterror("Can not init LibX.\n");
  param->win_ptr = mlx_new_window(param->mlx_ptr, WIN_X, WIN_Y, "Raytracer");
  param->img = mlx_new_image(param->mlx_ptr, WIN_X, WIN_Y);
  treat_image(param, file);
  mlx_key_hook(param->win_ptr, &key, &param);
  mlx_expose_hook(param->win_ptr, &expose, param);
  mlx_loop(param->mlx_ptr);
}
Example #20
0
static void	init(t_glob *glob)
{
    if ((glob->graph->mlx_ptr = mlx_init()) == 0)
        put_error("Cannot init mlx\n", 1);
    init_img(glob, &(glob->graph->aff_img), AFF_SIZEX, AFF_SIZEY);
    init_img(glob, &(glob->graph->calc_img), CALC_SIZEX, CALC_SIZEY);
    init_img(glob, &(glob->graph->loader), 60, 60);
    if ((glob->graph->win_ptr = mlx_new_window(glob->graph->mlx_ptr,
                                AFF_SIZEX, AFF_SIZEY,
                                "Raytracer")) == 0)
        put_error("Cannot create window\n", 1);
}
Example #21
0
t_mlx	*ft_mlx_init(int width, int height, char *name)
{
	t_mlx		*mlx;

	mlx = (t_mlx *)malloc(sizeof(t_mlx));
	mlx->width = width;
	mlx->height = height;
	mlx->p_mlx = mlx_init();
	mlx->p_win = mlx_new_window(mlx->p_mlx, mlx->width, mlx->height, name);
	ft_new_image(mlx);
	return (mlx);
}
Example #22
0
void	declare_and_check_mlx_error(t_graph *e)
{
	if (!(e->mlx = mlx_init()))
	{
		write(2, "mlx init error\n", 15);
		exit(0);
	}
	else if (!(e->win = mlx_new_window(e->mlx, WIDTH, HEIGHT, "Philosophers")))
	{
		write(2, "mlx win error\n", 14);
		exit(0);
	}
}
Example #23
0
void			create_win(t_mlxtool *mlx_tool, char *name)
{
	int sizex;
	int sizey;

	find_x(mlx_tool);
	find_y(mlx_tool);
	sizex = mlx_tool->minx - mlx_tool->maxx;
	sizey = mlx_tool->miny - mlx_tool->maxy;
	mlx_tool->init = mlx_init();
	mlx_tool->win = mlx_new_window(mlx_tool->init, sizex, sizey, name);
	mlx_loop(mlx_tool->init);
}
Example #24
0
File: window.c Project: thumavu/RT
t_gui	new_gui(int w, int h, char *title)
{
	t_gui	env;

	env.mlx = mlx_init();
	env.win = mlx_new_window(env.mlx, w, h, title);
	env.width = w;
	env.height = h;
	env.title = title;
	env.image = mlx_new_image(env.mlx, w, h);
	env.pixel = mlx_get_data_addr(env.image, &env.bpp, &env.sl, &env.endian);
	return (env);	
}
Example #25
0
void		ft_launch(t_param *p, char *file)
{
	if ((p->e.mlx = mlx_init()) == NULL)
		exit(ft_error("[Mlx init]: Initialisation impossible"));
	p->e.win = mlx_new_window(p->e.mlx, WIN_X, WIN_Y, p->file);
	p->e.img = mlx_new_image(p->e.mlx, WIN_X, WIN_Y);
	p->data = mlx_get_data_addr(p->e.img, &(p->bpp), &(p->sl), &(p->endian));
	ft_work(p, 0);
	mlx_mouse_hook(p->e.win, &ft_mouse_hook, p);
	mlx_expose_hook(p->e.win, &ft_expose_hook, p);
	mlx_key_hook(p->e.win, &ft_key_hook, p);
	mlx_loop(p->e.mlx);
}
Example #26
0
void	ft_mlx(t_env *e)
{
	e->f = malloc(sizeof(t_img));

	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, WIDTH + (2 * OFF), HEIGHT + (2 * OFF), "triangle_try_angle");
	e->f->img = mlx_new_image(e->mlx, WIDTH + (2 * OFF), HEIGHT + (2 * OFF));
	e->f->d = mlx_get_data_addr(e->f->img, &e->f->bpp, &e->f->line_size, &e->f->endian);
	mlx_key_hook(e->win, key_hook, e);
	mlx_mouse_hook(e->win, mouse_hook, e);
	mlx_expose_hook(e->win, expose_hook, e);
	mlx_loop(e->mlx);
}
Example #27
0
void initmlx()
{
	char name[2];
	name[0] = '1';
	name[1] = 0;
	e.l = 1280;
	e.h = 800;
	e.mlx = mlx_init();
	e.win = mlx_new_window(e.mlx, e.l, e.h, name);
	e.img = mlx_new_image(e.mlx, e.l, e.h);
	e.addr = mlx_get_data_addr(e.img, &(e.bpp), &(e.sizel), &(e.endian));
//	bzero(e.tab, 10);
}
Example #28
0
void			ft_draw_grid(int **tab, int nb_line, int nb_col)
{
	t_fdf	e;

	e.mlx_ptr = mlx_init();
	e.win = mlx_new_window(e.mlx_ptr, 1500, 1500, "image_42");
	e.tab = tab;
	e.nb_line = nb_line;
	e.nb_col = nb_col;
	mlx_key_hook(e.win, key_hook, &e);
	mlx_expose_hook(e.win, expose_hook, &e);
	mlx_loop(e.mlx_ptr);
}
Example #29
0
void	set_env(t_env *e, char *title, int w, int h)
{
	e->mlx = mlx_init();
	e->win = mlx_new_window(e->mlx, w, h, title);
	e->img = mlx_new_image(e->mlx, w, h);
	e->xmax = XMAX;
	e->xmin = XMIN;
	e->ymax = YMAX;
	e->ymin = YMIN;
	e->nbr_clic = 0;
	e->stepx = (double)(e->xmax - e->xmin) / WX;
	e->stepy = (double)(e->ymax - e->ymin) / WY;
}
Example #30
0
int	main(int ac, char **av)
{
  t_rt	rt;

  rt.mlx_ptr = mlx_init();
  rt.win_ptr = mlx_new_window(rt.mlx_ptr , 400 , 400 , "My first window");
  rt.img_ptr = mlx_new_image(rt.mlx_ptr, 400, 400);
  rt.data = mlx_get_data_addr(rt.img_ptr, &rt.bpp, &rt.sizeline, &rt.endian);
  remplis_image(&rt);
  mlx_put_image_to_window(rt.mlx_ptr, rt.win_ptr , rt.img_ptr, 0, 0);
  mlx_expose_hook(rt.win_ptr, gere_expose, &rt);
  mlx_loop(rt.mlx_ptr);
}