RenderPath.pkg 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. $#include "Graphics/RenderPath.h"
  2. enum RenderCommandType
  3. {
  4. CMD_NONE = 0,
  5. CMD_CLEAR,
  6. CMD_SCENEPASS,
  7. CMD_QUAD,
  8. CMD_FORWARDLIGHTS,
  9. CMD_LIGHTVOLUMES,
  10. CMD_RENDERUI
  11. };
  12. enum RenderCommandSortMode
  13. {
  14. SORT_FRONTTOBACK = 0,
  15. SORT_BACKTOFRONT
  16. };
  17. enum RenderTargetSizeMode
  18. {
  19. SIZE_ABSOLUTE = 0,
  20. SIZE_VIEWPORTDIVISOR,
  21. SIZE_VIEWPORTMULTIPLIER
  22. };
  23. struct RenderTargetInfo
  24. {
  25. RenderTargetInfo();
  26. void Load(const XMLElement& element);
  27. String name_ @ name;
  28. String tag_ @ tag;
  29. unsigned format_ @ format;
  30. Vector2 size_ @ size;
  31. RenderTargetSizeMode sizeMode_ @ sizeMode;
  32. bool enabled_ @ enabled;
  33. bool cubemap_ @ cubemap;
  34. bool filtered_ @ filtered;
  35. bool sRGB_ @ sRGB;
  36. bool persistent_ @ persistent;
  37. };
  38. struct RenderPathCommand
  39. {
  40. RenderPathCommand();
  41. void Load(const XMLElement& element);
  42. void SetTextureName(TextureUnit unit, const String name);
  43. void SetShaderParameter(const String name, const Variant& value);
  44. void RemoveShaderParameter(const String name);
  45. void SetNumOutputs(unsigned num);
  46. void SetOutput(unsigned index, const String name, CubeMapFace face);
  47. void SetOutputName(unsigned index, const String name);
  48. void SetOutputFace(unsigned index, CubeMapFace face);
  49. void SetDepthStencilName(const String name);
  50. const String GetTextureName(TextureUnit unit) const;
  51. const Variant& GetShaderParameter(const String name) const;
  52. unsigned GetNumOutputs() const;
  53. const String GetOutputName(unsigned index) const;
  54. CubeMapFace GetOutputFace(unsigned index) const;
  55. const String GetDepthStencilName() const;
  56. String tag_ @ tag;
  57. RenderCommandType type_ @ type;
  58. RenderCommandSortMode sortMode_ @ sortMode;
  59. String pass_ @ pass;
  60. String metadata_ @ metadata;
  61. String vertexShaderName_ @ vertexShaderName;
  62. String pixelShaderName_ @ pixelShaderName;
  63. String vertexShaderDefines_ @ vertexShaderDefines;
  64. String pixelShaderDefines_ @ pixelShaderDefines;
  65. unsigned clearFlags_ @ clearFlags;
  66. Color clearColor_ @ clearColor;
  67. float clearDepth_ @ clearDepth;
  68. unsigned clearStencil_ @ clearStencil;
  69. BlendMode blendMode_ @ blendMode;
  70. bool enabled_ @ enabled;
  71. bool useFogColor_ @ useFogColor;
  72. bool markToStencil_ @ markToStencil;
  73. bool useLitBase_ @ useLitBase;
  74. bool vertexLights_ @ vertexLights;
  75. };
  76. class RenderPath
  77. {
  78. // SharedPtr<RenderPath> Clone();
  79. tolua_outside RenderPath* RenderPathClone @ Clone();
  80. bool Load(XMLFile* file);
  81. bool Append(XMLFile* file);
  82. void SetEnabled(const String tag, bool active);
  83. void ToggleEnabled(const String tag);
  84. void SetRenderTarget(unsigned index, const RenderTargetInfo& info);
  85. void AddRenderTarget(const RenderTargetInfo& info);
  86. void RemoveRenderTarget(const String name);
  87. void RemoveRenderTarget(unsigned index);
  88. void RemoveRenderTargets(const String tag);
  89. void SetCommand(unsigned index, const RenderPathCommand& command);
  90. void AddCommand(const RenderPathCommand& command);
  91. void InsertCommand(unsigned index, const RenderPathCommand& command);
  92. void RemoveCommand(unsigned index);
  93. void RemoveCommands(const String tag);
  94. void SetShaderParameter(const String name, const Variant& value);
  95. unsigned GetNumRenderTargets() const;
  96. unsigned GetNumCommands() const;
  97. RenderPathCommand* GetCommand(unsigned index);
  98. const Variant& GetShaderParameter(const String name) const;
  99. };
  100. ${
  101. static RenderPath* RenderPathClone(RenderPath* renderPath)
  102. {
  103. if (!renderPath)
  104. return 0;
  105. SharedPtr<RenderPath> clonedRenderPathPtr = renderPath->Clone();
  106. RenderPath* clonedRenderPath = clonedRenderPathPtr.Get();
  107. clonedRenderPathPtr.Detach();
  108. return clonedRenderPath;
  109. }
  110. $}