1 #ifndef RAYLIB_CPP_INCLUDE_SHADER_HPP_
2 #define RAYLIB_CPP_INCLUDE_SHADER_HPP_
6 #include "./raylib.hpp"
7 #include "./raylib-cpp-utils.hpp"
16 Shader(const ::Shader& shader) {
20 Shader(
unsigned int id,
int* locs =
nullptr) :
::Shader{id, locs} {}
22 Shader(
const std::string& vsFileName,
const std::string& fsFileName) {
23 set(::LoadShader(vsFileName.c_str(), fsFileName.c_str()));
26 Shader(
const char* vsFileName,
const char* fsFileName) {
27 set(::LoadShader(vsFileName, fsFileName));
44 static ::Shader
Load(
const std::string& vsFileName,
const std::string& fsFileName) {
45 return ::LoadShader(vsFileName.c_str(), fsFileName.c_str());
53 static ::Shader
LoadFromMemory(
const std::string& vsCode,
const std::string& fsCode) {
54 return ::LoadShaderFromMemory(vsCode.c_str(), fsCode.c_str());
57 GETTERSETTER(
unsigned int, Id,
id)
58 GETTERSETTER(
int*, Locs, locs)
86 if (locs !=
nullptr) {
87 ::UnloadShader(*
this);
95 ::BeginShaderMode(*
this);
113 return ::GetShaderLocation(*
this, uniformName.c_str());
122 return ::GetShaderLocationAttrib(*
this, attribName.c_str());
131 ::SetShaderValue(*
this, uniformLoc, value, uniformType);
140 inline Shader&
SetValue(
int uniformLoc,
const void* value,
int uniformType,
int count) {
141 ::SetShaderValueV(*
this, uniformLoc, value, uniformType, count);
151 ::SetShaderValueMatrix(*
this, uniformLoc, mat);
161 ::SetShaderValueTexture(*
this, uniformLoc, texture);
169 return id != 0 && locs !=
nullptr;
173 void set(const ::Shader& shader) {
Shader & SetValue(int uniformLoc, const void *value, int uniformType, int count)
Set shader uniform value vector.
Shader & EndMode()
End custom shader drawing (use default shader).
Shader & BeginMode()
Begin custom shader drawing.
::Shader Load(const std::string &vsFileName, const std::string &fsFileName)
Load shader from files and bind default locations.
Shader & SetValue(int uniformLoc, const ::Texture2D &texture)
Set shader uniform value for texture.
::Shader LoadFromMemory(const std::string &vsCode, const std::string &fsCode)
Load a shader from memory.
int GetLocation(const std::string &uniformName) const
Get shader uniform location.
int GetLocationAttrib(const std::string &attribName) const
Get shader attribute location.
bool IsReady() const
Retrieves whether or not the shader is ready.
Shader & SetValue(int uniformLoc, const ::Matrix &mat)
Set shader uniform value (matrix 4x4)
Shader & SetValue(int uniformLoc, const void *value, int uniformType)
Set shader uniform value.
All raylib-cpp classes and functions appear in the raylib namespace.