aboutsummaryrefslogtreecommitdiff
path: root/headers/TZR_resource.h
blob: 06f076300b51cc5ec132362951bb1879999829d9 (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
#pragma once
#include "TZR_types.h"

/* Return 0 on error. */
[[nodiscard]]
TZR_Uint TZR_LoadResourceFromMemory(TZR_ResourceType type, const void *data, int size);
[[nodiscard]]
TZR_Uint TZR_LoadResourceTyped(TZR_ResourceType type, const char *path);

/* Return 0 on error; try to autodetect resource type from file extension. */
[[nodiscard]]
TZR_Uint TZR_LoadResource(const char *path);

/* Doesn't handle invalid ID. Pointer might get invalidated by resource
 * creation calls, use with caution. */
TZR_Resource *TZR_GetResourcePointer(TZR_Uint id);

/* Doesn't handle invalid ID. Pointer might get invalidated by resource
 * creation calls, use with caution. */
TZR_Raw *TZR_GetRawResource(TZR_Uint id);

/* Doesn't handle invalid ID. */
TZR_ResourceType TZR_GetResourceType(TZR_Uint id);

/* Doesn't handle invalid ID. */
const char *TZR_GetResourcePath(TZR_Uint id);

/* Doesn't handle invalid ID. */
int TZR_GetImageWidth(TZR_Uint id);

/* Doesn't handle invalid ID. */
int TZR_GetImageHeight(TZR_Uint id);

/* Reload ressource. Returns -1 on error and doesn't apply changes. */
int TZR_ReloadResource(TZR_Uint id);

/* Watch for changes on managed resources and hotreload if appropriate. */
void TZR_ResourcesWatch(void);

/* Used internaly. */
[[nodiscard]]
int TZR_DirectResourceLoad(TZR_Resource *res, const void *data, int size);
void TZR_DestroyResource(TZR_Resource *res, int free_path);