xyginext  0.2.0
Second generation of xygine game creation framework
Public Types | Public Member Functions | List of all members
xy::ShaderResource Class Referencefinal

Specialised resource manager for shaders. More...

#include <ShaderResource.hpp>

Public Types

using ID = sf::Int32
 

Public Member Functions

 ShaderResource (const ShaderResource &)=delete
 
 ShaderResource (ShaderResource &&)=delete
 
ShaderResourceoperator= (const ShaderResource &)=delete
 
ShaderResourceoperator= (ShaderResource &&)=delete
 
sf::Shader & get (ID)
 get a reference to the shader corresponding to the given ID More...
 
void preload (ID, const std::string &, const std::string &)
 Preloads a shader. More...
 
void preload (ID, const std::string &, sf::Shader::Type)
 Preloads a shader. More...
 
bool exists (ID id)
 Returns true if the given ID is already in use.
 

Detailed Description

Specialised resource manager for shaders.

Member Function Documentation

◆ get()

sf::Shader& xy::ShaderResource::get ( ID  )

get a reference to the shader corresponding to the given ID

Before a shader can be returned it must be preloaded and associated with the given ID. If using custom shaders along side the built in xygine shaders the the Unique ID should start at least Shader::Type::Count

See also
preLoad

◆ preload() [1/2]

void xy::ShaderResource::preload ( ID  ,
const std::string &  ,
const std::string &   
)

Preloads a shader.

Shaders need to be loaded and compiled before they can be used which can be a time consuming action. Preloading shaders when other resources are loaded allows shaders to be returned more efficiently at run time.

Parameters
IDA unique 32 bit integer to identify the loaded shader
stringA string containing the source for the vertex shader. The string can either be a constant stored within a source file, or loaded from an external file at run time.
stringA string containing the source for the fragment shader. The string can either be a constant stored within a source file, or loaded from an external file at run time.

◆ preload() [2/2]

void xy::ShaderResource::preload ( ID  ,
const std::string &  ,
sf::Shader::Type   
)

Preloads a shader.

Shaders need to be loaded and compiled before they can be used which can be a time consuming action. Preloading shaders when other resources are loaded allows shaders to be returned more efficiently at run time.

Parameters
IDA unique 32 bit integer to identify the loaded shader
stringA string containing the source for a vertex or fragment shader. The string can either be a constant stored within a source file, or loaded from an external file at run time.
sf::Shader::TypeShader type describing whether the source is a vertex or fragment shader.