NWengine 0.9
Loading...
Searching...
No Matches
Shader Class Reference

Class representing a shader asset. More...

#include <Shader.h>

Inheritance diagram for Shader:
Asset

Public Member Functions

void Use ()
 Use this shader for rendering.
 
void SetMat4x4 (const char *name, const float *value)
 Set a 4x4 matrix uniform in the shader.
 
void SetUniform1f (const char *name, const float value)
 Set a float uniform in the shader.
 
void SetUniform3f (const char *name, float x, float y, float z)
 Set a 3-component float vector uniform in the shader.
 
void SetVector2 (const char *name, float value0, float value1)
 Set a 2-component float vector uniform in the shader.
 
void SetUniform1i (const char *name, const int value)
 Set an integer uniform in the shader.
 
void SetUniformArrayf (const char *name, float *value, int size)
 Set an array of float uniforms in the shader.
 
void SetUniformArrayi (const char *name, int *value, int size)
 Set an array of integer uniforms in the shader.
 
AssetGetFromCache (void *identifier) override
 Get a shader asset from the cache.
 
AssetLoadFromFile (const char *path, void *identifier) override
 Load a shader asset from a file.
 
AssetLoadFromBuffer (void *shaderTextPtr, void *identifier) override
 Load a shader asset from a buffer.
 
void Delete ()
 Delete the shader.
 
void _GlGen (ShaderText *shaderText)
 Generate and bind the OpenGL shader program.
 
 NW_DECL_RES_LIST (ShaderIdentifier, Shader)
 
- Public Member Functions inherited from Asset
virtual AssetLoadFromFileOrGetFromCache (void *identifier, const char *path, void *data)
 Load the asset from file or get it from the cache based on the identifier and file path.
 
virtual AssetLoadFromBufferOrGetFromCache (void *identifier, void *buffer, void *data)
 Load the asset from a buffer or get it from the cache based on the identifier.
 
virtual void Clean ()
 Clean up the asset.
 

Static Public Member Functions

static ShaderText parseShader (const char *path)
 Parse a shader file and return the shader text.
 

Public Attributes

uint32 _glID = 0
 
ShaderIdentifier _identifier
 
- Public Attributes inherited from Asset
int _usageCounter = 0
 

Detailed Description

Class representing a shader asset.

Member Function Documentation

◆ _GlGen()

void Shader::_GlGen ( ShaderText * shaderText)

Generate and bind the OpenGL shader program.

Parameters
shaderTextA pointer to the ShaderText struct.

◆ GetFromCache()

Asset * Shader::GetFromCache ( void * identifier)
overridevirtual

Get a shader asset from the cache.

Parameters
identifierThe identifier of the shader.
Returns
The shader asset if found in the cache, nullptr otherwise.

Reimplemented from Asset.

◆ LoadFromBuffer()

Asset * Shader::LoadFromBuffer ( void * shaderTextPtr,
void * identifier )
overridevirtual

Load a shader asset from a buffer.

Parameters
shaderTextPtrA pointer to the ShaderText struct.
identifierThe identifier of the shader.
Returns
The loaded shader asset.

Reimplemented from Asset.

◆ LoadFromFile()

Asset * Shader::LoadFromFile ( const char * path,
void * identifier )
overridevirtual

Load a shader asset from a file.

Parameters
pathThe path to the shader file.
identifierThe identifier of the shader.
Returns
The loaded shader asset.

Reimplemented from Asset.

◆ parseShader()

ShaderText Shader::parseShader ( const char * path)
static

Parse a shader file and return the shader text.

Parameters
pathThe path to the shader file.
Returns
The parsed shader text.

◆ SetMat4x4()

void Shader::SetMat4x4 ( const char * name,
const float * value )

Set a 4x4 matrix uniform in the shader.

Parameters
nameThe name of the uniform.
valueThe value of the uniform.

◆ SetUniform1f()

void Shader::SetUniform1f ( const char * name,
const float value )

Set a float uniform in the shader.

Parameters
nameThe name of the uniform.
valueThe value of the uniform.

◆ SetUniform1i()

void Shader::SetUniform1i ( const char * name,
const int value )

Set an integer uniform in the shader.

Parameters
nameThe name of the uniform.
valueThe value of the uniform.

◆ SetUniform3f()

void Shader::SetUniform3f ( const char * name,
float x,
float y,
float z )

Set a 3-component float vector uniform in the shader.

Parameters
nameThe name of the uniform.
xThe x component of the vector.
yThe y component of the vector.
zThe z component of the vector.

◆ SetUniformArrayf()

void Shader::SetUniformArrayf ( const char * name,
float * value,
int size )

Set an array of float uniforms in the shader.

Parameters
nameThe name of the uniform.
valueThe array of float values.
sizeThe size of the array.

◆ SetUniformArrayi()

void Shader::SetUniformArrayi ( const char * name,
int * value,
int size )

Set an array of integer uniforms in the shader.

Parameters
nameThe name of the uniform.
valueThe array of integer values.
sizeThe size of the array.

◆ SetVector2()

void Shader::SetVector2 ( const char * name,
float value0,
float value1 )

Set a 2-component float vector uniform in the shader.

Parameters
nameThe name of the uniform.
value0The first component of the vector.
value1The second component of the vector.

Member Data Documentation

◆ _glID

uint32 Shader::_glID = 0

The OpenGL ID of the shader.

◆ _identifier

ShaderIdentifier Shader::_identifier

The identifier of the shader.


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