EntropyCanvas::ShaderClient
EntropyCanvas::ShaderClient
Section titled “EntropyCanvas::ShaderClient”Client API for shader operations. More…
#include <ShaderClient.h>
Public Functions
Section titled “Public Functions”| Name | |
|---|---|
| ~ShaderClient() | |
| EntropyEngine::Networking::Result< AssetId > | uploadShaderSync(const ShaderBundle & bundle, bool persistent =false) Upload a shader and wait for completion. |
| std::shared_ptr< UploadShaderHandle > | uploadShader(const ShaderBundle & bundle, bool persistent =false) Upload a custom shader to CanvasEngine. |
| ShaderClient & | operator=(const ShaderClient & ) =delete |
| bool | isBuiltin(const AssetId & id) Check if an AssetId is a built-in shader. |
| bool | isAvailable(const AssetId & id) const Check if a shader is available (built-in or uploaded). |
| std::optional< ShaderMetadata > | getMetadata(const AssetId & id) const Get cached shader metadata. |
| const char * | getBuiltinName(const AssetId & id) Get the name of a built-in shader (for debugging). |
| void | fetchShaderInfo(const AssetId & id, std::function< void(bool found, const ShaderMetadata &metadata)> callback) Request shader info from server (async). |
| size_t | cachedMetadataCount() const Get number of cached shader metadata entries. |
| ShaderClient(CanvasClient & canvasClient) Construct a ShaderClient attached to a CanvasClient. | |
| ShaderClient(const ShaderClient & ) =delete |
Friends
Section titled “Friends”| Name | |
|---|---|
| class | CanvasClient |
Detailed Description
Section titled “Detailed Description”class EntropyCanvas::ShaderClient;Client API for shader operations.
ShaderClient provides methods for:
- Uploading custom shaders to CanvasEngine
- Checking if shaders are built-in or available
- Caching shader metadata
Security Note: Built-in shaders are identified by AssetId constants in BuiltinShaders. Do NOT use string lookups - use the constants directly.
Usage:
ShaderClient shaders(canvasClient);
// Check if PBR shader is built-inif (shaders.isBuiltin(Shaders::BuiltinShaders::PBR)) { // Use built-in PBR shader material.shaderAssetId = Shaders::BuiltinShaders::PBR;}
// Upload custom shaderShaderBundle bundle;bundle.mainSource = readFile("MyShader.slang");bundle.metadata.name = "MyCustomShader";
auto handle = shaders.uploadShader(bundle);handle.wait();
if (handle.success()) { AssetId shaderId = handle.result(); material.shaderAssetId = shaderId;}Public Functions Documentation
Section titled “Public Functions Documentation”function ~ShaderClient
Section titled “function ~ShaderClient”~ShaderClient()function uploadShaderSync
Section titled “function uploadShaderSync”EntropyEngine::Networking::Result< AssetId > uploadShaderSync( const ShaderBundle & bundle, bool persistent =false)Upload a shader and wait for completion.
Parameters:
- bundle Shader bundle with source and metadata
- persistent If true, shader survives session disconnect
Return: Result with AssetId on success, or error
Convenience method that blocks until the operation completes.
function uploadShader
Section titled “function uploadShader”std::shared_ptr< UploadShaderHandle > uploadShader( const ShaderBundle & bundle, bool persistent =false)Upload a custom shader to CanvasEngine.
Parameters:
- bundle Shader bundle with source and metadata
- persistent If true, shader survives session disconnect
Return: Handle to track operation completion
The shader is registered with the server and assigned an AssetId computed from the source content. Identical shaders get the same ID.
function operator=
Section titled “function operator=”ShaderClient & operator=( const ShaderClient &) =deletefunction isBuiltin
Section titled “function isBuiltin”static inline bool isBuiltin( const AssetId & id)Check if an AssetId is a built-in shader.
Parameters:
- id Shader AssetId
Return: True if this is a built-in shader
Delegates to BuiltinShaders::isBuiltin(). Use this for fast O(1) checks.
function isAvailable
Section titled “function isAvailable”bool isAvailable( const AssetId & id) constCheck if a shader is available (built-in or uploaded).
Parameters:
- id Shader AssetId
Return: True if shader is available
function getMetadata
Section titled “function getMetadata”std::optional< ShaderMetadata > getMetadata( const AssetId & id) constGet cached shader metadata.
Parameters:
- id Shader AssetId
Return: Metadata if cached, nullopt otherwise
function getBuiltinName
Section titled “function getBuiltinName”static inline const char * getBuiltinName( const AssetId & id)Get the name of a built-in shader (for debugging).
Parameters:
- id Shader AssetId
Return: Shader name or “Custom” if not a built-in
function fetchShaderInfo
Section titled “function fetchShaderInfo”void fetchShaderInfo( const AssetId & id, std::function< void(bool found, const ShaderMetadata &metadata)> callback)Request shader info from server (async).
Parameters:
- id Shader AssetId
- callback Called with result
Fetches shader metadata from the server. Useful for checking if a custom shader exists and getting its parameters.
function cachedMetadataCount
Section titled “function cachedMetadataCount”size_t cachedMetadataCount() constGet number of cached shader metadata entries.
function ShaderClient
Section titled “function ShaderClient”explicit ShaderClient( CanvasClient & canvasClient)Construct a ShaderClient attached to a CanvasClient.
Parameters:
- canvasClient Parent CanvasClient (must remain valid)
function ShaderClient
Section titled “function ShaderClient”ShaderClient( const ShaderClient &) =deleteFriends
Section titled “Friends”friend CanvasClient
Section titled “friend CanvasClient”friend class CanvasClient( CanvasClient);Updated on 2026-01-26 at 17:14:35 -0500