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