OGLShaderVariation.h 2.7 KB

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