Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #pragma once
- #include "Property.h"
- namespace key{
- // When adding to this, also update the following
- // - ShaderManager.cpp::getSize()
- // - GetShaderTypeName
- enum AttributeType{
- AT_FLOAT_VEC2 = GL_FLOAT_VEC2,
- AT_FLOAT_VEC3 = GL_FLOAT_VEC3,
- AT_FLOAT_VEC4 = GL_FLOAT_VEC4
- };
- // When adding to this, also update the following
- // - ShaderManager.cpp::getSize()
- // - GetShaderTypeName
- enum UniformType{
- UT_FLOAT_MAT4 = GL_FLOAT_MAT4
- };
- template<typename Variable, typename Type>
- class ShaderVariable{
- friend class ShaderManager;
- friend std::ostream& operator<<(std::ostream& out, const ShaderVariable<Variable, Type>& sv){
- return out<<"Variable{"<<sv._eVariable<<"} of type {"<<GetShaderTypeName(sv._eType)<<"}";
- }
- private:
- Variable _eVariable;
- Type _eType;
- public:
- ShaderVariable(Variable var, Type type);
- inline bool operator==(const ShaderVariable<Variable, Type>& rhs) const;
- };
- template<typename Variable, typename Type>
- inline bool ShaderVariable<Variable, Type>::operator==(const ShaderVariable<Variable, Type>& rhs) const{
- return (_eVariable == rhs._eVariable && _eType == rhs._eType);
- }
- template<typename Type>
- std::string GetShaderTypeName(Type type){
- switch(type){
- case AT_FLOAT_VEC2:
- return "float_vec2";
- case AT_FLOAT_VEC3:
- return "float_vec3";
- case AT_FLOAT_VEC4:
- return "float_vec4";
- case UT_FLOAT_MAT4:
- return "float_mat4";
- default:
- return "Type not specified in GetShaderTypeName.";
- }
- }
- typedef ShaderVariable<Attribute, AttributeType> ShaderAttribute;
- typedef ShaderVariable<Uniform, UniformType> ShaderUniform;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement