void ft_burning_hub(mlx_t *mlx) { mlx->win_burning = mlx_new_window(mlx->mlx_ptr, WIDTH, HEIGHT, "burning"); mlx_key_hook(mlx->win_burning, key_burning, mlx); mlx_mouse_hook(mlx->win_burning, mouse_burning, mlx); mlx_expose_hook(mlx->win_burning, expose_burning, mlx); }
int main(int ac, char **av) { t_env env; List *list; t_coord *ptr; list = NULL; if (av[1]) { if (!(env.fd = open(av[1], O_RDONLY))) return (-1); while (get_next_line(env.fd, &env.data)) { env.val = ft_strsplit(env.data, ' '); list = ft_get_params_to_lst(env.val, list); free (env.val); } ft_init(&env); ft_add_param_to_struct(&env, &ptr, list); env.ptr2 = ptr; mlx_key_hook(env.win, ft_key_hook, &env); mlx_expose_hook(env.win, ft_expose_hook, &env); mlx_loop_hook(env.win, ft_key_hook, &env); mlx_loop(env.mlx); } return (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); }
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); }
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); }
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); }
int main(int argc, char **argv) { t_env *e; t_objs *obj; if (argc == 2) { e = (t_env *)malloc(sizeof(t_env)); obj = (t_objs *)malloc(sizeof(t_objs)); if (!e || !obj) ft_error("Malloc error", 2); if (!(init_env(e))) return (0); if (!extension(argv[1])) ft_error("File need .rt extension", 2); if (!(obj = parsing(argv[1], e, obj))) ft_error("Parsing error", 2); obj = manage_data(e, obj); e->begin_list = obj; mlx_expose_hook(e->win, expose_hook, e); mlx_key_hook(e->win, key_events, e); mlx_loop(e->mlx); } return (0); }
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); }
void declarations_mlx(t_graph *e) { e->img_ptr = mlx_new_image(e->mlx, WIDTH, HEIGHT); e->img = mlx_get_data_addr(e->img_ptr, &e->bpp, &e->size_line, &e->endian); mlx_expose_hook(e->win, expose_hook, e); mlx_hook(e->win, 2, 1L << 0, &key_press_hook, e); }
int main(int argc, char **argv) { t_img *img; if (check_error(argc, argv[1])) { ft_putendl("Usage : ./fractol [Arg1]"); ft_putendl("Arg1 being \"Julia\" or \"Mandelbrot\" or \"Ship\""); return (1); } if (!(img = init_image())) ft_mlx_error(); if (argv[1][0] == 'm' || argv[1][0] == 'M') img->type = 'm'; else if (argv[1][0] == 's' || argv[1][0] == 'S') img->type = 's'; else if (argv[1][0] == 'j' || argv[1][0] == 'J') img->type = 'j'; mlx_hook(img->win_ptr, 2, 1L << 8, grab_key, img); mlx_expose_hook(img->win_ptr, grab_expose, img); mlx_hook(img->win_ptr, MOTION_NOTIFY, POINTER_MOTION, motion_notify, img); mlx_mouse_hook(img->win_ptr, mouse_hook, img); mlx_loop(img->mlx_ptr); return (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); }
int main(int argc, char **argv) { t_env e; t_cam cam; t_set settings; if (!argv[1] || argc != 2) { ft_putendl_fd("\033[1;33;40mWrong number of argument\033[0m", 2); ft_putstr_fd("Wolf3d : \n\t./wolf3d \033[1;32;40myour_map\033[0m", 2); ft_putendl_fd(" -> will start an arcade game with your map", 2); ft_putendl_fd("\t./wolf3d story -> will start the story mode", 2); return (0); } e.cam = &cam; e.set = &settings; e.file = ft_strdup(argv[1]); w_init(&e); w_check_out(&e); mlx_expose_hook(e.win, expose_hook, &e); mlx_hook(e.win, KeyPress, KeyPressMask, key_p, &e); mlx_hook(e.win, KeyRelease, KeyReleaseMask, key_r, &e); mlx_mouse_hook(e.win, mouse_hook, &e); mlx_loop_hook(e.mlx, &move, &e); mlx_loop(e.mlx); return (0); }
void gere_window(t_window *w) { mlx_put_image_to_window(w->mlx_ptr, w->win_ptr, w->img_ptr, 0, 0); mlx_hook(w->win_ptr, KeyPress, KeyPressMask, gere_key, w); mlx_expose_hook(w->win_ptr, gere_expose, w); mlx_loop(w->mlx_ptr); }
void init_kernel(t_env *e) { tread_function(acting, 0.1, e, 1); // mlx_hook(e->mlx, 0, 0, key_press, e); mlx_key_hook(e->win, key_release, e); mlx_expose_hook(e->win, expose_hook, e); }
int main(int ac, char **av) { t_fdf_ctx ctx; if (ac != 2) { fdf_usage(av[0]); return (-42); } ft_bzero(&ctx, sizeof(t_fdf_ctx)); ctx.win_h = FDF_WIN_H; ctx.win_w = FDF_WIN_W; fdf_parse_file(&ctx, av[1]); fdf_check_errors(&ctx); if ((ctx.map_len = ctx.map_w * ctx.map_h) == 0) return (-1); fdf_map_lst_to_array(&ctx); fdf_init_mlx(&ctx, av[1]); fdf_get_center(&ctx); fdf_adapt_map(&ctx); mlx_expose_hook(ctx.win, fdf_hook_expose, &ctx); mlx_key_hook(ctx.win, fdf_hook_keys, &ctx); fdf_commands(); mlx_loop(ctx.mlx); return (0); }
void fdf_read_files(int ac, char **av) { t_fdf_config *config; int i; t_list *list; t_fdf_window *window; config = fdf_get_config(ac, av); ft_putendl("Exited config"); ft_putnbr(config->window_count); i = 0; while (i < config->window_count) { config->current = i; window = config->windows[i]; if (!(list = fdf_read_file(window->fd))) fdf_exit(-50); fdf_add_vertical_lines(list); fdf_load_frame(list, window); mlx_key_hook(mlx_get_window(i)->window, fdf_key_hook, window); mlx_expose_hook(mlx_get_window(i)->window, fdf_expose_hook, window); i++; } }
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); }
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); }
int main(int ac, char **av) { t_ptr *ptr; t_col *color; t_sc *scene; if (ac > 1) my_parse(av[1]); (void)av; if (ac != 1) my_putstr_error(ARG_ERROR); if ((ptr = my_init()) == NULL) { my_putstr_error(INIT_ERROR); return (EXIT_ERROR); } if ((color = my_init_color(0, 0, 0)) == NULL) { my_putstr_error(INIT_ERROR); return (EXIT_ERROR); } if ((scene = my_init_scene()) == NULL) return (EXIT_ERROR); my_fill_image(ptr->pic, color, scene); mlx_expose_hook(ptr->win->ptr, &my_expose, ptr); mlx_key_hook(ptr->win->ptr, &my_key, ptr); mlx_loop(ptr->mlx); return (SUCCESS); }
void ft_mlx(t_env *e) { e->mlx = mlx_init(); e->win = mlx_new_window(e->mlx, SIZE, SIZE, "42"); mlx_expose_hook(e->win, expose_hook, e); mlx_key_hook(e->win, key_hook, e); mlx_loop(e->mlx); }
static void set_hooks(t_env *w) { mlx_expose_hook(w->win, expose_hook, w); mlx_mouse_hook(w->win, mouse_hook, w); mlx_hook(w->win, 2, 0, keypressed, w); mlx_hook(w->win, 3, 1, keyreleased, w); mlx_hook(w->win, 6, 1 << 6, motion_hook, w); }
void fdf(t_env e) { e.mlx = mlx_init(); e.win = mlx_new_window(e.mlx, e.x_win, e.y_win, "fdf 42"); mlx_expose_hook(e.win, expose_hook, &e); mlx_hook(e.win, 2, 3, key_hook, &e); mlx_loop(e.mlx); }
void init_hooks(t_env *e) { mlx_hook(e->win, 2, (1L << 7), &key_hook, e); mlx_loop_hook(e->core, &loop_hook, e); mlx_expose_hook(e->win, &expose_hook, e); mlx_mouse_hook(e->win, &mouse_hook, e); mlx_hook(e->win, 6, (1L << 6), mouse_move, e); }
void my_hook(t_system *sys) { mlx_hook(sys->win, KeyPress, KeyPressMask, &move_on, sys); mlx_hook(sys->win, KeyRelease, KeyReleaseMask, &move_off, sys); mlx_loop_hook(sys->mlx, key_move, sys); mlx_expose_hook(sys->win, &expose, sys); mlx_loop(sys->mlx); }
static void mlx(t_env *e) { mlx_expose_hook(e->win, raycaster, e); mlx_hook(e->win, KEYPRESS, KEYPRESSMASK, key_press, e); mlx_hook(e->win, KEYRELEASE, KEYRELEASEMASK, key_release, e); mlx_loop_hook(e->ptr, key_hook, e); mlx_do_key_autorepeatoff(e->ptr); mlx_loop(e->ptr); }
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(); }
static void event(t_var *var) { if (var != NULL) { mlx_expose_hook(var->win, gere_expose, var); mlx_key_hook(var->win, gere_key, var); mlx_loop(var->mlx); } }
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); }
void handle_second_win(void) { static int i = 0; mlx_hook(g()->p2.win, 6, 64, &mouse_hook, &g()->p2); mlx_key_hook(g()->p2.win, key_hook, &g()->p2); mlx_mouse_hook(g()->p2.win, mouse2_hook, &g()->p2); mlx_expose_hook(g()->p2.win, expose_hook, &g()->p2); if (i == 0) first_display_secwin(&i); }
static int fdf(t_env *e, char *win_name) { if (init_env(e, win_name) != 0) return (1); mlx_expose_hook(e->win, expose_hook, e); mlx_hook(e->win, 2, 0, key_hook, e); mlx_do_key_autorepeaton(e->mlx); mlx_loop_hook(e->mlx, loop_hook, e); mlx_loop(e->mlx); return (0); }