Base class for a resource in the component. More...
Public Member Functions | |
virtual | ~Resource () |
bool | isReadyForRendering () const |
bool | isUnloaded () const |
RESOURCE_LOAD_STATE | getLoadState () const |
nkMemory::StringView | getPath () const |
RESOURCE_TYPE | getTypeName () const |
nkMemory::StringView | getName () const |
System * | getSystem () const |
bool | getHidden () const |
bool | getGpuUploadCanBeDeferred () const |
virtual void | setPath (nkMemory::StringView value) |
void | setName (nkMemory::StringView value) |
void | setHidden (bool value) |
void | setGpuUploadCanBeDeferred (bool value) |
virtual bool | load ()=0 |
virtual void | unload ()=0 |
Base class for a resource in the component.
|
virtual |
Destructor.
bool nkGraphics::Resource::isReadyForRendering | ( | ) | const |
bool nkGraphics::Resource::isUnloaded | ( | ) | const |
RESOURCE_LOAD_STATE nkGraphics::Resource::getLoadState | ( | ) | const |
The current load state of the resource.
nkMemory::StringView nkGraphics::Resource::getPath | ( | ) | const |
RESOURCE_TYPE nkGraphics::Resource::getTypeName | ( | ) | const |
nkMemory::StringView nkGraphics::Resource::getName | ( | ) | const |
System* nkGraphics::Resource::getSystem | ( | ) | const |
bool nkGraphics::Resource::getHidden | ( | ) | const |
bool nkGraphics::Resource::getGpuUploadCanBeDeferred | ( | ) | const |
|
virtual |
Sets the resource's path, relative to the working directory. See nkResources::ResourceManager for path naming conventions.
value | The path to use. |
Reimplemented in nkGraphics::Texture.
void nkGraphics::Resource::setName | ( | nkMemory::StringView | value | ) |
Sets the resource name.
value | The resource name to use. |
void nkGraphics::Resource::setHidden | ( | bool | value | ) |
Sets whether the resource is hidden or not. Hidden resource do not contribute to resource set save requests. By default, this is set to false.
value | Whether the resource should be hidden (true) or not (false). |
void nkGraphics::Resource::setGpuUploadCanBeDeferred | ( | bool | value | ) |
Sets whether the resource's loading is safe to be deferred before rendering a scene or not.
This behavior is relevant to the Dx12 rendering API if chosen. By design, Gles and Dx11 require all loading resources to be ready before rendering, at the expense of potential hiccups if it is necessary to wait for them. The Dx12 renderer has been designed with a "no-hiccup" strategy, meaning that loading resources that are not ready yet won't prevent rendering. Instead, they will be gracefully handled in the background. A mesh won't be painted for instance, and only appear once GPU is ready to render it on next frames. If this flag is set to false, then the Dx12 renderer will have the same behavior as the Gles and Dx11 renderers and wait for resources.
By default, this is set to true.
value | Whether the resource GPU load can safely be deferred (true) or not (false). |
|
pure virtual |
Loading function. A resource goes into different states through its lifetime.
It is possible to loop through these states during the resource lifetime, if needed.
Implemented in nkGraphics::Program, nkGraphics::Mesh, and nkGraphics::Shader.
|
pure virtual |
Unloads the resource, and places it back into its created state. Frees all internal memory used to initialize it.
Implemented in nkGraphics::Program, and nkGraphics::Shader.