static void get_text_sequel(t_v_env *param, void *e) { T4.file = "./textures/4.xpm"; T4.img = mlx_xpm_file_to_image(e, T4.file, &T4.size_x, &T4.size_y); if (T4.img == NULL) v_exit("%r#20", 20); T4.data = mlx_get_data_addr(T4.img, &T4.bpp, &T4.sizeline, &T4.endian); T5.file = "./textures/5.xpm"; T5.img = mlx_xpm_file_to_image(e, T5.file, &T5.size_x, &T5.size_y); if (T5.img == NULL) v_exit("%r#20", 20); T5.data = mlx_get_data_addr(T5.img, &T5.bpp, &T5.sizeline, &T5.endian); T6.file = "./textures/6.xpm"; T6.img = mlx_xpm_file_to_image(e, T6.file, &T6.size_x, &T6.size_y); if (T6.img == NULL) v_exit("%r#20", 20); T6.data = mlx_get_data_addr(T6.img, &T6.bpp, &T6.sizeline, &T6.endian); T7.file = "./textures/7.xpm"; T7.img = mlx_xpm_file_to_image(e, T7.file, &T7.size_x, &T7.size_y); if (T7.img == NULL) v_exit("%r#20", 20); T7.data = mlx_get_data_addr(T7.img, &T7.bpp, &T7.sizeline, &T7.endian); T8.file = "./textures/8.xpm"; T8.img = mlx_xpm_file_to_image(e, T8.file, &T8.size_x, &T8.size_y); if (T8.img == NULL) v_exit("%r#20", 20); T8.data = mlx_get_data_addr(T8.img, &T8.bpp, &T8.sizeline, &T8.endian); }
int load_write_and_chack(t_param *param) { if ((param->check_ok.img = mlx_xpm_file_to_image(param->window.p, "texture/check_ok.xpm", &(param->check_ok.y), &(param->check_ok.x))) == NULL || (param->write.img = mlx_xpm_file_to_image(param->window.p, "texture/write.xpm", &(param->write.y), &(param->write.x))) == NULL || (param->hide.img = mlx_xpm_file_to_image(param->window.p, "texture/cache.xpm", &(param->hide.y), &(param->hide.x))) == NULL || (param->wrong.img = mlx_xpm_file_to_image(param->window.p, "texture/wrong.xpm", &(param->wrong.y), &(param->wrong.x))) == NULL) return (0); return (1); }
static void xpm_to_image(t_texture *tex, t_env *env) { int width; int height; tex->text1 = mlx_xpm_file_to_image(env->mlx, "./textures/wall1.xpm", &width, &height); tex->text2 = mlx_xpm_file_to_image(env->mlx, "./textures/wall2.xpm", &width, &height); tex->text3 = mlx_xpm_file_to_image(env->mlx, "./textures/wall3.xpm", &width, &height); tex->text4 = mlx_xpm_file_to_image(env->mlx, "./textures/wall4.xpm", &width, &height); tex->text5 = mlx_xpm_file_to_image(env->mlx, "./textures/kwiessle.xpm", &width, &height); tex->text6 = mlx_xpm_file_to_image(env->mlx, "./textures/psyche.xpm", &width, &height); tex->text7 = mlx_xpm_file_to_image(env->mlx, "./textures/vquesnel.xpm", &width, &height); tex->textsol = mlx_xpm_file_to_image(env->mlx, "./textures/floor.xpm", &width, &height); tex->textroof = mlx_xpm_file_to_image(env->mlx, "./textures/neon.xpm", &width, &height); if (!tex->text1 || !tex->text2 || !tex->text3 || !tex->text4 || !tex->text7 || !tex->text5 || !tex->text6 || !tex->textsol || !tex->textroof) ft_error("Error when extracting xpm files."); }
static void ft_load_img(t_display *d) { d->img->entity_img->img_xpm[0] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_1, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[1] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_2, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[2] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_3, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[3] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_4, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[4] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_5, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[5] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_6, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[6] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_7, &d->img->entity_img->w, &d->img->entity_img->h); d->img->entity_img->img_xpm[7] = mlx_xpm_file_to_image(d->mlx->mlx, IMG_ENTITY_LVL_8, &d->img->entity_img->w, &d->img->entity_img->h); }
void ft_init_dsbimg(t_env *e) { int w; w = 256; e->img_wall[25] = mlx_xpm_file_to_image(e->mlx, "images/w25.xpm", &w, &w); e->img_door[1] = mlx_xpm_file_to_image(e->mlx, "images/door1.xpm", &w, &w); e->img_door[3] = mlx_xpm_file_to_image(e->mlx, "images/door3.xpm", &w, &w); e->img_door[4] = mlx_xpm_file_to_image(e->mlx, "images/door4.xpm", &w, &w); e->img_door[5] = mlx_xpm_file_to_image(e->mlx, "images/door5.xpm", &w, &w); e->img_door[6] = mlx_xpm_file_to_image(e->mlx, "images/door6.xpm", &w, &w); e->img_door[7] = mlx_xpm_file_to_image(e->mlx, "images/door7.xpm", &w, &w); e->img_door[8] = mlx_xpm_file_to_image(e->mlx, "images/door8.xpm", &w, &w); e->img_sb[2] = mlx_xpm_file_to_image(e->mlx, "images/sb2.xpm", &w, &w); e->img_sb[3] = mlx_xpm_file_to_image(e->mlx, "images/sb3.xpm", &w, &w); }
void init_textures(t_mega *all) { t_text *text; int texture_nb; int nb; int i; i = 0; nb = SKYBOX + 1; init_weapon_hud(all); getfile2load(all, nb); while (i < nb) { text = &all->text[i]; text->img.img = mlx_xpm_file_to_image(all->e.mlx, text->filename, &text->w, &text->h); if (text->img.img == NULL) ft_error(4); text->img.data = mlx_get_data_addr(text->img.img, &text->img.bpp, &text->img.sizeline, &text->img.endian); if (!text->img.data) ft_error(4); free(text->filename); i++; } }
static void ft_load_img(t_display *d) { d->img->ground_img->img_xpm = mlx_xpm_file_to_image(d->mlx->mlx, IMG_GROUND, &d->img->ground_img->w, &d->img->ground_img->h); }
void load_texture(t_system *sys) { int i; i = -1; while (sys->obj[++i].type != -2) { if (sys->obj[i].tex.file) { my_putstr("Loading "); my_putstr(sys->obj[i].tex.file); my_putstr("\n"); sys->obj[i].tex.texture.img = mlx_xpm_file_to_image(sys->mlx, sys->obj[i].tex.file, &(sys->obj[i].tex.w), &(sys->obj[i].tex.h)); sys->obj[i].tex.texture.data = mlx_get_data_addr(sys->obj[i].tex.texture.img, &(sys->obj[i].tex.texture.bpp), &(sys->obj[i].tex.texture.sizeline), &(sys->obj[i].tex.texture.endian)); } else sys->obj[i].tex.texture.data = NULL; } }
int get_tex(t_env *env) { t_img *img; int i; char *tab[10]; int x2; int y2; tex(tab); i = 0; while (i < 10) { x2 = 0; y2 = 0; env->img[i] = (t_img *)malloc(sizeof(t_img)); img = env->img[i]; if (!(img->img = mlx_xpm_file_to_image(env->ptr, tab[i], &x2, &y2))) exit(0); if (!(img->data = mlx_get_data_addr(img->img, &(img->bpp), &(img->sizel), &(img->endian)))) exit(0); i++; } return (0); }
void w_set_texture(t_app *app, char *file_name, char num) { t_texture texture; t_obj *obj; int height; int width; obj = NULL; ft_bzero(&texture, sizeof(t_texture)); if ((obj = (t_obj *)ft_memalloc(sizeof(t_obj))) == NULL) ft_putstr_fd("Erreur d'allocation de t_obj\n", 2); obj->img = mlx_xpm_file_to_image(app->mlx, file_name, &width, &height); if (obj->img == NULL) return ; obj->data = mlx_get_data_addr(obj->img, &obj->bpp, &obj->sizeline, &obj->endian); texture.num = num; texture.x = 0; texture.y = 0; texture.width = width; texture.height = height; texture.obj = obj; ft_lstpush_front(&app->lst_texture, &texture, sizeof(t_texture)); }
void ray_tracer(t_env *e) { int x; int y; int a; int b; int c; int d; a = 0; b = 0; c = 0; d = 0; e->no = 0; e->sky = 0; e->img = (t_img *)malloc(sizeof(t_img) * 1); e->skybox = (t_img *)malloc(sizeof(t_img) * 1); e->sol = (t_img *)malloc(sizeof(t_img) * 1); e->img->img_ptr = mlx_new_image(e->mlx, e->width, e->height); e->img->data = mlx_get_data_addr(e->img->img_ptr, &e->img->bpp, &e->img->sizeline, &e->img->endian); e->skybox->img_ptr = mlx_xpm_file_to_image(e->mlx, "cart.xpm", &(c), &(d)); e->skybox->data = mlx_get_data_addr(e->skybox->img_ptr, &(e->skybox->bpp), &(e->skybox->sizeline), &(e->skybox->endian)); e->sol->img_ptr = mlx_xpm_file_to_image(e->mlx, "sol.xpm", &(a), &(b)); e->sol->data = mlx_get_data_addr(e->sol->img_ptr, &(e->sol->bpp), &(e->sol->sizeline), &(e->sol->endian)); y = 0; while (y < e->height) { e->y = y; x = 0; while (x < e->width) { e->s = 0; e->x = x; e->color = give_color(e, x, y); if(e->no == 0) pixel_put_to_img(e, x, y); e->no = 0; x++; } y++; } mlx_put_image_to_window(e->mlx, e->win, e->img->img_ptr, 0, 0); }
static t_img loadimage(t_mlxdata *data, char *path, int xsize, int ysize) { t_img img; img.size.x = xsize; img.size.y = ysize; img.ptr = (void *)mlx_xpm_file_to_image(data->env.mlx, path, &xsize, &ysize); return (img); }
int init_textures(t_env *e) { t_textures *wall; t_textures *floor; t_textures *ceil; wall = &e->wall; floor = &e->floor; ceil = &e->ceil; wall->img_ptr = mlx_xpm_file_to_image(e->mlx, WALL, &wall->x, &wall->y); floor->img_ptr = mlx_xpm_file_to_image(e->mlx, FLOOR, &floor->x, &floor->y); ceil->img_ptr = mlx_xpm_file_to_image(e->mlx, CEIL, &ceil->x, &ceil->y); if (!wall->img_ptr || !floor->img_ptr || !ceil->img_ptr) return (0); wall->img = MLX_DAT(wall->img_ptr, &wall->bpp, &wall->sl, &wall->end); floor->img = MLX_DAT(floor->img_ptr, &floor->bpp, &floor->sl, &floor->end); ceil->img = MLX_DAT(ceil->img_ptr, &ceil->bpp, &ceil->sl, &ceil->end); return (1); }
int init_texture(t_param *param) { if ((param->tab_texture_menu = malloc(sizeof(t_texture) * 24)) == NULL || load_texture(param) == 0 || (param->panel_control.img = mlx_xpm_file_to_image(param->window.p, "texture/panel_config.xpm", &(param->panel_control.y), &(param->panel_control.x))) == NULL || (param->textbox.img = mlx_xpm_file_to_image(param->window.p, "texture/textbox.xpm", &(param->textbox.y), &(param->textbox.x))) == NULL || load_write_and_chack(param) == 0 || load_texture_form(param) == 0) return (0); return (1); }
static void set_texture(t_env *e, t_texture *t, char *name) { if (!(t->i = mlx_xpm_file_to_image(e->mlx, name, &(t->wth), &(t->hgt)))) { ft_putstr("Texture \""); ft_putstr(name); ft_putendl("\" not found"); exit(1); } t->d = mlx_get_data_addr(t->i, &(t->bpp), &(t->sl), &(t->edn)); }
void ft_set_text(t_env *env, char *line, int nb_line) { env->text[nb_line] = (t_text*)malloc(sizeof(t_text)); env->text[nb_line]->data = (t_data*)malloc(sizeof(t_data)); env->text[nb_line]->img = mlx_xpm_file_to_image(env->mlx, line, &env->text[nb_line]->width, &env->text[nb_line]->height); env->text[nb_line]->data->addr = mlx_get_data_addr(env->text[nb_line]->img, &env->text[nb_line]->data->bpp, &env->text[nb_line]->data->sl, &env->text[nb_line]->data->end); }
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); }
t_img *new_xpm(t_mlx *mlx, int w, int h) { t_img *img; if (!(img = (t_img *)malloc(sizeof(*img)))) str_exit(-1, "new.c : Error line 55", mlx); if (!(img->img = mlx_xpm_file_to_image(mlx->mlx, "skybox.xpm", &w, &h))) str_exit(-1, "No skybox", mlx); img->addr = mlx_get_data_addr(img->img, &(img->bpp), &(img->size_l), &(img->endian)); return (img); }
void ft_init_textures(t_ba *ba) { ft_init_struct_text(ba); ba->eye->x = WD_W; ba->eye->y = WD_H; ba->eye->img = mlx_xpm_file_to_image(ba->mlx, "texture/eye.xpm", &ba->eye->x, &ba->eye->y); ba->eye->data = mlx_get_data_addr(ba->eye->img, &ba->eye->bpp, &ba->eye->size, &ba->eye->endian); ba->mars->x = WD_W; ba->mars->y = WD_H; ba->mars->img = mlx_xpm_file_to_image(ba->mlx, "texture/mars.xpm", &ba->mars->x, &ba->mars->y); ba->mars->data = mlx_get_data_addr(ba->mars->img, &ba->mars->bpp, &ba->mars->size, &ba->mars->endian); ba->doge->x = WD_W; ba->doge->y = WD_H; ba->doge->img = mlx_xpm_file_to_image(ba->mlx, "texture/doge.xpm", &ba->doge->x, &ba->doge->y); ba->doge->data = mlx_get_data_addr(ba->doge->img, &ba->doge->bpp, &ba->doge->size, &ba->doge->endian); }
void ft_static_xpm(t_id *s) { int i; int j; if (s->gun == 1) mlx_put_image_to_window(s->mlx, s->win, GU, W_X / 2, DE); if (s->map[(int)s->posx][(int)s->posy] == 2) { s->tp = malloc(sizeof(void*)); s->tp = mlx_xpm_file_to_image(s->mlx, "Textures/tp.xpm", &i, &j); mlx_put_image_to_window(s->mlx, s->win, s->tp, WX2, W_Y / 2 - 100); } }
void get_textures(t_v_env *param, void *e) { T0.file = "./textures/0.xpm"; T0.img = mlx_xpm_file_to_image(e, T0.file, &T0.size_x, &T0.size_y); if (T0.img == NULL) v_exit("%r#20", 20); T0.data = mlx_get_data_addr(T0.img, &T0.bpp, &T0.sizeline, &T0.endian); T1.file = "./textures/1.xpm"; T1.img = mlx_xpm_file_to_image(e, T1.file, &T1.size_x, &T1.size_y); if (T1.img == NULL) v_exit("%r#20", 20); T1.data = mlx_get_data_addr(T1.img, &T1.bpp, &T1.sizeline, &T1.endian); T2.file = "./textures/2.xpm"; T2.img = mlx_xpm_file_to_image(e, T2.file, &T2.size_x, &T2.size_y); if (T2.img == NULL) v_exit("%r#20", 20); T2.data = mlx_get_data_addr(T2.img, &T2.bpp, &T2.sizeline, &T2.endian); T3.file = "./textures/3.xpm"; T3.img = mlx_xpm_file_to_image(e, T3.file, &T3.size_x, &T3.size_y); if (T3.img == NULL) v_exit("%r#20", 20); T3.data = mlx_get_data_addr(T3.img, &T3.bpp, &T3.sizeline, &T3.endian); get_text_sequel(param, e); }
t_img *ft_load_img(void *mlx, char *src) { t_img *i; if (!src || !(i = (t_img*)malloc(sizeof(t_img)))) return (NULL); if (!(i->img = mlx_xpm_file_to_image(mlx, src, &(i->width), &(i->height)))) return (NULL); i->data = mlx_get_data_addr(i->img, &(i->bpp), &(i->sizeline), &(i->endian)); i->sl_div = i->sizeline / 4; i->bpp_div = i->bpp / 8 / 4; i->udata = (unsigned int*)i->data; return (i); }
int load_each_texture(t_each_text *texture, char *path, t_data *data) { texture->texture = mlx_xpm_file_to_image(data->windo.mlx_ptr, path, &(texture->size_x), &(texture->size_y)); if (texture->texture == NULL) return (FAIL); texture->data = mlx_get_data_addr(texture->texture, &(texture->bpp), &(texture->sizeline), &(texture->endian)); return (SUCCES); }
static void level_image(t_env *e) { void *xpm; int lar; int lon; ft_bzero(e->str, LON * LAR * 4); mlx_put_image_to_window(e->mlx, e->win, e->img, 0, 0); xpm = mlx_xpm_file_to_image (e->mlx, e->stage->lvl, &lar, &lon); mlx_put_image_to_window(e->mlx, e->win, xpm, LAR / 2 - lar / 2, LON / 2 - lon / 2); mlx_put_image_to_window(e->mlx, e->win, xpm, LAR / 2 - lar / 2, LON / 2 - lon / 2); sleep(1); }
void create_img(t_env *e, t_coord dim, char *file, t_coord pos) { int x; int y; x = (int)dim.x; y = (int)dim.y; if (e->img) { free(e->img); e->img = NULL; } e->img = mlx_new_image(e->mlx, x, y); e->img = mlx_xpm_file_to_image(e->mlx, file, &x, &y); mlx_put_image_to_window(e->mlx, e->win, e->img, pos.x, pos.y); }
int main() { int fd; void *img; void *mlx; void *win; int c; int v; c = 900; v = 800; mlx = mlx_init(); win = mlx_new_window(mlx, 900, 800, "cacac"); img = mlx_xpm_file_to_image(mlx, "lol.xpm", &c, &v); mlx_put_image_to_window(mlx, win, img, 0, 0); mlx_loop(mlx); }
int load_texture(t_param *param) { int indice; indice = -1; while (++indice < 24) if ((param->tab_texture_menu[indice].img = mlx_xpm_file_to_image(param->window.p, get_texture_menu(indice), &(param->tab_texture_menu[indice].y), &(param->tab_texture_menu[indice].x))) == NULL) { my_putstr("Error load texture : ", 2, -1); my_putstr(get_texture_menu(indice), 2, -1); my_putstr("\n", 2, -1); return (0); } return (1); }
void rec_texture_file(t_tex *tex, char *ret, void *mlx) { char *name; int endian; int bpp; int sizeline; name = rec_name(ret); tex->type = 0; if ((tex->img = mlx_xpm_file_to_image(mlx, name, &tex->width, &tex->height)) == NULL) { tex->type = 1; tex->proc_type = 0; } else tex->data = mlx_get_data_addr(tex->img, &bpp, &sizeline, &endian); if (name != NULL) free(name); }
void init_texture(t_env *e) { int i; printf("llaa init texture\n"); e->tex = malloc(sizeof(t_image) * 63); e->file = malloc(sizeof(char *) * 63); init_texture_parser1(e); init_texture_parser2(e); init_texture_parser3(e); i = 0; while (++i < 63) { e->tex[i].i = mlx_xpm_file_to_image(e->mlx, e->file[i], &e->tex[i].width, &e->tex[i].height); if (e->tex[i].i == NULL) texture_error(); e->tex[i].data = mlx_get_data_addr(e->tex[i].i, &e->tex[i].bpp, &e->tex[i].szline, &e->tex[i].endian); } }
int load_texture_form(t_param *param) { int indice; if ((param->tab_texture_form = malloc(sizeof(t_texture) * 11)) == NULL) return (0); indice = -1; while (++indice < 11) if ((param->tab_texture_form[indice].img = mlx_xpm_file_to_image(param->window.p, get_texture_form(indice), &(param->tab_texture_form[indice].y), &(param->tab_texture_form[indice].x))) == NULL) { my_putstr("Error load texture : ", 2, -1); my_putstr(get_texture_form(indice), 2, -1); my_putstr("\n", 2, -1); return (0); } return (1); }