blob: 39e0bc6cc518290af55b2c6622c0dd7b6a7cd515 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#ifndef MGUI_ASYNC_IMAGE_H
#define MGUI_ASYNC_IMAGE_H
#include <mgl/graphics/image.h>
#include <mgl/graphics/texture.h>
#include <stdint.h>
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 */
|