raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
raylib::Shader Class Reference

Shader type (generic) More...

#include <Shader.hpp>

Public Member Functions

 Shader (const ::Shader &shader)
 
 Shader (const char *vsFileName, const char *fsFileName)
 
 Shader (const Shader &)=delete
 
 Shader (const std::string_view vsFileName, const std::string_view fsFileName)
 
 Shader (Shader &&other)
 
 Shader (unsigned int id, int *locs=nullptr)
 
 Shader (unsigned int id, std::span< int > locs)
 
 ~Shader ()
 Unload shader from GPU memory (VRAM) More...
 
ShaderBeginMode ()
 Begin custom shader drawing. More...
 
ShaderEndMode ()
 End custom shader drawing (use default shader). More...
 
unsigned int GetId () const
 Retrieves the id value for the object. More...
 
int GetLocation (const std::string_view uniformName) const
 Get shader uniform location. More...
 
int GetLocationAttrib (const std::string_view attribName) const
 Get shader attribute location. More...
 
int * GetLocs () const
 Retrieves the locs value for the object. More...
 
bool IsReady () const
 Retrieves whether or not the shader is ready. More...
 
Shaderoperator= (const ::Shader &shader)
 
Shaderoperator= (const Shader &)=delete
 
Shaderoperator= (Shader &&other) noexcept
 
ShaderSetValue (int uniformLoc, const ::Matrix &mat)
 Set shader uniform value (matrix 4x4) More...
 
ShaderSetValue (int uniformLoc, const ::Texture2D &texture)
 Set shader uniform value for texture. More...
 
template<typename T >
ShaderSetValue (int uniformLoc, const T &value, int uniformType)
 Set shader uniform value. More...
 
ShaderSetValue (int uniformLoc, const void *value, int uniformType)
 Set shader uniform value. More...
 
ShaderSetValue (int uniformLoc, const void *value, int uniformType, int count)
 Set shader uniform value vector. More...
 
template<typename T >
ShaderSetValue (int uniformLoc, std::span< T > data, int uniformType)
 Set shader uniform value vector (represented as a std::span) More...
 
ShaderSetValue (std::string_view uniformName, const ::Matrix &mat)
 Set shader uniform value (matrix 4x4) Automatically finds the location of the uniform given its name. More...
 
ShaderSetValue (std::string_view uniformName, const ::Texture2D &texture)
 Set shader uniform value for texture Automatically finds the location of the uniform given its name. More...
 
template<typename T >
ShaderSetValue (std::string_view uniformName, const T &value, int uniformType)
 Set shader uniform value Automatically finds the location of the uniform given its name. More...
 
ShaderSetValue (std::string_view uniformName, const void *value, int uniformType)
 Set shader uniform value Automatically finds the location of the uniform given its name. More...
 
ShaderSetValue (std::string_view uniformName, const void *value, int uniformType, int count)
 Set shader uniform value vector Automatically finds the location of the uniform given its name. More...
 
template<typename T >
ShaderSetValue (std::string_view uniformName, std::span< T > data, int uniformType)
 Set shader uniform value vector (represented as a std::span) Automatically finds the location of the uniform given its name. More...
 
void Unload ()
 Unload shader from GPU memory (VRAM) More...
 

Static Public Member Functions

::Shader Load (const char *vsFileName, const char *fsFileName)
 
::Shader Load (const std::string_view vsFileName, const std::string_view fsFileName)
 Load shader from files and bind default locations. More...
 
::Shader LoadFromMemory (const char *vsCode, const char *fsCode)
 
::Shader LoadFromMemory (const std::string_view vsCode, const std::string_view fsCode)
 Load a shader from memory. More...
 

Protected Member Functions

void set (const ::Shader &shader)
 

Detailed Description

Shader type (generic)

Definition at line 16 of file Shader.hpp.

Constructor & Destructor Documentation

◆ Shader() [1/6]

raylib::Shader::Shader ( const ::Shader &  shader)
inline

