CmMaterial.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include "CmMaterial.h"
  2. #include "CmException.h"
  3. #include "CmShader.h"
  4. #include "CmTechnique.h"
  5. namespace CamelotEngine
  6. {
  7. void Material::setShader(ShaderPtr shader)
  8. {
  9. mShader = shader;
  10. }
  11. void Material::throwIfNotInitialized() const
  12. {
  13. if(mShader == nullptr)
  14. {
  15. CM_EXCEPT(InternalErrorException, "Material does not have shader set.");
  16. }
  17. }
  18. void Material::setTexture(const String& name, TexturePtr value)
  19. {
  20. throwIfNotInitialized();
  21. }
  22. void Material::setFloat(const String& name, float value)
  23. {
  24. throwIfNotInitialized();
  25. }
  26. void Material::setColor(const String& name, const Color& value)
  27. {
  28. throwIfNotInitialized();
  29. }
  30. void Material::setVec(const String& name, const Vector2& value)
  31. {
  32. throwIfNotInitialized();
  33. }
  34. void Material::setVec(const String& name, const Vector3& value)
  35. {
  36. throwIfNotInitialized();
  37. }
  38. void Material::setVec(const String& name, const Vector4& value)
  39. {
  40. throwIfNotInitialized();
  41. }
  42. void Material::setMat(const String& name, const Matrix3& value)
  43. {
  44. throwIfNotInitialized();
  45. }
  46. void Material::setMat(const String& name, const Matrix4& value)
  47. {
  48. throwIfNotInitialized();
  49. }
  50. UINT32 Material::getNumPasses() const
  51. {
  52. throwIfNotInitialized();
  53. return mShader->getBestTechnique()->getNumPasses();
  54. }
  55. void Material::applyPass(UINT32 passIdx)
  56. {
  57. throwIfNotInitialized();
  58. // TODO - It's going to be very important to minimize the amount of texture (and less importantly) constant changes
  59. }
  60. }