#ifndef MGUI_ASYNC_IMAGE_H #define MGUI_ASYNC_IMAGE_H #include #include #include typedef struct mgui_async_image mgui_async_image; typedef enum { MGUI_ASYNC_IMAGE_NOT_LOADED, MGUI_ASYNC_IMAGE_LOADING, MGUI_ASYNC_IMAGE_LOADED, MGUI_ASYNC_IMAGE_APPLIED, MGUI_ASYNC_IMAGE_FAILED_TO_LOAD, MGUI_ASYNC_IMAGE_UNLOADED } mgui_async_image_state; struct mgui_async_image { mgl_image image; mgl_texture texture; uint64_t hash; mgui_async_image_state state; uint32_t updated; uint32_t ref_count; char *filepath; }; /* Do not call this manually */ void mgui_async_image_init(void); /* Do not call this manually */ void mgui_async_image_deinit(void); /* Do not call this manually */ void mgui_async_image_unload_unreferenced(void); /* Increases reference count by 1 every time this is called. Call |mgui_async_image_unref| when done with the image so it can be unloaded when all references are gone. */ mgui_async_image* mgui_async_image_get_by_path(const char *filepath); /* Needs to be called at least once a frame to keep the image from being unloaded */ void mgui_async_image_update(mgui_async_image *self); void mgui_async_image_unref(mgui_async_image *self); #endif /* MGUI_ASYNC_IMAGE_H */