libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
resourcebridge.h File Reference
#include "stdint.h"
#include "ship/Api.h"
#include "fast/resource/type/Texture.h"
#include "ship/resource/Resource.h"
#include <memory>
Include dependency graph for resourcebridge.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

namespace  Ship
 Core namespace for the libultraship engine framework.
 

Functions

void ResourceSetResourceManager (std::shared_ptr< Ship::ResourceManager > resourceManager)
 
std::shared_ptr< Ship::ResourceManagerResourceGetResourceManager ()
 
std::shared_ptr< Ship::IResourceResourceLoad (const char *name)
 Loads a resource by its virtual path and returns a type-erased shared pointer.
 
std::shared_ptr< Ship::IResourceResourceLoad (uint64_t crc)
 Loads a resource by its 64-bit CRC and returns a type-erased shared pointer.
 
template<class T >
std::shared_ptr< T > ResourceLoad (const char *name)
 Loads a resource by its virtual path and casts it to the requested type.
 
template<class T >
std::shared_ptr< T > ResourceLoad (uint64_t crc)
 Loads a resource by CRC and casts it to the requested type.
 
API_EXPORT uint64_t ResourceGetCrcByName (const char *name)
 Returns the 64-bit CRC that corresponds to the given resource path.
 
API_EXPORT const char * ResourceGetNameByCrc (uint64_t crc)
 Returns the virtual path string that corresponds to the given 64-bit CRC.
 
API_EXPORT size_t ResourceGetSizeByName (const char *name)
 Returns the raw data size in bytes of the resource with the given path.
 
API_EXPORT size_t ResourceGetSizeByCrc (uint64_t crc)
 Returns the raw data size in bytes of the resource with the given CRC.
 
API_EXPORT uint8_t ResourceGetIsCustomByName (const char *name)
 Returns non-zero if the resource at name originates from a custom/mod archive.
 
API_EXPORT uint8_t ResourceGetIsCustomByCrc (uint64_t crc)
 Returns non-zero if the resource at crc originates from a custom/mod archive.
 
API_EXPORT void * ResourceGetDataByName (const char *name)
 Returns a raw pointer to the resource's data buffer by path.
 
API_EXPORT void * ResourceGetDataByCrc (uint64_t crc)
 Returns a raw pointer to the resource's data buffer by CRC.
 
API_EXPORT uint16_t ResourceGetTexWidthByName (const char *name)
 Returns the texture width in pixels for the texture resource at name.
 
API_EXPORT uint16_t ResourceGetTexWidthByCrc (uint64_t crc)
 Returns the texture width in pixels for the texture resource at crc.
 
API_EXPORT uint16_t ResourceGetTexHeightByName (const char *name)
 Returns the texture height in pixels for the texture resource at name.
 
API_EXPORT uint16_t ResourceGetTexHeightByCrc (uint64_t crc)
 Returns the texture height in pixels for the texture resource at crc.
 
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 ResourceLoadDirectory (const char *name)
 Synchronously loads all resources whose paths begin with name.
 
API_EXPORT void ResourceLoadDirectoryAsync (const char *name)
 Queues all resources under name for background loading.
 
API_EXPORT void ResourceDirtyDirectory (const char *name)
 Marks all resources under name as dirty so they are reloaded on next access.
 
API_EXPORT void ResourceDirtyByName (const char *name)
 Marks the resource at name as dirty so it is reloaded on next access.
 
API_EXPORT void ResourceDirtyByCrc (uint64_t crc)
 Marks the resource at crc as dirty so it is reloaded on next access.
 
API_EXPORT void ResourceUnloadByName (const char *name)
 Evicts the resource with the given path from the resource cache.
 
API_EXPORT void ResourceUnloadByCrc (uint64_t crc)
 Evicts the resource with the given CRC from the resource cache.
 
API_EXPORT void ResourceUnloadDirectory (const char *name)
 Evicts all resources whose paths begin with name from the resource cache.
 
API_EXPORT void ResourceClearCache ()
 Evicts all resources from the resource cache.
 
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 uint32_t ResourceHasGameVersion (uint32_t hash)
 Returns non-zero if the given version hash is present in the loaded archives.
 
API_EXPORT uint32_t IsResourceManagerLoaded ()
 Returns non-zero if the ResourceManager has been fully initialised and is ready.
 

Function Documentation

◆ IsResourceManagerLoaded()

API_EXPORT uint32_t IsResourceManagerLoaded ( )

Returns non-zero if the ResourceManager has been fully initialised and is ready.

◆ ResourceClearCache()

API_EXPORT void ResourceClearCache ( )

Evicts all resources from the resource cache.

◆ ResourceDirtyByCrc()

API_EXPORT void ResourceDirtyByCrc ( uint64_t  crc)

Marks the resource at crc as dirty so it is reloaded on next access.

◆ ResourceDirtyByName()

API_EXPORT void ResourceDirtyByName ( const char *  name)

Marks the resource at name as dirty so it is reloaded on next access.

◆ ResourceDirtyDirectory()

API_EXPORT void ResourceDirtyDirectory ( const char *  name)

Marks all resources under name as dirty so they are reloaded on next access.

Parameters
nameDirectory prefix or exact path.

◆ ResourceGetCrcByName()

API_EXPORT uint64_t ResourceGetCrcByName ( const char *  name)

Returns the 64-bit CRC that corresponds to the given resource path.

◆ ResourceGetDataByCrc()

API_EXPORT void * ResourceGetDataByCrc ( uint64_t  crc)

