예제 #1
0
파일: init_img.c 프로젝트: vquesnel/Wolf3D
t_img		*init_img(t_env *env)
{
	t_img	*img;

	if (!(img = (t_img *)malloc(sizeof(t_img))))
		ft_error("Can't create image.");
	img->img = mlx_new_image(env->mlx, X_SIZE, Y_SIZE);
	img->data = mlx_get_data_addr(img->img, &img->bpp, \
			&img->sizeline, &img->endian);
	return (img);
}
예제 #2
0
파일: main.c 프로젝트: 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);
}
예제 #3
0
int		ft_recreate(t_id *s)
{
    if (s->img)
        mlx_destroy_image(s->mlx, s->img);
    s->img = mlx_new_image(s->mlx, W_X, W_Y);
    s->data = mlx_get_data_addr(s->img, &s->bit_per_pixel, &s->s_line,
                                &s->endian);
    s->bpp = s->bit_per_pixel / 8;
    ft_corps(s);
    return (1);
}
예제 #4
0
파일: image.c 프로젝트: kwiessle/wolf3d
t_img		*init_img(t_env *env)
{
	t_img	*img;

	if (!(img = (t_img *)malloc(sizeof(t_img))))
		return (NULL);
	img->img = mlx_new_image(env->mlx, X_WIN, Y_WIN);
	img->data = mlx_get_data_addr(img->img, &img->bpp, \
			&img->size_line, &img->endian);
	return (img);
}
예제 #5
0
파일: new.c 프로젝트: ItsJimi/42
t_img	*new_img(t_mlx *mlx)
{
	t_img	*img;

	if (!(img = (t_img *)malloc(sizeof(*img))))
		str_exit(-1, "new.c : Error line 55");
	img->img = mlx_new_image(mlx->mlx, mlx->w, mlx->h);
	img->addr = mlx_get_data_addr(img->img, &(img->bpp), &(img->size_l),
		&(img->endian));
	return (img);
}
예제 #6
0
파일: image.c 프로젝트: ebaudet/RTV1
t_img		*img_init(void)
{
	t_win	*win;
	t_img	*img;

	win = env_init();
	img = (t_img *)malloc(sizeof(t_img));
	img->img = mlx_new_image(win->mlx, WIDTH, HEIGHT);
	img->data = mlx_get_data_addr(img->img, &img->bpp, &img->size_line
		, &img->endian);
	return (img);
}
예제 #7
0
파일: mlx.c 프로젝트: Infornia/RayTracing
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);
}
예제 #8
0
파일: ft_main.c 프로젝트: nsavry/FdF
int		main(int argc, char **argv)
{
	t_env		e;

	e.mlx = mlx_init();
	if (e.mlx == NULL)
		return (0);
	e.win = mlx_new_window(e.mlx, 2400, 1300, "Fil de Fer");
	if (e.win == NULL)
		return (0);
	e.im = mlx_new_image(e.mlx, 2400, 1300);
	e.imb = mlx_new_image(e.mlx, 2400, 1300);
	e.x = 0;
	e.y = 0;
	e.map = NULL;
	ft_init_space(argc, argv, &e);
	mlx_key_hook(e.win, key_hook, &e);
	mlx_expose_hook(e.win, expose_hook, &e);
	mlx_loop(e.mlx);
	return (0);
}
예제 #9
0
void	create_img(t_mlx *mlx, t_img *img)
{
  img->win_x = 800;
  img->win_y = 600;
  img->sphere = mlx_new_image(mlx->mlx_ptr, img->win_x, img->win_y);
  img->data = mlx_get_data_addr(img->sphere, &(img->bpp),
				&(img->sizeline), &(img->endian));
  color_img(img, mlx);
  /* if (mlx_put_image_to_window(mlx->mlx_ptr, mlx->win_ptr, */
  /* 			      img->sphere, 0, 0) == -1) */
  /*   exit(1); */
}
예제 #10
0
파일: main.c 프로젝트: 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);
}
예제 #11
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;
}
예제 #12
0
파일: fractol.c 프로젝트: hhismans/fractol
int		mouse_hook(int boutton, int x, int y, t_env *e)
{
	printf("bouton = %d, x = %d, y = %d\n", boutton, x, y);
	if (boutton == LEFT_CLIC)
	{
		if (e->nbr_clic == 0)
		{
			ft_putstr("in nrbclic = 0");
			e->nbr_clic++;
			e->xmintmp = e->xmin;
			e->ymintmp = e->ymin;
			e->xmin = e->xmin + x * e->stepx;
			e->ymin = e->ymin + y * e->stepy;
		}
		else if (e->nbr_clic == 1)
		{
			ft_putstr("in nrbclic = 1");
			e->nbr_clic = 0;
			e->xmax = e->xmintmp + x * e->stepx;
			e->ymax = e->ymintmp + y * e->stepy;
			e->stepx = (double)(e->xmax - e->xmin) / WX;
			e->stepy = (double)(e->ymax - e->ymin) / WY;
			double x_f;
			double y_f;
			int nb_it;
			mlx_destroy_image(e->mlx, e->img);
			e->img = mlx_new_image(e->mlx, WX, WY);
			x_f = e->xmin;
			x = 0;
			while (x <= WX)
			{
				y = 0;
				y_f = e->ymin;
				while (y <= WY)
				{
					nb_it = is_converg((mandelbrot), x_f, y_f);
			//			printf("val x_f = %lf, val de y_f = %lf, val de nb_it = %d\n", x_f, y_f, nb_it);
			//			printf("val stepx= %lf, val de stepy = %lf, val de y %d= \n",e->stepx, e->stepy, y);
					if (nb_it < 1000)
						mlx_pixel_put_img(e->img, x, y, rainbow_gen(nb_it * 40));
					else
						mlx_pixel_put_img(e->img, x, y, 0x000000);
					y++;
					y_f += e->stepy;
				}
				x_f += e->stepx;
				x++;
			}
			mlx_put_image_to_window(e->mlx, e->win, e->img, 0,0);
		}
	}
	return (0);
}
예제 #13
0
파일: struct.c 프로젝트: Borhink/wolf3d
int			create_img(t_env *e, t_img *img)
{
	t_texture	*h;

	h = &(e->hand);
	h->i = mlx_xpm_file_to_image(e->mlx, "img/hand.xpm", &(h->wth), &(h->hgt));
	if (!(img->i = mlx_new_image(e->mlx, WIN_W, WIN_H)) || !h->i)
		return (0);
	img->d = mlx_get_data_addr(img->i, &(img->bpp), &(img->sl), &(img->edn));
	h->d = mlx_get_data_addr(h->i, &(h->bpp), &(h->sl), &(h->edn));
	return (1);
}
예제 #14
0
파일: main.c 프로젝트: pkesslas/projets
void	ft_setimg(t_ba *ba)
{
	int		bpp;
	int		size;
	int		endian;

	size = 0;
	endian = 0;
	bpp = 0;
	ba->img = mlx_new_image(ba->mlx, WD_H, WD_W);
	ba->pix = mlx_get_data_addr(ba->img, &bpp, &size, &endian);
}
예제 #15
0
파일: main.c 프로젝트: Moss-Id/RTv1
t_img			*init_img(void)
{
	t_win	*win;
	t_img	*img;

	win = init_env();
	img = (t_img*)malloc(sizeof(t_img));
	img->img = mlx_new_image(win->mlx, WIN_WID, WIN_HEI);
	img->data = mlx_get_data_addr(img->img, &img->bbp,
									&img->size_line, &img->endian);
	return (img);
}
예제 #16
0
파일: main.c 프로젝트: 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);
}
예제 #17
0
void	ft_initialization(t_id *s)
{
	s->dp = 25;
	s->decalz = 0.2;
	s->slide = 0.2;
	s->img = mlx_new_image(s->mlx, W_X, W_Y);
	s->data = mlx_get_data_addr(s->img, &s->bit_per_pixel, &s->s_line,
			&s->endian);
	s->bpp = s->bit_per_pixel / 8;
	ft_display_hor(s);
	ft_display_ver(s);
	mlx_put_image_to_window(s->mlx, s->win, s->img, 0, 0);
}
예제 #18
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);
}
예제 #19
0
파일: fractol.c 프로젝트: amoinier/fractol
static	t_img	*ft_init_img(t_env *init)
{
	t_img	*img;

	if (!(img = (t_img *)malloc(sizeof(*img))))
		error();
	img->img = mlx_new_image(init->mlx, init->width, init->height);
	img->bpp = 0;
	img->sizel = 0;
	img->endn = 0;
	img->cimg = mlx_get_data_addr(img->img, &img->bpp, &img->sizel, &img->endn);
	return (img);
}
예제 #20
0
파일: fractol.c 프로젝트: hhismans/fractol
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;
}
예제 #21
0
t_mlximg	mlximg_create(void *mlx, int width, int height)
{
  t_mlximg	rtn;

  if ((rtn.ptr = mlx_new_image(mlx, width, height)) != NULL)
    {
      rtn.size.x = width;
      rtn.size.y = height;
      rtn.data = mlx_get_data_addr(rtn.ptr, &rtn.bpp, &rtn.linesize,
				   &rtn.endianness);
    }
  return (rtn);
}
예제 #22
0
파일: image.c 프로젝트: Frozenhorns/project
// Inisialization img
t_image		*initialization_img(void *ptr_ini, int height, int width)
{
  t_image	*t_img;

  IMG = malloc(sizeof(*t_img));
  IMG->ptr_ini = ptr_ini;
  IMG->height = height;
  IMG->width = width;
  IMG->img = mlx_new_image(ptr_ini, width, height);
  IMG->data = mlx_get_data_addr(IMG->img, &IMG->bpp, \
				&IMG->sizeline, &IMG->endian);
  return (t_img);
}
예제 #23
0
파일: setup_mlx.c 프로젝트: Denis2222/RTv1
void	render(t_env *e)
{
	key_up_down(e);
	key_left_right(e);
	e->img = mlx_new_image(e->mlx, WIDTH, HEIGHT);
	e->imgpx = mlx_get_data_addr(e->img,
	&(e->bpp), &(e->size_line), &(e->endian));

	raytrace(e);
	mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0);
	usleep(50);
	mlx_destroy_image(e->mlx, e->img);
}
예제 #24
0
파일: main.cpp 프로젝트: gabfou/ruche
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);
}
예제 #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);
}
예제 #26
0
파일: rtv1.c 프로젝트: amoinier/RTV1
static	t_img	*ft_init_img(t_env *init, int w, int h)
{
	t_img	*img;

	if (!(img = (t_img *)malloc(sizeof(*img))))
		error("error : ft_init_img");
	img->img = mlx_new_image(init->mlx, w, h);
	img->bpp = 0;
	img->sizel = 0;
	img->endn = 0;
	img->cimg = mlx_get_data_addr(img->img, &img->bpp, &img->sizel, &img->endn);
	return (img);
}
예제 #27
0
파일: main.c 프로젝트: Oludovic/raytracer
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);
}
예제 #28
0
파일: window.c 프로젝트: 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);	
}
예제 #29
0
파일: main.c 프로젝트: NegMozzie/42
static int		create_img(t_env *env)
{
	t_img		*img;

	env->img[10] = (t_img *)malloc(sizeof(t_img));
	img = env->img[10];
	if (!(img->img = mlx_new_image(env->ptr, SCREENWIDTH, SCREENHEIGHT)))
		exit (0);
	if (!(img->data = mlx_get_data_addr(img->img, &(img->bpp), &(img->sizel)
		, &(img->endian))))
		exit (0);
	return (1);
}
예제 #30
0
파일: init.c 프로젝트: 42-Ceasure/SquelMLX
int	init_mlx(t_win *win)
{
	win->mlx = mlx_init();
	win->win = mlx_new_window(win->mlx, WIDTH, HEIGHT, NAME);
	win->img = mlx_new_image(win->mlx, WIDTH, HEIGHT);
	win->endian = 1;
	win->bpp = 4;
	win->s_line = WIDTH;
	win->data = mlx_get_data_addr(win->img, &(win->bpp), &(win->s_line), &(win->endian));
	mlx_key_hook(win->win, key_hook, win);
	// mlx_expose_hook(win->win, expose_hook, win);
	mlx_loop(win->mlx);
	return (0);
}