void ft_load_entity_img(t_display *d) { if ((d->img->entity_img = malloc(sizeof(t_entity_img))) == NULL) exit(EXIT_FAILURE); ft_load_img(d); ft_load_addr(d); }
t_texture const *load_texture(t_sub file_name, uint32_t flags) { t_hmap *const cache = texture_cache(); char key[sizeof(uint32_t) + file_name.length]; t_texture *texture; *(uint32_t*)key = flags; ft_memcpy(key + sizeof(uint32_t), file_name.str, file_name.length); if ((texture = ft_hmapget(cache, SUBV(key)).value) != NULL) { ft_logf(LOG_DEBUG, "Cached texture: %ts", file_name); return (texture); } texture = ft_hmapput(cache, SUBV(key), NULL, sizeof(t_texture)).value; texture->get = &texture_bilinear; if (!ft_load_img(file_name, &texture->img)) { ft_logf(LOG_VERBOSE, "Failed to load '%ts'", file_name); ft_hmaprem(cache, SUBV(key), NULL); return (NULL); } if (flags & TEXTURE_GAMMA) correct_gamma(&texture->img); ft_logf(LOG_VERBOSE, "Texture file '%ts' loaded", file_name); return (texture); }
void ft_load_ground_img(t_display *d) { if ((d->img->ground_img = malloc(sizeof(t_ground_img))) == NULL) exit(EXIT_FAILURE); ft_load_img(d); ft_load_addr(d); ft_load_type_ground(d); }