Definition at line 18 of file Shader.hpp.

◆ Shader() [2/6]

raylib::Shader::Shader ( unsigned int  id,
int *  locs = nullptr 
)
inline

Definition at line 22 of file Shader.hpp.

◆ Shader() [3/6]

raylib::Shader::Shader ( unsigned int  id,
std::span< int >  locs 
)
inline

Definition at line 23 of file Shader.hpp.

◆ Shader() [4/6]

raylib::Shader::Shader ( const std::string_view  vsFileName,
const std::string_view  fsFileName 
)
inline

Definition at line 25 of file Shader.hpp.

◆ Shader() [5/6]

raylib::Shader::Shader ( const char *  vsFileName,
const char *  fsFileName 
)
inline

Definition at line 29 of file Shader.hpp.

◆ Shader() [6/6]

raylib::Shader::Shader ( Shader &&  other)
inline

Definition at line 35 of file Shader.hpp.

◆ ~Shader()

raylib::Shader::~Shader ( )
inline

Unload shader from GPU memory (VRAM)

Definition at line 95 of file Shader.hpp.

References Unload().

Member Function Documentation

◆ BeginMode()

Shader & raylib::Shader::BeginMode ( )
inline

Begin custom shader drawing.

Definition at line 111 of file Shader.hpp.

◆ EndMode()

Shader & raylib::Shader::EndMode ( )
inline

End custom shader drawing (use default shader).

Definition at line 119 of file Shader.hpp.

◆ GetId()

unsigned int raylib::Shader::GetId ( ) const
inline

Retrieves the id value for the object.

Returns
The id value of the object.

Definition at line 68 of file Shader.hpp.

◆ GetLocation()

int raylib::Shader::GetLocation ( const std::string_view  uniformName) const
inline

Get shader uniform location.

See also
GetShaderLocation()

Definition at line 129 of file Shader.hpp.

Referenced by SetValue().

◆ GetLocationAttrib()

int raylib::Shader::GetLocationAttrib ( const std::string_view  attribName) const
inline

Get shader attribute location.

See also
GetShaderLocationAttrib()

Definition at line 138 of file Shader.hpp.

◆ GetLocs()

int * raylib::Shader::GetLocs ( ) const
inline

Retrieves the locs value for the object.

Returns
The locs value of the object.

Definition at line 69 of file Shader.hpp.

◆ IsReady()

bool raylib::Shader::IsReady ( ) const
inline

Retrieves whether or not the shader is ready.

Definition at line 275 of file Shader.hpp.

◆ Load() [1/2]

::Shader raylib::Shader::Load ( const char *  vsFileName,
const char *  fsFileName 
)
inlinestatic

Definition at line 51 of file Shader.hpp.

◆ Load() [2/2]

::Shader raylib::Shader::Load ( const std::string_view  vsFileName,
const std::string_view  fsFileName 
)
inlinestatic

Load shader from files and bind default locations.

See also
::LoadShader

Definition at line 47 of file Shader.hpp.

◆ LoadFromMemory() [1/2]

::Shader raylib::Shader::LoadFromMemory ( const char *  vsCode,
const char *  fsCode 
)
inlinestatic

Definition at line 64 of file Shader.hpp.

◆ LoadFromMemory() [2/2]

::Shader raylib::Shader::LoadFromMemory ( const std::string_view  vsCode,
const std::string_view  fsCode 
)
inlinestatic

Load a shader from memory.

See also
::LoadShaderFromMemory

Definition at line 60 of file Shader.hpp.

◆ operator=() [1/2]

Shader & raylib::Shader::operator= ( const ::Shader &  shader)
inline

Definition at line 71 of file Shader.hpp.

◆ operator=() [2/2]

Shader & raylib::Shader::operator= ( Shader &&  other)
inlinenoexcept

Definition at line 78 of file Shader.hpp.

◆ set()

void raylib::Shader::set ( const ::Shader &  shader)
inlineprotected

Definition at line 280 of file Shader.hpp.

