ShaderCollection
in package
Table of Contents
Properties
- $avilableShaderFiles : array<string, array<int, string>>
- Pre registered shader files that can be loaded on demand
- $gl : GLState
- $globalDefines : array<string, int|float|string>
- Array of global defines that will be added to all shader programs
- $shaderDirectory : string
- $shaderFileLoader : ShaderFileLoader
- Shader file loader instance
- $shaderPrograms : array<string, ShaderProgram>
- Array of shader programs
Methods
- __construct() : mixed
- Constructor
- addVISUShaders() : void
- Specifially scans the VISU shader directory for shader files and adds them to the collection
- enableVISUIncludes() : void
- Enables VISU shader includes
- get() : ShaderProgram
- Returns a shader program from the collection
- loadAll() : void
- Loads all currently registered shader programs, you can pass a callback to be called after each shader program is loaded This way you can show a loading screen or something.
- registerFromFiles() : void
- Adds a shader program from an array of shader stage files
- scanShaderDirectory() : void
- Scans the shader directory for shader files and adds them to the collection
- setGlobalDefine() : void
- Sets a global define that will be added to all shader programs
- setShaderProgram() : void
- Adds a shader program to the collection
Properties
$avilableShaderFiles
Pre registered shader files that can be loaded on demand
private
array<string, array<int, string>>
$avilableShaderFiles
= []
$gl
private
GLState
$gl
$globalDefines
Array of global defines that will be added to all shader programs
private
array<string, int|float|string>
$globalDefines
= []
$shaderDirectory
private
string
$shaderDirectory
$shaderFileLoader
Shader file loader instance
private
ShaderFileLoader
$shaderFileLoader
$shaderPrograms
Array of shader programs
private
array<string, ShaderProgram>
$shaderPrograms
= []
Methods
__construct()
Constructor
public
__construct(GLState $gl, string $shaderDirectory) : mixed
Parameters
- $gl : GLState
- $shaderDirectory : string
-
The directory where the shader files are located
addVISUShaders()
Specifially scans the VISU shader directory for shader files and adds them to the collection
public
addVISUShaders() : void
enableVISUIncludes()
Enables VISU shader includes
public
enableVISUIncludes() : void
get()
Returns a shader program from the collection
public
get(string $name) : ShaderProgram
Parameters
- $name : string
-
The name of the shader program
Return values
ShaderProgramloadAll()
Loads all currently registered shader programs, you can pass a callback to be called after each shader program is loaded This way you can show a loading screen or something.
public
loadAll([callable|null $callback = null ]) : void
..
Parameters
- $callback : callable|null = null
-
The callback to be called after each shader program is loaded
registerFromFiles()
Adds a shader program from an array of shader stage files
public
registerFromFiles(string $name, array<int, string> $paths) : void
$shaders->registerFromFiles('myshader', [
ShaderStage::VERTEX => 'myshader.vert.glsl',
ShaderStage::FRAGMENT => 'myshader.frag.glsl',
]);
Parameters
- $name : string
- $paths : array<int, string>
-
An array of shader stage constants as keys and paths to the shader files as values
scanShaderDirectory()
Scans the shader directory for shader files and adds them to the collection
public
scanShaderDirectory([string|null $directoryPath = null ]) : void
Parameters
- $directoryPath : string|null = null
-
The directory to scan. If null, the shader directory will be used
setGlobalDefine()
Sets a global define that will be added to all shader programs
public
setGlobalDefine(string $name, int|float|string $value) : void
Parameters
- $name : string
- $value : int|float|string
setShaderProgram()
Adds a shader program to the collection
public
setShaderProgram(string $name, ShaderProgram $shaderProgram) : void
Parameters
- $name : string
-
A unique name / identifier for the shader program
- $shaderProgram : ShaderProgram