void fractal_choice(char **argv, t_struct *mystruct) { if (ft_strequ(argv[1], "Julia") == 1) { mystruct->fracnum = 1; julia_init(mystruct); mlx_mouse_hook(mystruct->win, ft_zoom, mystruct); mlx_hook(mystruct->win, 6, (1L << 6), motion_julia, mystruct); } else if (ft_strequ(argv[1], "Mandel") == 1) { mystruct->fracnum = 2; mandel_init(mystruct); mlx_mouse_hook(mystruct->win, ft_zoom_mandel, mystruct); mlx_hook(mystruct->win, 6, (1L << 6), motion_mandel, mystruct); } else if (ft_strequ(argv[1], "Burning") == 1) { mystruct->fracnum = 3; burn_init(mystruct); mlx_mouse_hook(mystruct->win, ft_zoom_burning, mystruct); mlx_hook(mystruct->win, 6, (1L << 6), motion_burning, mystruct); } else error_arg(); }
void ft_initialisation(t_id *s) { s->test = 0; s->sol = -1; s->gun = -1; s->plafond = -1; s->display = 0; s->planex = 0; s->planey = 0.66; s->dirx = -1; s->diry = 0; s->level = 0; 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_xpm_textures(s); ft_corps(s); mlx_mouse_hook(s->win, mouse_reaction_click, s); mlx_key_hook(s->win, key_reaction, s); mlx_hook(s->win, 17, (1L << 17), red_cross, s); mlx_hook(s->win, KEYPRESS, KEYPRESSMASK, ft_movement, s); mlx_hook(s->win, MOTIONNOTIFY, POINTERMOTIOMMASK, mouse_reaction, s); mlx_loop(s->mlx); }
int main(void) { t_env e; e = *(t_env*)malloc(sizeof(t_env)); e.mlx = (void *)malloc(sizeof(void *)); e.win = (void *)malloc(sizeof(void *)); e.mlx = mlx_init(); e.win = mlx_new_window(e.mlx, WIN_WIDTH, WIN_HEIGH, "The Wolf"); e.img.img = (void *)malloc(4096); e.player.pos.x = 22; e.player.pos.y = 12; e.player.dir.x = -1; e.player.dir.y = 0; e.r.plane.x = 0; e.r.plane.y = 0.80; e.time = 0; e.oldtime = 0; read_file(&e); mlx_loop_hook(e.mlx, &loop_hook, &e); mlx_hook(e.win, 2, (1L << 0), &key_press, &e); mlx_hook(e.win, 3, (1L << 1), &key_release, &e); mlx_hook(e.win, 17, 0L, &quit, &e); mlx_loop(e.mlx); return (0); }
static void *start_fractal(void *data) { t_thread_info ti; int frac_set; frac_set = (int)data; ti.blk.r = 0; ti.blk.g = 0; ti.blk.b = 0; ti.blk.alpha = 0; ti.c = (t_co *)ft_memalloc(sizeof(t_co)); init_co_img(ti.c); ti.lock = 0; ti.show = 2; choose_set(frac_set, &ti); draw_set(ti.c->img, &ti.frac); IMG_TO_WINDOW(ti.c->mlx_ptr, ti.c->win_ptr, ti.c->img_ptr); mlx_hook(ti.c->win_ptr, KEYPRESS, 3, &handler_key, (void *)&ti); if (ti.frac.fract == JULIA) mlx_hook(ti.c->win_ptr, MOTNOTY, 1L << 6, &handler_julia, (void *)&ti); mlx_mouse_hook(ti.c->win_ptr, &handler_mouse, (void *)&ti); menu(ti.c); mlx_loop(ti.c->mlx_ptr); return (NULL); }
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); }
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); }
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); }
int main(int argc, char **argv) { t_struck s; t_pc *proc; unsigned long long i[3]; if (argc == 1) ft_usage(); init_struct(&s); proc = NULL; check_valid_file(&s, argv, 0); map_gen(&s, &proc, -1, i); s.pro = &proc; if (s.rep & GRAPH) { init_graph(&s); mlx_hook(s.img.win, 2, (1l << 0), key_functions, &s); mlx_hook(s.img.menu, 2, (1l << 0), key_functions, &s); s.rep ^= STOP; mlx_loop_hook(s.img.mlx, aff_graph, &s); mlx_loop(s.img.mlx); } else launching_vm(&s); return (0); }
int main(void) { t_glob *gl; t_bitmap *bmp; gl = (t_glob *)malloc(sizeof(t_glob)); if (!gl) return (0); bmp = (t_bitmap *)malloc(sizeof(t_bitmap)); if (!bmp) return (0); ft_init(gl); texture_grey(gl, bmp); texture_wood(gl, bmp); texture_me(gl, bmp); ft_skybox(gl, bmp); gl->mlx = mlx_init(); gl->win = mlx_new_window(gl->mlx, gl->s_x, gl->s_y, "Wolf 3D"); ft_wolf3d(gl); mlx_loop_hook(gl->mlx, ft_wolf3d, gl); mlx_hook(gl->win, 2, (1L << 0), ft_key_press, gl); mlx_hook(gl->win, 3, (1L << 1), ft_key_release, gl); mlx_hook(gl->win, 17, 0, ft_close, gl); mlx_loop(gl->mlx); return (0); }
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 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); }
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 do_mlx(t_fol *f) { mlx_hook(f->win, MotionNotify, PointerMotionMask, mouse_hook, f); mlx_hook(f->win, KeyPress, KeyPressMask, key_press, f); mlx_hook(f->win, KeyRelease, KeyReleaseMask, key_release, f); mlx_hook(f->win, ButtonPress, ButtonPressMask, button_press, f); mlx_loop_hook(f->mlx, fractol_core, f); mlx_loop(f->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 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 load_hooks(t_all *str_all) { mlx_hook(str_all->win_ptr, MotionNotify, PointerMotionMask, &mouse_move_hook, str_all); mlx_hook(str_all->win_ptr, ButtonPress, ButtonPressMask, &mouse_press, str_all); mlx_hook(str_all->win_ptr, ButtonRelease, ButtonReleaseMask, &mouse_release, str_all); mlx_hook(str_all->win_ptr, Expose, ExposureMask, &gere_expose, str_all); }
int main(int ac, char **av) { t_env env; init(&env, av, ac); mlx_key_hook(env.win, key_hook, &env); mlx_hook(env.win, ButtonPress, ButtonPressMask, mouse_press, &env); mlx_hook(env.win, MotionNotify, PointerMotionMask, mouse_motion, &env); mlx_loop_hook(env.ptr, loop_hook, &env); mlx_loop(env.ptr); return (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); }
void han_shot_first(t_init st, char *str) { st = init_all(st, str); resolution(st); mlx_hook(st.win, 2, 1, key_hook, &st); if (ft_strcmp(str, "Julia") == 0) mlx_hook(st.win, 6, (1L << 6), motion_hook, &st); mlx_mouse_hook(st.win, mouse_hook, &st); mlx_put_image_to_window(st.mlx, st.win, st.link, st.pos_x_image, st.pos_y_image); mlx_loop(st.mlx); }
void ft_pre_w3d(t_w3d *w3d) { w3d->mlx = ft_mlx_init(w3d->mlx, WIN_X, WIN_Y, "wolf3d"); ft_load_w3d_textures(w3d, w3d->mlx, &w3d->texture); w3d->cam.pos.y = w3d->spawn.x + 0.5; w3d->cam.pos.x = w3d->spawn.y + 0.5; ft_wolf3d(w3d); mlx_hook(w3d->mlx->p_win, KeyPress, KeyPressMask, ft_wolf_move, w3d); mlx_hook(w3d->mlx->p_win, KeyRelease, KeyPressMask, ft_release_key, w3d); mlx_hook(w3d->mlx->p_win, DestroyNotify, StructureNotifyMask, &red_x, w3d); mlx_loop_hook(w3d->mlx->p_mlx, ft_wolf3d_loop, w3d); mlx_loop(w3d->mlx->p_mlx); }
int events(t_game *game) { view(game); draw_mini_map(game); mlx_put_image_to_window(game->window->mlx_ptr, game->window->mlx_win, \ game->window->img, 0, 0); mlx_put_image_to_window(game->window->mlx_ptr, game->window->mlx_win,\ game->window->mini_map, 30, 30); init_keys(game); mlx_hook(game->window->mlx_win, KeyPress, KeyPressMask, &hook_press, game); mlx_hook(game->window->mlx_win, KeyRelease, KeyReleaseMask, &hook_release,\ game); mlx_loop_hook(game->window->mlx_ptr, &gere_key, game); mlx_loop(game->window->mlx_ptr); }
int main() { t_variable var; init_var(&var, laby); trace(&var); mlx_expose_hook(var.win_ptr, refresh, &var); mlx_hook(var.win_ptr, KeyPress, KeyPressMask, key, &var); mlx_hook(var.win_ptr, ButtonPress, ButtonPressMask, gun, &var); mlx_hook(var.win_ptr, MotionNotify, PointerMotionMask, mouse, &var); if (var.fd != -1) joystick(&var); else mlx_loop(var.mlx_ptr); return (0); }
int main(int ac, char **av) { t_all all; if (ac >= 2) { all.mlx = mlx_init(); all.win_x = (ac >= 4 && check_arg(av[2])) ? ft_atoi(av[2]) : 500; all.win_y = (ac >= 4 && check_arg(av[3])) ? ft_atoi(av[3]) : 500; all.win = mlx_new_window(all.mlx, all.win_x, all.win_y, "FdF"); init_all(&all); if (ac == 5) check_color(av[4], &all); all.fd = open(av[1], O_RDONLY); if (all.fd == -1) exit(EXIT_FAILURE); parser(all.fd, &all); mlx_hook(all.win, 2, (1L << 0), key_hook_first, &all); draw_map_x(&all); mlx_loop(all.mlx); } else help_main(); return (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); }
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 argc, char **argv) { t_env e; int i_x; int i_y; i_x = WIN_X * 2 / 5; i_y = WIN_Y * 2 / 5; if (argc == 2) { ft_parse(&e, argv[1]); ft_drawsettings(&e); e.mlx = mlx_init(); e.win = mlx_new_window(e.mlx, WIN_X, WIN_Y, "mlx42"); e.im = mlx_new_image(e.mlx, WIN_X, WIN_Y); e.imc = mlx_get_data_addr(e.im, &e.bpp, &e.imlen, &e.endi); mlx_string_put(e.mlx, e.win, i_x, i_y, 0xccccff, WELCOME); mlx_string_put(e.mlx, e.win, i_x + 16, i_y + 20, 0xccccff, START); mlx_hook(e.win, KEYPRESS, KEYPRESSMASK, ft_key_settings, &e); mlx_loop(e.mlx); } else ft_error("error : invalid number of arguments"); 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); }
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); }
void map_processing(t_e *e) { e->mlx = mlx_init(); e->win = mlx_new_window(e->mlx, WIN_W, WIN_H, WIN_N); e->ima = mlx_new_image(e->mlx, WIN_W, WIN_H); e->ima_data = mlx_get_data_addr( e->ima, &(e->ima_bits), &(e->ima_line), &(e->ima_endi)); e->grid = create_grid(e); reset(e); 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_hook(e->win, 17, (1L << 17), &end_exe, e); mlx_hook(e->win, 2, (1L << 0), &key_hook_press, e); mlx_loop(e->mlx); }
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); }