Exemplo n.º 1
0
Arquivo: init.c Projeto: xSkyZie/42
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);
}
Exemplo n.º 2
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);
}
Exemplo n.º 3
0
int		main(int argc, char **argv)
{
	t_win	*window;
	t_cam	*cam;
	t_map	*map;

	/* Check argv */
	if (argc > 2 || argc == 1)
		ft_error("Too or not enough parameters in command line");
	/* Init Map */
	map = ft_init_map(argv[1]);
	/* Init Env */
	window = init_env();
	/* Init Camera */
	cam = ft_new_camera(map->start, M_PI / 2);

	/* Init img */
	window->img = init_img();

	mlx_do_key_autorepeaton(window->mlx);
	mlx_hook(window->win, 2, (1L << 0), ft_key_hook, window);
	mlx_expose_hook(window->win, ft_expose_hook, window);
	ft_draw_img();
	mlx_put_image_to_window(window->mlx, window->win, window->img->img, 0, 0);
	mlx_loop(window->mlx);


	/* Display view */
	/* Fini ! */
	return (0);
}
Exemplo n.º 4
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);
}
Exemplo n.º 5
0
int				main(int ac, char **av)
{
	t_env		e;
	static char	*fract[] = {FRACTAL_NAMES, 0};
	static void	(*draw[])(t_env *, t_img *) = {FRACTAL_FUNCT};

	e.fract = fract;
	e.draw = draw;
	e.mlx = NULL;
	init_img(&e.one);
	init_img(&e.two);
	e.local_endian = 0x11223344;
	e.local_endian = (((unsigned char *)&e.local_endian)[0] == 0x11) ? 1 : 0;
	if (ac > 1 && !ft_get_fractal_name(av, &e))
		ft_fractol(&e);
	ft_usage(av[0], &e);
	return (EXIT_FAILURE);
}
Exemplo n.º 6
0
Arquivo: map.c Projeto: xSkyZie/42
void			change_map(t_env *e, char *filename)
{
	free_tab(e->map->mapget);
	free(e->map);
	e->map = init_map(e, filename);
	mlx_destroy_image(e->mlx, e->mmap->img);
	free(e->mmap);
	e->mmap = init_img(e, e->map->column * 4, e->map->line * 4);
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: Moss-Id/RTv1
t_win			*init_env(void)
{
	static t_win		*window = NULL;

	if (window == NULL)
	{
		if (!(window = (t_win*)malloc(sizeof(t_win))))
			ft_error("Insuffisant memory.");
		window->mlx = mlx_init();
		window->win = mlx_new_window(window->mlx, WIN_HEI, WIN_WID, "RT_v1");
		window->img = init_img();
	}
	return (window);
}
Exemplo n.º 8
0
int		main(int argc, char **argv)
{
  t_mlx		*ptr;
  t_img		*i;

  ptr = init_mlx();
  i = init_img(ptr);
  if (argc == 2)
    bombyx1(i, ptr, argv[1]);
  if (argc == 3)
    graph2(argv, ptr, i);
  else
    printf("Usage: ./106bombyx [-k] OR [-i_min -i_max]");
  printf("\n");
  return (0);
}
Exemplo n.º 9
0
void	init_env(t_env *env)
{
	env->mlx = mlx_init();
	if (env->mlx == NULL)
	{
		ft_putendl_fd("Fatal error : mlx cannot initialize", 2);
		exit(-1);
	}
	env->zoom = ZOOM;
	env->win = mlx_new_window(env->mlx, WIDTH, HEIGHT, "Fract'ol");
	if (env->win == NULL)
	{
		ft_putendl_fd("Fatal error : mlx cannot create window", 2);
		exit(-1);
	}
	init_img(env);
	env->color = 0;
	env->menu = 0;
	draw_fractal(env);
}
Exemplo n.º 10
0
int			key_hook(int keycode, t_env *env)
{
    if (keycode == KEYCODE_ESC)
    {
        mlx_destroy_image(env->mlx, env->img);
        exit(0);
    }
    if (keycode == KEYCODE_H)
        env->menu = (env->menu + 1) % 2;
    else
    {
        move(keycode, env);
        zoom(keycode, env);
        change_fractal(keycode, env);
        change_color(keycode, env);
    }
    mlx_destroy_image(env->mlx, env->img);
    init_img(env);
    draw_fractal(env);
    return (keycode);
}
Exemplo n.º 11
0
int main(void)
{
	vbx_timestamp_t time_start, time_stop;
	double scalar_time, vector_time;

	input_pointer img1;
	input_pointer img2;
	input_pointer sc_img1;
	input_pointer sc_img2;
	output_pointer scalar_out;
	output_pointer vector_out;

	int i,j;

    int total_errors = 0;

    vbx_test_init();

	vbx_mxp_print_params();

	img1       = vbx_shared_malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type)  );
	img2       = vbx_shared_malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type)  );
	vector_out = vbx_shared_malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(output_type) );

	sc_img1    = malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type)  );
	sc_img2    = malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(input_type)  );
	scalar_out = malloc( NUM_OF_ROWS*NUM_OF_COLUMNS*sizeof(output_type) );

	init_img( img1, img2 );
	init_img( sc_img1, sc_img2 );

	vbx_mxp_t *this_mxp = VBX_GET_THIS_MXP();
	const int VBX_VECTOR_BYTE_LANES = this_mxp->vector_lanes * sizeof(int);

	printf("\n");
	printf("Num of byte lanes: %d\n", VBX_VECTOR_BYTE_LANES);

	printf("Initialized data\n\n");
	printf("Executing Scalar Image Blend...\n");

	vbx_timestamp_start();
	time_start = vbx_timestamp();
	scalar_blend( scalar_out, sc_img1, sc_img2, NUM_OF_ROWS, NUM_OF_COLUMNS, CONST_BLEND );
	time_stop = vbx_timestamp();

	printf("Finished Scalar Image Blend\n");
	scalar_time = vbx_print_scalar_time(time_start, time_stop);

	printf("\nExecuting Vector Image Blend...\n");

	vbx_timestamp_start();
	time_start = vbx_timestamp();
	vector_blend( vector_out, img1, img2, NUM_OF_ROWS, NUM_OF_COLUMNS, CONST_BLEND);
	time_stop = vbx_timestamp();

	printf("Finished Vector Image Blend\n");

	vector_time = vbx_print_vector_time(time_start, time_stop, scalar_time);

	int errors = 0;
	for( j=0; j<NUM_OF_ROWS; j++ ) {
		for( i = 0; i < NUM_OF_COLUMNS; i++ ) {
			if( vector_out[j*NUM_OF_COLUMNS+i] != scalar_out[j*NUM_OF_COLUMNS+i] ) {
				if(errors < 5)
					printf( "\nFail at sample [%3d,%3d].  Scalar: %3d Vector: %3d Img1: %3d Img2: %3d",
						j, i, scalar_out[j*NUM_OF_COLUMNS+i],
						vector_out[j*NUM_OF_COLUMNS+i], img1[j*NUM_OF_COLUMNS+i], img2[j*NUM_OF_COLUMNS+i] );
				errors++;
			}
		}
	}
	printf("\n%d errors\n", errors);
    total_errors += errors;

    VBX_TEST_END(total_errors);

	return 0;
}
Exemplo n.º 12
0
static void		new_window(t_env *env)
{
	env->mlx = mlx_init();
	env->win = mlx_new_window(env->mlx, X_WIN, Y_WIN + 200, "Wolf3D");
	env->img = init_img(env);
}