static void refresh(t_app *app) { app->img = mlx_new_image(app->env.mlx, RES_X, RES_Y); raycasting_loop(app); mlx_put_image_to_window(app->env.mlx, app->env.win, app->img, 0, 0); mlx_destroy_image(app->env.mlx, app->img); }
int loop_hook(t_mlxdata *data) { mlx_destroy_image(data->env.mlx, data->img.ptr); data->img = mlx_create_image(data, WIDTH, HEIGHT, 32); which_fractal(data); expose_hook(data); return (1); }
static void key_quit(t_env *e) { mlx_destroy_window(e->mlx.mlx, e->mlx.win); mlx_destroy_image(e->mlx.mlx, e->mlx.img); free(*e); free(e); exit(0); }
void draw_reload(t_env *e) { e->img = mlx_new_image(e->mlx, WINDOW_SIZE_W + 100, WINDOW_SIZE_H + 100); e->pixel_img = mlx_get_data_addr(e->img, &(e->bpp), &(e->s_line), &(e->ed)); draw_map(e); mlx_put_image_to_window(e->mlx, e->win, e->img, -50, -50); mlx_destroy_image(e->mlx, e->img); }
int end_exe(t_e *e) { mlx_destroy_image(e->mlx, e->ima); mlx_destroy_window(e->mlx, e->win); ft_putendl("So long, and thanks for all the fish"); exit(0); return (0); }
void ft_recreate_img(t_id *s) { if (s->img) mlx_destroy_image(s->mlx, s->img); s->img = mlx_new_image(s->img, 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; }
void draw_again(t_map *map) { map->image->image = mlx_new_image(map->mlx, map->x_win, map->y_win); put_map(map); mlx_put_image_to_window(map->mlx, map->win, map->image->image, 0, 0); mlx_destroy_image(map->mlx, map->image->image); mlx_key_hook(map->win, &ft_keyhook, map); mlx_loop(map->mlx); }
int key_hook(int keycode, t_env *env) { if (keycode == 53) { mlx_destroy_image(env->mlx, env->img); exit(1); } return (1); }
void run_application(t_interface *env) { mlx_key_hook(env->gui.win, onkey_handler, env); mlx_expose_hook(env->gui.win, expose_handler, env); mlx_loop(env->gui.mlx); mlx_destroy_image(env->gui.mlx, env->gui.image); kill_stack(&env->objects); dispose_garbage(); }
int ft_destroy_img(void *mlx, t_img *i) { if (i) { mlx_destroy_image(mlx, i->img); free(i); } return (0); }
void ft_imgdel(t_img *img, void *mlx) { if (img) { if (mlx && img->data) mlx_destroy_image(mlx, img->data); free(img); } }
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); }
void ft_free_all(t_all *all) { ft_free_map(all); mlx_destroy_image(all->env.mlx, all->img.img); free(all->env.mlx); free(all->env.win); free(all); exit (0); }
void change_color(t_mlx *list) { list->color = list->color + 0x0F0F0F; mlx_clear_window(list->mlx, list->win); mlx_destroy_image(list->mlx, list->link); *list = ft_create_image(*list); ft_try(*list); mlx_put_image_to_window(list->mlx, list->win, list->link, list->pos_x_image, list->pos_y_image); }
void image(t_env *e) { if (e->img) mlx_destroy_image(e->mlx, e->img); e->img = mlx_new_image(e->mlx, e->size_x, e->size_y); e->img_addr = mlx_get_data_addr(e->img, &e->bits_pix, &e->size_line, &e->end); display_map(e); mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0); }
void ft_clear_mlx(t_mlx *mlx) { if (!mlx) return ; mlx_destroy_image(mlx->p_mlx, mlx->mlx_img->p_img); ft_memdel((void **)&mlx->mlx_img); mlx_clear_window(mlx->p_mlx, mlx->p_win); mlx_destroy_window(mlx->p_mlx, mlx->p_win); ft_memdel((void **)&mlx); }
int ft_key_print(int key, t_struct *s) { key_rgb(key, s); if (key == 85) { init_color(s); s->color++; if (s->color == 6) s->color = 0; } if (key == 53) { exit(2); mlx_destroy_image(s->mlx, s->ptr_img); mlx_destroy_window(s->mlx, s->win); } if (key == 125) s->y1 *= 1.01; if (key == 126) s->y1 *= 0.99; if (key == 124) s->x1 -= 0.01; if (key == 123) s->x1 += 0.01; if (key == 69) { s->iter_max += 1; s->zoom *= 1.05; } if (key == 78) { s->iter_max -= 1; s->zoom *= 0.97; } if (key == 75) s->iter_max += 1; if (key == 67) s->iter_max -= 1; if (key == 83) { s->type++; s->bol = 0; if (s->type == 5) s->type = 1; } if (key == 84) { if (s->bw == 1) s->bw = 0; else s->bw = 1; } put_img(s); return (1); }
static int ft_key_hook(int keycode, t_data *d) { if (keycode == 65307) { mlx_destroy_image(d->mlx, d->img); mlx_destroy_window(d->mlx, d->win); ft_destroy_data(d); exit(EXIT_SUCCESS); } return (1); }
int destroy_funct(void *param) { t_env *env; env = (t_env *)param; mlx_destroy_image(env->mlx, env->ig); mlx_destroy_window(env->mlx, env->win); ft_putendl("Closing program."); exit(0); return (1); }
int key_function(int keycode, t_param *param) { if (keycode == 53) { mlx_destroy_image(param->mlx, param->img); mlx_destroy_window(param->mlx, param->win); free(param); exit(EXIT_SUCCESS); } return (keycode); }
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); }
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); }
void destroy_mlx(t_data *d) { if (d->img) mlx_destroy_image(d->mlx, d->img); if (d->win) mlx_destroy_window(d->mlx, d->win); if (d->mlx) { free(d->mlx); exit(0); } }
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); }
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); }
int gere_key(int keycode, void *param) { t_mlx *p; p = param; if (keycode == ESC) { mlx_destroy_image(p->mlx, p->img); mlx_destroy_window(p->mlx, p->win); exit (0); } return (1); }
void ft_destroy(t_mlxdata *data) { int i; i = 0; while (i < data->grid->columns) free(data->grid->table[i++]); free(data->grid->table); mlx_destroy_image(data->env.mlx, data->img.ptr); mlx_destroy_window(data->env.mlx, data->env.window); free(data->grid); free(data->env.mlx); free(data); }
int expose_hoo(t_struct *mystruct) { mlx_destroy_image(mystruct->mlx, mystruct->img->img_ptr); mystruct->img->img_ptr = mlx_new_image(mystruct->mlx, WIDTH, HEIGHT); if (mystruct->fracnum == 1) myjulia(mystruct); else if (mystruct->fracnum == 2) mymandel(mystruct); else if (mystruct->fracnum == 3) myburn(mystruct); mlx_put_image_to_window(mystruct->mlx, mystruct->win, mystruct->img->img_ptr, 0, 0); return (0); }
int mouse_cg(int x, int y, t_ftol *f) { mlx_destroy_image(f->mlx, f->img); mlx_clear_window(f->mlx, f->win); f->img = mlx_new_image(f->mlx, 800, 800); if (f->check != 1) { f->tmp_z_i = ((double)(y - 512)) / 512; f->tmp_z_r = ((double)(x - 512)) / 512; } print_mandelbrot(f); mlx_put_image_to_window(f->mlx, f->win, f->img, 0, 0); return (0); }
int ft_exposehook(t_env *e) { mlx_clear_window(e->mlx, e->win); if (e->key.i || e->key.k || e->key.kp || e->key.km || e->key.pu || e->key.pd || e->key.w || e->key.s || e->key.a || e->key.d) { mlx_destroy_image(e->mlx, e->img.adr); ft_initimg(e); ft_displaylines(e); } mlx_put_image_to_window(e->mlx, e->win, e->img.adr, 0, 0); ft_debugmessage(e); return (0); }