◆ SetValue() [1/12]

Shader & raylib::Shader::SetValue ( int  uniformLoc,
const ::Matrix &  mat 
)
inline

Set shader uniform value (matrix 4x4)

See also
SetShaderValueMatrix()

Definition at line 235 of file Shader.hpp.

◆ SetValue() [2/12]

Shader & raylib::Shader::SetValue ( int  uniformLoc,
const ::Texture2D &  texture 
)
inline

Set shader uniform value for texture.

See also
SetShaderValueTexture()

Definition at line 256 of file Shader.hpp.

◆ SetValue() [3/12]

template<typename T >
Shader & raylib::Shader::SetValue ( int  uniformLoc,
const T &  value,
int  uniformType 
)
inline

Set shader uniform value.

See also
SetShaderValue()

Definition at line 169 of file Shader.hpp.

◆ SetValue() [4/12]

Shader & raylib::Shader::SetValue ( int  uniformLoc,
const void *  value,
int  uniformType 
)
inline

Set shader uniform value.

See also
SetShaderValue()

Definition at line 147 of file Shader.hpp.

◆ SetValue() [5/12]

Shader & raylib::Shader::SetValue ( int  uniformLoc,
const void *  value,
int  uniformType,
int  count 
)
inline

Set shader uniform value vector.

See also
SetShaderValueV()

Definition at line 191 of file Shader.hpp.

◆ SetValue() [6/12]

template<typename T >
Shader & raylib::Shader::SetValue ( int  uniformLoc,
std::span< T >  data,
int  uniformType 
)
inline

Set shader uniform value vector (represented as a std::span)

See also
SetShaderValueV()

Definition at line 213 of file Shader.hpp.

◆ SetValue() [7/12]

Shader & raylib::Shader::SetValue ( std::string_view  uniformName,
const ::Matrix &  mat 
)
inline

Set shader uniform value (matrix 4x4) Automatically finds the location of the uniform given its name.

See also
SetShaderValueMatrix()

Definition at line 246 of file Shader.hpp.

References GetLocation().

◆ SetValue() [8/12]

Shader & raylib::Shader::SetValue ( std::string_view  uniformName,
const ::Texture2D &  texture 
)
inline

Set shader uniform value for texture Automatically finds the location of the uniform given its name.

See also
SetShaderValueTexture()

Definition at line 267 of file Shader.hpp.

References GetLocation().

◆ SetValue() [9/12]

template<typename T >
Shader & raylib::Shader::SetValue ( std::string_view  uniformName,
const T &  value,
int  uniformType 
)
inline

Set shader uniform value Automatically finds the location of the uniform given its name.

See also
SetShaderValue()

Definition at line 181 of file Shader.hpp.

References GetLocation().

◆ SetValue() [10/12]

Shader & raylib::Shader::SetValue ( std::string_view  uniformName,
const void *  value,
int  uniformType 
)
inline

Set shader uniform value Automatically finds the location of the uniform given its name.

See also
SetShaderValue()

Definition at line 158 of file Shader.hpp.

References GetLocation().

◆ SetValue() [11/12]

Shader & raylib::Shader::SetValue ( std::string_view  uniformName,
const void *  value,
int  uniformType,
int  count 
)
inline

Set shader uniform value vector Automatically finds the location of the uniform given its name.

See also
SetShaderValueV()

Definition at line 202 of file Shader.hpp.

References GetLocation().

◆ SetValue() [12/12]

template<typename T >
Shader & raylib::Shader::SetValue ( std::string_view  uniformName,
std::span< T >  data,
int  uniformType 
)
inline

Set shader uniform value vector (represented as a std::span) Automatically finds the location of the uniform given its name.

See also
SetShaderValueV()

Definition at line 225 of file Shader.hpp.

References GetLocation().

◆ Unload()

void raylib::Shader::Unload ( )
inline

Unload shader from GPU memory (VRAM)

Definition at line 102 of file Shader.hpp.

Referenced by ~Shader().