VISU - PHP Game Framework

ShaderFileLoader
in package

Table of Contents

Properties

$additionlIncludePaths  : array<string|int, string>
An array of include paths to search for included files
$shaderFileDir  : string

Methods

__construct()  : mixed
Constructor
addIncludePath()  : void
Adds an additional include path to search for included files
getShaderFileDir()  : string
Returns the current shader file directory
loadShader()  : string
Will load and process a shader file and return the final source code
processShader()  : string
Will process includes and macros in the shader source code and return the final source code
processShaderIncludes()  : string
Replaces include statements in the shader source code with the contents of the included file
findIncludeFromPath()  : string
Tries to find the shader file in the currently available include paths Returns the contents of the file if found, otherwise throws an exception
getDefinesString()  : string
Generates a defines code section string

Properties

$additionlIncludePaths

An array of include paths to search for included files

private array<string|int, string> $additionlIncludePaths = []

Methods

__construct()

Constructor

public __construct(string $shaderFileDir) : mixed
Parameters
$shaderFileDir : string

A path to a directory where the shader files are located you want to be able to load.

addIncludePath()

Adds an additional include path to search for included files

public addIncludePath(string $path) : void
Parameters
$path : string

Path to a directory that will be considered for includes

getShaderFileDir()

Returns the current shader file directory

public getShaderFileDir() : string
Return values
string

loadShader()

Will load and process a shader file and return the final source code

public loadShader(string $shaderFile[, array<string, int|float|string> $defines = [] ][, bool $rootFile = true ]) : string
Parameters
$shaderFile : string

The relative path to the shader file

$defines : array<string, int|float|string> = []

An array of macros that will be injected into the shader

$rootFile : bool = true

Whether or not this is the root file that is being processed, This file contains the additional defines passed over $defines.

Return values
string

processShader()

Will process includes and macros in the shader source code and return the final source code

public processShader(string $shaderContents[, array<string, int|float|string> $defines = [] ][, bool $rootFile = true ]) : string
Parameters
$shaderContents : string
$defines : array<string, int|float|string> = []

An array of macros that will be injected into the shader

$rootFile : bool = true

Whether or not this is the root file that is being processed, This file contains the additional defines passed over $defines.

Return values
string

processShaderIncludes()

Replaces include statements in the shader source code with the contents of the included file

public processShaderIncludes(string $shaderContents) : string
Parameters
$shaderContents : string

The shader source code

Tags
throws
ShaderInvalidIncludeException
Return values
string

findIncludeFromPath()

Tries to find the shader file in the currently available include paths Returns the contents of the file if found, otherwise throws an exception

private findIncludeFromPath(string $path) : string
Parameters
$path : string
Tags
throws
ShaderInvalidIncludeException
Return values
string

The contents of the shader file

getDefinesString()

Generates a defines code section string

private getDefinesString(array<string, int|float|string> $defines) : string
Parameters
$defines : array<string, int|float|string>

An array of macros that will be used in the shader

Return values
string

        
On this page

Search results