OGLShaderVariation.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // Urho3D Engine
  3. // Copyright (c) 2008-2011 Lasse Öörni
  4. //
  5. // Permission is hereby granted, free of charge, to any person obtaining a copy
  6. // of this software and associated documentation files (the "Software"), to deal
  7. // in the Software without restriction, including without limitation the rights
  8. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. // copies of the Software, and to permit persons to whom the Software is
  10. // furnished to do so, subject to the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be included in
  13. // all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. // THE SOFTWARE.
  22. //
  23. #pragma once
  24. #include "ArrayPtr.h"
  25. #include "GPUObject.h"
  26. #include "GraphicsDefs.h"
  27. #include "RefCounted.h"
  28. class Shader;
  29. class ShaderProgram;
  30. /// Vertex or pixel shader on the GPU.
  31. class ShaderVariation : public RefCounted, public GPUObject
  32. {
  33. public:
  34. /// Construct.
  35. ShaderVariation(Shader* shader, ShaderType type);
  36. /// Destruct.
  37. virtual ~ShaderVariation();
  38. /// Release the shader.
  39. virtual void Release();
  40. /// Compile the shader. Return true if successful.
  41. bool Create();
  42. /// Set name.
  43. void SetName(const String& name);
  44. /// Set source code.
  45. void SetSourceCode(const SharedArrayPtr<char>& code, unsigned length);
  46. /// Set defines.
  47. void SetDefines(const Vector<String>& defines);
  48. /// Return shader type.
  49. ShaderType GetShaderType() const { return shaderType_; }
  50. /// Return full shader name.
  51. const String& GetName() const { return name_; }
  52. /// Return defines.
  53. const Vector<String>& GetDefines() const { return defines_; }
  54. /// Return whether successfully compiled.
  55. bool IsCompiled() const { return compiled_; }
  56. /// Return compile error/warning string.
  57. const String& GetCompilerOutput() const { return compilerOutput_; }
  58. private:
  59. /// Shader type.
  60. ShaderType shaderType_;
  61. /// Full shader name.
  62. String name_;
  63. /// GLSL source code.
  64. SharedArrayPtr<char> sourceCode_;
  65. /// Source code length.
  66. unsigned sourceCodeLength_;
  67. /// Defines to use in compiling.
  68. Vector<String> defines_;
  69. /// Shader compile error string.
  70. String compilerOutput_;
  71. /// Compiled flag.
  72. bool compiled_;
  73. };