void fs_emu_initialize_textures() { if (g_fs_emu_theme.width == 0) { fs_emu_fatal("theme is not initialized yet"); } //g_atlas = fs_emu_texture_new_from_file("atlas"); fs_image *image = fs_image_new(); image->width = 1024; image->height = 1024; image->format = FS_IMAGE_FORMAT_RGBA; image->data = fs_malloc0(1024 * 1024 * 4); initialize_atlas(image); g_atlas = fs_new(fs_emu_texture, 1); g_atlas->width = image->width; g_atlas->height = image->height; g_atlas->image = image; load_texture(g_atlas); fs_emu_set_texture(g_atlas); fs_gl_add_context_notification(context_notification_handler, g_atlas); if (g_fs_emu_theme.overlay_image[0]) { char *path = fs_emu_theme_get_resource(g_fs_emu_theme.overlay_image); fs_log("g_fs_emu_theme.overlay_image %s => %s\n", g_fs_emu_theme.overlay_image, path); if (path) { g_fs_emu_overlay_texture = fs_emu_texture_new_from_file(path); } } for (int i = 0; i < FS_EMU_MAX_OVERLAYS; i++) { for (int j = 0; j < FS_EMU_MAX_OVERLAY_STATES; j++) { fs_emu_texture *tex = NULL; char *name = fs_strdup_printf("custom_%d_%d.png", i - FS_EMU_FIRST_CUSTOM_OVERLAY, j); char *path = fs_emu_theme_get_resource(name); if (!path && g_fs_emu_theme.overlays[i].name) { free(name); name = fs_strdup_printf("%s_%d.png", g_fs_emu_theme.overlays[i].name, j); path = fs_emu_theme_get_resource(name); } if (path) { tex = fs_emu_texture_new_from_file(path); g_fs_emu_theme.overlays[i].textures[j] = tex; free(path); } else if (j == 1) { char *base_name = fs_strdup_printf("custom_%d.png", i - FS_EMU_FIRST_CUSTOM_OVERLAY); path = fs_emu_theme_get_resource(base_name); if (!path && g_fs_emu_theme.overlays[i].name) { free(name); name = fs_strdup_printf("%s.png", g_fs_emu_theme.overlays[i].name); path = fs_emu_theme_get_resource(name); } if (path) { tex = fs_emu_texture_new_from_file(path); g_fs_emu_theme.overlays[i].textures[j] = tex; free(path); } free(base_name); } else if (j >= 2) { g_fs_emu_theme.overlays[i].textures[j] = \ g_fs_emu_theme.overlays[i].textures[j - 1]; } free(name); // size will be determined from the last loaded texture/state // for the overlay if (tex) { g_fs_emu_theme.overlays[i].w = (double) tex->width / g_fs_emu_theme.width; g_fs_emu_theme.overlays[i].h = (double) tex->height / g_fs_emu_theme.height; } } } }
void fs_emu_initialize_textures() { g_atlas = fs_emu_texture_new_from_file("atlas"); }