Carpenter Engine
A C++ game engine with a build once run anywhere solution
|
an semi-abstract class that represents a material to a shader More...
#include <Material.hpp>
Public Member Functions | |
Material (Shader *referenceShader) | |
The default constructor. | |
void | CreateParameter (const char *name, MaterialParameterType type) |
Creates a parameter for the material. | |
void * | SetParameter (const char *name, void *value) |
Sets the value of a parameter. | |
Engine::Success | ApplyMaterialParams () |
Applies both the material values to the shader. | |
Shader * | GetShader () |
Gets the shader used by the material. | |
an semi-abstract class that represents a material to a shader
This class is used to create a material that can be used with a shader. Materials are used to pass data to the shader, and to tell the shader how to handle that data. To create a material, you must first assign a shader to the material. From there, you tell the material what the parameters of the shader are, and what values the shader should use for those parameters. This is done with the CreateParameter
and SetParameter
methods.
There are two ways to create a materials:
Engine::Graphics::Material::Material | ( | Shader * | referenceShader | ) |
The default constructor.
Takes in a shader to use as a reference for the material.
Engine::Success Engine::Graphics::Material::ApplyMaterialParams | ( | ) |
Applies both the material values to the shader.
This method gets called by the renderer when the material is applied.
void Engine::Graphics::Material::CreateParameter | ( | const char * | name, |
MaterialParameterType | type | ||
) |
Creates a parameter for the material.
This method takes in a parameter name and a parameter type and keeps track of the parameters in the material. This method will throw an error if the parameter already exists.
name | The name of the parameter |
type | The type of the parameter |
Engine::Graphics::Shader * Engine::Graphics::Material::GetShader | ( | ) |
Gets the shader used by the material.
@reutnrs The shader used by the material
void * Engine::Graphics::Material::SetParameter | ( | const char * | name, |
void * | value | ||
) |
Sets the value of a parameter.
This method takes a reference to a value and assigns it to the parameter with the specified name. This method will throw an error if the parameter does not exist.
You can either pass a dynamic variable, or a pointer to an existing value. There is however no pointer safety, but the method returns a void pointer to the value that was set.
name | The name of the parameter |
value | The value to assign to the parameter |