rag
graphic 2d engine
Public Types | Public Member Functions | Public Attributes | Friends | List of all members
rag::Material Class Reference

Represents a render material that would affect how objects will be rendered. More...

#include <Material.h>

Public Types

enum  EBlendMode { BLEND_NORMAL, BLEND_ADD, BLEND_PRE_ADD }
 

Public Member Functions

 Material (const std::string &vsh, const std::string &fsh)
 Default constructor using two paths for vertex and fragment shader respectively.
 
virtual ~Material ()
 Default destructor.
 
void setUniform (const std::string &name, float value)
 Set float shader uniform.
 
void setUniform (const std::string &name, const glm::vec2 &value)
 Set vec2 shader uniform.
 
void setUniform (const std::string &name, const glm::vec3 &value)
 Set vec3 shader uniform.
 
void setUniform (const std::string &name, const glm::vec4 &value)
 Set vec4 shader uniform.
 
void setUniform (const std::string &name, const glm::mat3 &value)
 Set mat3 shader uniform.
 
void setUniform (const std::string &name, const glm::mat4 &value)
 Set mat4 shader uniform.
 
const std::vector< TUniformVar > & getUniforms () const
 Returns the list of all uniforms related with the current shader program.
 

Public Attributes

std::string vsh
 Path for vertex shader.
 
std::string fsh
 Path for fragment shader.
 
int textureId
 Texture id.
 
EBlendMode blendMode
 Blending mode.
 
int priority
 Materials with higher priority are propagated down in the Display List.
 
bool stopsPropagation
 If true, no matter priorities, material won't be affected by parent materials.
 

Friends

class Renderer
 

Detailed Description

Represents a render material that would affect how objects will be rendered.

A Material is based in a vertex and fragment Shader. A texture is linked to the material, and a blend mode. Everything will contribute to the final result when the object is rendered.

Todo:
: Make a clearer design taking into account efficiency and naming convention. Refactor classes like Program, Shader. May make sense to allow change shader uniforms in Shader class instead of Material. DisplayObjects shold use Material references, and then have the ability to make copies if they need to modify something, (e.g., change shader uniforms).

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