libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
resourcebridge.h
Go to the documentation of this file.
1#pragma once
2
3#include "stdint.h"
4#include "ship/Api.h"
5
6#ifdef __cplusplus
9#include <memory>
10namespace Ship {
11class ResourceManager;
12}
13void ResourceSetResourceManager(std::shared_ptr<Ship::ResourceManager> resourceManager);
14std::shared_ptr<Ship::ResourceManager> ResourceGetResourceManager();
15
21std::shared_ptr<Ship::IResource> ResourceLoad(const char* name);
22
28std::shared_ptr<Ship::IResource> ResourceLoad(uint64_t crc);
29
36template <class T> std::shared_ptr<T> ResourceLoad(const char* name) {
37 return std::static_pointer_cast<T>(ResourceLoad(name));
38}
39
46template <class T> std::shared_ptr<T> ResourceLoad(uint64_t crc) {
47 return std::static_pointer_cast<T>(ResourceLoad(crc));
48}
49
50extern "C" {
51#endif
52
54API_EXPORT uint64_t ResourceGetCrcByName(const char* name);
55
57API_EXPORT const char* ResourceGetNameByCrc(uint64_t crc);
58
60API_EXPORT size_t ResourceGetSizeByName(const char* name);
61
63API_EXPORT size_t ResourceGetSizeByCrc(uint64_t crc);
64
68API_EXPORT uint8_t ResourceGetIsCustomByName(const char* name);
69
74
81API_EXPORT void* ResourceGetDataByName(const char* name);
82
84API_EXPORT void* ResourceGetDataByCrc(uint64_t crc);
85
87API_EXPORT uint16_t ResourceGetTexWidthByName(const char* name);
88
90API_EXPORT uint16_t ResourceGetTexWidthByCrc(uint64_t crc);
91
93API_EXPORT uint16_t ResourceGetTexHeightByName(const char* name);
94
97
99API_EXPORT size_t ResourceGetTexSizeByName(const char* name);
100
103
108API_EXPORT void ResourceLoadDirectory(const char* name);
109
115
120API_EXPORT void ResourceDirtyDirectory(const char* name);
121
123API_EXPORT void ResourceDirtyByName(const char* name);
124
127
129API_EXPORT void ResourceUnloadByName(const char* name);
130
133
138API_EXPORT void ResourceUnloadDirectory(const char* name);
139
142
149API_EXPORT void ResourceGetGameVersions(uint32_t* versions, size_t versionsSize, size_t* versionsCount);
150
155API_EXPORT uint32_t ResourceHasGameVersion(uint32_t hash);
156
159
160#ifdef __cplusplus
161};
162#endif
API export/import macros for cross-platform shared library symbol visibility.
#define API_EXPORT
Marks a symbol for export from (or import into) a shared library.
Definition Api.h:32
Core namespace for the libultraship engine framework.
Definition gfx_direct3d_common.h:14
API_EXPORT uint64_t ResourceGetCrcByName(const char *name)
Returns the 64-bit CRC that corresponds to the given resource path.
API_EXPORT uint16_t ResourceGetTexWidthByCrc(uint64_t crc)
Returns the texture width in pixels for the texture resource at crc.
API_EXPORT uint16_t ResourceGetTexWidthByName(const char *name)
Returns the texture width in pixels for the texture resource at name.
API_EXPORT void ResourceDirtyDirectory(const char *name)
Marks all resources under name as dirty so they are reloaded on next access.
API_EXPORT void ResourceUnloadByCrc(uint64_t crc)
Evicts the resource with the given CRC from the resource cache.
API_EXPORT void ResourceDirtyByCrc(uint64_t crc)
Marks the resource at crc as dirty so it is reloaded on next access.
std::shared_ptr< Ship::IResource > ResourceLoad(const char *name)
Loads a resource by its virtual path and returns a type-erased shared pointer.
API_EXPORT uint16_t ResourceGetTexHeightByName(const char *name)
Returns the texture height in pixels for the texture resource at name.
API_EXPORT size_t ResourceGetTexSizeByName(const char *name)
Returns the total texture data size in bytes for the texture at name.
API_EXPORT size_t ResourceGetTexSizeByCrc(uint64_t crc)
Returns the total texture data size in bytes for the texture at crc.
API_EXPORT void ResourceDirtyByName(const char *name)
Marks the resource at name as dirty so it is reloaded on next access.
API_EXPORT uint8_t ResourceGetIsCustomByCrc(uint64_t crc)
Returns non-zero if the resource at crc originates from a custom/mod archive.
API_EXPORT uint32_t IsResourceManagerLoaded()
Returns non-zero if the ResourceManager has been fully initialised and is ready.
API_EXPORT void ResourceUnloadByName(const char *name)
Evicts the resource with the given path from the resource cache.
API_EXPORT uint32_t ResourceHasGameVersion(uint32_t hash)
Returns non-zero if the given version hash is present in the loaded archives.
API_EXPORT uint8_t ResourceGetIsCustomByName(const char *name)
Returns non-zero if the resource at name originates from a custom/mod archive.
API_EXPORT void ResourceLoadDirectoryAsync(const char *name)
Queues all resources under name for background loading.
API_EXPORT const char * ResourceGetNameByCrc(uint64_t crc)
Returns the virtual path string that corresponds to the given 64-bit CRC.
API_EXPORT void ResourceClearCache()
Evicts all resources from the resource cache.
API_EXPORT void * ResourceGetDataByCrc(uint64_t crc)
Returns a raw pointer to the resource's data buffer by CRC.
void ResourceSetResourceManager(std::shared_ptr< Ship::ResourceManager > resourceManager)
API_EXPORT uint16_t ResourceGetTexHeightByCrc(uint64_t crc)
Returns the texture height in pixels for the texture resource at crc.
API_EXPORT void ResourceUnloadDirectory(const char *name)
Evicts all resources whose paths begin with name from the resource cache.
API_EXPORT size_t ResourceGetSizeByCrc(uint64_t crc)
Returns the raw data size in bytes of the resource with the given CRC.
API_EXPORT void ResourceGetGameVersions(uint32_t *versions, size_t versionsSize, size_t *versionsCount)
Retrieves the list of game version hashes present in the loaded archives.
API_EXPORT size_t ResourceGetSizeByName(const char *name)
Returns the raw data size in bytes of the resource with the given path.
API_EXPORT void ResourceLoadDirectory(const char *name)
Synchronously loads all resources whose paths begin with name.
API_EXPORT void * ResourceGetDataByName(const char *name)
Returns a raw pointer to the resource's data buffer by path.
std::shared_ptr< Ship::ResourceManager > ResourceGetResourceManager()