Returns a raw pointer to the resource's data buffer by CRC.

◆ ResourceGetDataByName()

API_EXPORT void * ResourceGetDataByName ( const char *  name)

Returns a raw pointer to the resource's data buffer by path.

The pointer is valid as long as the resource remains loaded; do not cache it across frames without also holding a reference to the resource.

◆ ResourceGetGameVersions()

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.

Parameters
versionsCaller-supplied array to receive the version hashes.
versionsSizeCapacity of versions (number of elements).
versionsCountSet to the actual number of versions written to versions.

◆ ResourceGetIsCustomByCrc()

API_EXPORT uint8_t ResourceGetIsCustomByCrc ( uint64_t  crc)

Returns non-zero if the resource at crc originates from a custom/mod archive.

◆ ResourceGetIsCustomByName()

API_EXPORT uint8_t ResourceGetIsCustomByName ( const char *  name)

Returns non-zero if the resource at name originates from a custom/mod archive.

◆ ResourceGetNameByCrc()

API_EXPORT const char * ResourceGetNameByCrc ( uint64_t  crc)

Returns the virtual path string that corresponds to the given 64-bit CRC.

◆ ResourceGetResourceManager()

std::shared_ptr< Ship::ResourceManager > ResourceGetResourceManager ( )

◆ ResourceGetSizeByCrc()

API_EXPORT size_t ResourceGetSizeByCrc ( uint64_t  crc)

Returns the raw data size in bytes of the resource with the given CRC.

◆ ResourceGetSizeByName()

API_EXPORT size_t ResourceGetSizeByName ( const char *  name)

Returns the raw data size in bytes of the resource with the given path.

◆ ResourceGetTexHeightByCrc()

API_EXPORT uint16_t ResourceGetTexHeightByCrc ( uint64_t  crc)

Returns the texture height in pixels for the texture resource at crc.

◆ ResourceGetTexHeightByName()

API_EXPORT uint16_t ResourceGetTexHeightByName ( const char *  name)

Returns the texture height in pixels for the texture resource at name.

◆ ResourceGetTexSizeByCrc()

API_EXPORT size_t ResourceGetTexSizeByCrc ( uint64_t  crc)

Returns the total texture data size in bytes for the texture at crc.

◆ ResourceGetTexSizeByName()

API_EXPORT size_t ResourceGetTexSizeByName ( const char *  name)

Returns the total texture data size in bytes for the texture at name.

◆ ResourceGetTexWidthByCrc()

API_EXPORT uint16_t ResourceGetTexWidthByCrc ( uint64_t  crc)

Returns the texture width in pixels for the texture resource at crc.

◆ ResourceGetTexWidthByName()

API_EXPORT uint16_t ResourceGetTexWidthByName ( const char *  name)

Returns the texture width in pixels for the texture resource at name.

◆ ResourceHasGameVersion()

API_EXPORT uint32_t ResourceHasGameVersion ( uint32_t  hash)

Returns non-zero if the given version hash is present in the loaded archives.

Parameters
hashVersion hash to search for.

◆ ResourceLoad() [1/4]

std::shared_ptr< Ship::IResource > ResourceLoad ( const char *  name)

Loads a resource by its virtual path and returns a type-erased shared pointer.

Parameters
nameVirtual path of the resource within the archive (e.g. "textures/foo.png").
Returns
Shared pointer to the loaded IResource, or nullptr on failure.

◆ ResourceLoad() [2/4]

template<class T >
std::shared_ptr< T > ResourceLoad ( const char *  name)

Loads a resource by its virtual path and casts it to the requested type.

Template Parameters
TExpected resource type (e.g. Fast::Texture).
Parameters
nameVirtual resource path.
Returns
Shared pointer to T, or nullptr if the resource could not be loaded or cast.

◆ ResourceLoad() [3/4]

std::shared_ptr< Ship::IResource > ResourceLoad ( uint64_t  crc)

Loads a resource by its 64-bit CRC and returns a type-erased shared pointer.

Parameters
crc64-bit CRC of the resource path.
Returns
Shared pointer to the loaded IResource, or nullptr on failure.

◆ ResourceLoad() [4/4]

template<class T >
std::shared_ptr< T > ResourceLoad ( uint64_t  crc)

Loads a resource by CRC and casts it to the requested type.

Template Parameters
TExpected resource type.
Parameters
crc64-bit CRC of the resource path.
Returns
Shared pointer to T, or nullptr on failure.

◆ ResourceLoadDirectory()

API_EXPORT void ResourceLoadDirectory ( const char *  name)

Synchronously loads all resources whose paths begin with name.

Parameters
nameDirectory prefix (e.g. "textures/") or exact path.

◆ ResourceLoadDirectoryAsync()

API_EXPORT void ResourceLoadDirectoryAsync ( const char *  name)

Queues all resources under name for background loading.

Parameters
nameDirectory prefix or exact path.

◆ ResourceSetResourceManager()

void ResourceSetResourceManager ( std::shared_ptr< Ship::ResourceManager resourceManager)

◆ ResourceUnloadByCrc()

API_EXPORT void ResourceUnloadByCrc ( uint64_t  crc)

Evicts the resource with the given CRC from the resource cache.

◆ ResourceUnloadByName()

API_EXPORT void ResourceUnloadByName ( const char *  name)

Evicts the resource with the given path from the resource cache.

◆ ResourceUnloadDirectory()

API_EXPORT void ResourceUnloadDirectory ( const char *  name)

Evicts all resources whose paths begin with name from the resource cache.

Parameters
nameDirectory prefix or exact path.