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 char *vsFileName, const char *fsFileName)
 
 Shader (const Shader &)=delete
 
 Shader (const std::string_view vsFileName, const std::string_view fsFileName)
 
 Shader (Shader &&other) noexcept
 
 ~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 IsValid () 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...
 
 ShaderUnmanaged ()
 
 ShaderUnmanaged (const ::Shader &shader)
 
 ShaderUnmanaged (const char *vsFileName, const char *fsFileName)
 
 ShaderUnmanaged (const std::string &vsFileName, const std::string &fsFileName)
 
 ShaderUnmanaged (unsigned int id, int *locs=nullptr)
 
void Unload ()
 Unload shader from GPU memory (VRAM) More...
 
- Public Member Functions inherited from raylib::ShaderUnmanaged
 ShaderUnmanaged (const ::Shader &shader)
 
 ShaderUnmanaged (const char *vsFileName, const char *fsFileName)
 
 ShaderUnmanaged (const std::string &vsFileName, const std::string &fsFileName)
 
 ShaderUnmanaged (unsigned int id, int *locs=nullptr)
 
ShaderUnmanagedBeginMode ()
 Begin custom shader drawing. More...
 
ShaderUnmanagedEndMode ()
 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 &uniformName) const
 Get shader uniform location. More...
 
int GetLocationAttrib (const std::string &attribName) const
 Get shader attribute location. More...
 
int * GetLocs () const
 Retrieves the locs value for the object. More...
 
bool IsValid () const
 Retrieves whether or not the shader is ready. More...
 
ShaderUnmanagedoperator= (const ::Shader &shader)
 
ShaderUnmanagedSetValue (int uniformLoc, const ::Matrix &mat)
 Set shader uniform value (matrix 4x4) More...
 
ShaderUnmanagedSetValue (int uniformLoc, const ::Texture2D &texture)
 Set shader uniform value for texture. More...
 
ShaderUnmanagedSetValue (int uniformLoc, const void *value, int uniformType)
 Set shader uniform value. More...
 
ShaderUnmanagedSetValue (int uniformLoc, const void *value, int uniformType, int count)
 Set shader uniform value vector. 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...
 
- Static Public Member Functions inherited from raylib::ShaderUnmanaged
::Shader Load (const char *vsFileName, const char *fsFileName)
 
::Shader Load (const std::string &vsFileName, const std::string &fsFileName)
 Load shader from files and bind default locations. More...
 
::Shader LoadFromMemory (const char *vsCode, const char *fsCode)
 
::Shader LoadFromMemory (const std::string &vsCode, const std::string &fsCode)
 Load a shader from memory. More...
 

Protected Member Functions

void set (const ::Shader &shader)
 
- Protected Member Functions inherited from raylib::ShaderUnmanaged
void set (const ::Shader &shader)
 

Detailed Description

Shader type (generic)

Definition at line 17 of file Shader.hpp.

Constructor & Destructor Documentation

◆ Shader() [1/3]

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

Definition at line 21 of file Shader.hpp.

◆ Shader() [2/3]

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

Definition at line 25 of file Shader.hpp.

◆ Shader() [3/3]

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

Definition at line 31 of file Shader.hpp.

◆ ~Shader()

raylib::Shader::~Shader ( )
inline

Unload shader from GPU memory (VRAM)

Definition at line 91 of file Shader.hpp.

References Unload().

Member Function Documentation

◆ BeginMode()

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

Begin custom shader drawing.

Definition at line 105 of file Shader.hpp.

◆ EndMode()

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

End custom shader drawing (use default shader).

Definition at line 113 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 64 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 123 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 132 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 65 of file Shader.hpp.

◆ IsValid()

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

Retrieves whether or not the shader is ready.

Definition at line 269 of file Shader.hpp.

◆ Load() [1/2]

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

Definition at line 47 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 43 of file Shader.hpp.

◆ LoadFromMemory() [1/2]

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

Definition at line 60 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 56 of file Shader.hpp.

◆ operator=() [1/2]

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

Definition at line 67 of file Shader.hpp.

◆ operator=() [2/2]

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

Definition at line 74 of file Shader.hpp.

◆ set()

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

Definition at line 274 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 229 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 250 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 163 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 141 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 185 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 207 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 240 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 261 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 175 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 152 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 196 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 219 of file Shader.hpp.

References GetLocation().

◆ ShaderUnmanaged() [1/5]

raylib::ShaderUnmanaged::ShaderUnmanaged ( )
inline

Definition at line 17 of file ShaderUnmanaged.hpp.

◆ ShaderUnmanaged() [2/5]

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

Definition at line 19 of file ShaderUnmanaged.hpp.

◆ ShaderUnmanaged() [3/5]

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

Definition at line 26 of file ShaderUnmanaged.hpp.

◆ ShaderUnmanaged() [4/5]

raylib::ShaderUnmanaged::ShaderUnmanaged ( const std::string &  vsFileName,
const std::string &  fsFileName 
)
inline

Definition at line 23 of file ShaderUnmanaged.hpp.

◆ ShaderUnmanaged() [5/5]

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

Definition at line 21 of file ShaderUnmanaged.hpp.

◆ Unload()

void raylib::Shader::Unload ( )
inline

Unload shader from GPU memory (VRAM)

Definition at line 96 of file Shader.hpp.

Referenced by ~Shader().