Muto 0.0.1
Cross-Platform Application Template
GitHub Repo | Muto Updates | Muto's Author
Loading...
Searching...
No Matches
Muto::Shader Class Referenceabstract

An abstraction for a shader program. More...

#include <Shader.h>

Inheritance diagram for Muto::Shader:
Muto::OpenGLShader

Public Member Functions

virtual void Bind () const =0
 connects the shader program for use.
 
virtual const std::string & GetName () const =0
 
virtual void SetFloat (const std::string &name, float value)=0
 Sets a single float uniform in the shader.
 
virtual void SetFloat3 (const std::string &name, const glm::vec3 &value)=0
 Sets a 3-component float vector uniform in the shader.
 
virtual void SetFloat4 (const std::string &name, const glm::vec4 &value)=0
 Sets a 4-component float vector uniform in the shader.
 
virtual void SetInt (const std::string &name, int value)=0
 Sets a single integer uniform in the shader.
 
virtual void SetIntArray (const std::string &name, int *values, uint32_t count)=0
 Sets an array of integers uniform in the shader.
 
virtual void SetMat4 (const std::string &name, const glm::mat4 &value)=0
 Sets a 4x4 matrix uniform in the shader.
 
virtual void Unbind () const =0
 disconnects the shader program.
 
virtual ~Shader ()=default
 

Static Public Member Functions

static Ref< Shader > Create (const std::string &filepath)
 Creates a shader from a file.
 
static Ref< Shader > Create (const std::string &name, const std::string &vertexSrc, const std::string &fragmentSrc)
 Creates a new shader from vertex and fragment shader source code.
 

Detailed Description

An abstraction for a shader program.

Constructor & Destructor Documentation

◆ ~Shader()

virtual Muto::Shader::~Shader ( )
virtualdefault

Member Function Documentation

◆ Bind()

virtual void Muto::Shader::Bind ( ) const
pure virtual

connects the shader program for use.

Implemented in Muto::OpenGLShader.

◆ Create() [1/2]

Ref< Shader > Muto::Shader::Create ( const std::string &  filepath)
static

Creates a shader from a file.

Parameters
filepathThe path to the shader file to load.
Returns
A reference to the created shader object.
Todo:
Adjust function to return a MutoResult and have the shader as an out parameter, to allow for error handling during shader compilation.
10 {
11 switch (Renderer::GetAPI())
12 {
13 case RenderAPI::API::RAPI_None: MU_CORE_ASSERT(false, "RenderAPI::None is currently not supported!"); return nullptr;
15 }
16 MU_CORE_ASSERT(false, "Unknown RenderAPI!");
17 return nullptr;
18 }
#define MU_CORE_ASSERT(x,...)
Definition Asserts.h:32
static RenderAPI::API GetAPI()
Retrieves the current rendering API.
Definition Renderer.h:44
constexpr Scope< T > CreateScope(Args &&... args)
Creates a Scope (unique_ptr) for the given type and constructor arguments.
Definition Defines_Macros.h:51

References Muto::Renderer::GetAPI(), Muto::RenderAPI::RAPI_None, and Muto::RenderAPI::RAPI_OpenGL.

◆ Create() [2/2]

Ref< Shader > Muto::Shader::Create ( const std::string &  name,
const std::string &  vertexSrc,
const std::string &  fragmentSrc 
)
static

Creates a new shader from vertex and fragment shader source code.

Parameters
nameThe name to assign to the shader.
vertexSrcThe vertex shader source code as a string.
fragmentSrcThe fragment shader source code as a string.
Returns
A reference to the newly created shader object.
Todo:
Adjust function to return a MutoResult and have the shader as an out parameter, to allow for error handling during shader compilation.
21 {
22 switch (Renderer::GetAPI())
23 {
24 case RenderAPI::API::RAPI_None: MU_CORE_ASSERT(false, "RenderAPI::None is currently not supported!"); return nullptr;
26 }
27 MU_CORE_ASSERT(false, "Unknown RenderAPI!");
28 return nullptr;
29 }

References Muto::Renderer::GetAPI(), Muto::RenderAPI::RAPI_None, and Muto::RenderAPI::RAPI_OpenGL.

◆ GetName()

virtual const std::string & Muto::Shader::GetName ( ) const
pure virtual

Implemented in Muto::OpenGLShader.

◆ SetFloat()

virtual void Muto::Shader::SetFloat ( const std::string &  name,
float  value 
)
pure virtual

Sets a single float uniform in the shader.

Implemented in Muto::OpenGLShader.

◆ SetFloat3()

virtual void Muto::Shader::SetFloat3 ( const std::string &  name,
const glm::vec3 &  value 
)
pure virtual

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

Implemented in Muto::OpenGLShader.

◆ SetFloat4()

virtual void Muto::Shader::SetFloat4 ( const std::string &  name,
const glm::vec4 &  value 
)
pure virtual

Sets a 4-component float vector uniform in the shader.

Implemented in Muto::OpenGLShader.

◆ SetInt()

virtual void Muto::Shader::SetInt ( const std::string &  name,
int  value 
)
pure virtual

Sets a single integer uniform in the shader.

Implemented in Muto::OpenGLShader.

◆ SetIntArray()

virtual void Muto::Shader::SetIntArray ( const std::string &  name,
int *  values,
uint32_t  count 
)
pure virtual

Sets an array of integers uniform in the shader.

Implemented in Muto::OpenGLShader.

◆ SetMat4()

virtual void Muto::Shader::SetMat4 ( const std::string &  name,
const glm::mat4 &  value 
)
pure virtual

Sets a 4x4 matrix uniform in the shader.

Implemented in Muto::OpenGLShader.

◆ Unbind()

virtual void Muto::Shader::Unbind ( ) const
pure virtual

disconnects the shader program.

Implemented in Muto::OpenGLShader.


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