RenderPath.pkg 3.9 KB

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