LLGL 0.05 Beta
Loading...
Searching...
No Matches
LLGL::Resource Class Referenceabstract

Base class for all hardware resource interfaces. More...

#include <Resource.h>

Inheritance diagram for LLGL::Resource:
LLGL::RenderSystemChild LLGL::Interface LLGL::NonCopyable LLGL::Buffer LLGL::Sampler LLGL::Texture

Public Member Functions

virtual ResourceType GetResourceType () const =0
 Returns the type of this resource object.
virtual bool GetNativeHandle (void *nativeHandle, std::size_t nativeHandleSize)=0
 Returns the native resource handle.
Public Member Functions inherited from LLGL::RenderSystemChild
virtual void SetDebugName (const char *name)
 Sets the name of this class instance for debugging purposes.
Public Member Functions inherited from LLGL::Interface
virtual bool IsInstanceOf (int id) const
 Returns true if this object is an instance of the specified interface.
Public Member Functions inherited from LLGL::NonCopyable
 NonCopyable (const NonCopyable &)=delete
NonCopyable & operator= (const NonCopyable &)=delete
virtual ~NonCopyable ()=default

Additional Inherited Members

Protected Member Functions inherited from LLGL::NonCopyable
 NonCopyable ()=default

Detailed Description

Base class for all hardware resource interfaces.

See also
Buffer
Texture
Sampler

Member Function Documentation

◆ GetNativeHandle()

virtual bool LLGL::Resource::GetNativeHandle ( void * nativeHandle,
std::size_t nativeHandleSize )
pure virtual

Returns the native resource handle.

Parameters
[out]nativeHandleRaw pointer to the backend specific structure to store the native handle. Obtain the respective structure from #include <LLGL/Backend/BACKEND/NativeHandle.h> where BACKEND must be either Direct3D12, Direct3D11, Vulkan, Metal, or OpenGL.
[in]nativeHandleSizeSpecifies the size (in bytes) of the native handle structure for robustness. This must be sizeof(STRUCT) where STRUCT is the respective backend specific structure such as LLGL::Direct3D12::ResourceNativeHandle.
Returns
True if the native handle was successfully retrieved. Otherwise, nativeHandleSize specifies an incompatible structure size.
Remarks
For the Direct3D backends, all retrieved COM pointers will be incremented and the user is responsible for releasing those pointers, i.e. a call to IUnknown::Release is required to each of the objects returned by this function.
For the Metal backend, all retrieved NSObject instances will have their retain counter incremented and the user is responsible for releasing those objects, i.e. a call to -(oneway void)release is required to each of the objects returned by this function.
For backends that do not support this function, the return value is false unless nativeHandle is null or nativeHandleSize is 0.
Example for obtaining the native handle of a Direct3D12 render system:
//...
if (myResource->GetNativeHandle(&d3dNativeHandle, sizeof(d3dNativeHandle))) {
ID3D12Resource* d3dResource = d3dNativeHandle.resource;
...
d3dResource->Release();
}
Native handle structure for a Direct3D 12 resource.
Definition Backend/Direct3D12/NativeHandle.h:110
NativeResource resource
Native Direct3D 12 resource.
Definition Backend/Direct3D12/NativeHandle.h:160
See also
Direct3D12::ResourceNativeHandle
Direct3D11::ResourceNativeHandle
Vulkan::ResourceNativeHandle
Metal::ResourceNativeHandle
OpenGL::ResourceNativeHandle

◆ GetResourceType()

virtual ResourceType LLGL::Resource::GetResourceType ( ) const
pure virtual

Returns the type of this resource object.

Remarks
This is queried by a virtual function call, so the resource type does not need to be stored per instance.
See also
ResourceType
Todo
(Maybe) replace by IsInstanceOf

Implemented in LLGL::Buffer, LLGL::Sampler, and LLGL::Texture.


The documentation for this class was generated from the following file: