Advertisement
Guest User

Untitled

a guest
Nov 30th, 2014
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. #pragma once
  2.  
  3. #include "Property.h"
  4.  
  5. namespace key{
  6.  
  7. // When adding to this, also update the following
  8. // - ShaderManager.cpp::getSize()
  9. // - GetShaderTypeName
  10. enum AttributeType{
  11. AT_FLOAT_VEC2 = GL_FLOAT_VEC2,
  12. AT_FLOAT_VEC3 = GL_FLOAT_VEC3,
  13. AT_FLOAT_VEC4 = GL_FLOAT_VEC4
  14. };
  15.  
  16. // When adding to this, also update the following
  17. // - ShaderManager.cpp::getSize()
  18. // - GetShaderTypeName
  19. enum UniformType{
  20. UT_FLOAT_MAT4 = GL_FLOAT_MAT4
  21. };
  22.  
  23. template<typename Variable, typename Type>
  24. class ShaderVariable{
  25. friend class ShaderManager;
  26. friend std::ostream& operator<<(std::ostream& out, const ShaderVariable<Variable, Type>& sv){
  27. return out<<"Variable{"<<sv._eVariable<<"} of type {"<<GetShaderTypeName(sv._eType)<<"}";
  28. }
  29. private:
  30. Variable _eVariable;
  31. Type _eType;
  32.  
  33. public:
  34. ShaderVariable(Variable var, Type type);
  35.  
  36. inline bool operator==(const ShaderVariable<Variable, Type>& rhs) const;
  37. };
  38.  
  39. template<typename Variable, typename Type>
  40. inline bool ShaderVariable<Variable, Type>::operator==(const ShaderVariable<Variable, Type>& rhs) const{
  41. return (_eVariable == rhs._eVariable && _eType == rhs._eType);
  42. }
  43.  
  44. template<typename Type>
  45. std::string GetShaderTypeName(Type type){
  46. switch(type){
  47. case AT_FLOAT_VEC2:
  48. return "float_vec2";
  49. case AT_FLOAT_VEC3:
  50. return "float_vec3";
  51. case AT_FLOAT_VEC4:
  52. return "float_vec4";
  53. case UT_FLOAT_MAT4:
  54. return "float_mat4";
  55. default:
  56. return "Type not specified in GetShaderTypeName.";
  57. }
  58. }
  59.  
  60. typedef ShaderVariable<Attribute, AttributeType> ShaderAttribute;
  61. typedef ShaderVariable<Uniform, UniformType> ShaderUniform;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement