1$#include "Graphics/Technique.h"
2
3enum PassLightingMode
4{
5    LIGHTING_UNLIT,
6    LIGHTING_PERVERTEX,
7    LIGHTING_PERPIXEL
8};
9
10class Pass : public RefCounted
11{
12    void SetBlendMode(BlendMode mode);
13    void SetCullMode(CullMode mode);
14    void SetDepthTestMode(CompareMode mode);
15    void SetLightingMode(PassLightingMode mode);
16    void SetDepthWrite(bool enable);
17    void SetAlphaToCoverage(bool enable);
18    void SetIsDesktop(bool enable);
19    void SetVertexShader(const String name);
20    void SetPixelShader(const String name);
21    void SetVertexShaderDefines(const String defines);
22    void SetPixelShaderDefines(const String defines);
23    void SetVertexShaderDefineExcludes(const String excludes);
24    void SetPixelShaderDefineExcludes(const String excludes);
25    void ReleaseShaders();
26
27    const String GetName() const;
28    unsigned GetIndex() const;
29    CullMode GetCullMode() const;
30    BlendMode GetBlendMode() const;
31    CompareMode GetDepthTestMode() const;
32    PassLightingMode GetLightingMode() const;
33    bool GetDepthWrite() const;
34    bool GetAlphaToCoverage() const;
35    bool IsDesktop() const;
36    const String GetVertexShader() const;
37    const String GetPixelShader() const;
38    const String GetVertexShaderDefines() const;
39    const String GetPixelShaderDefines() const;
40    const String GetVertexShaderDefineExcludes() const;
41    const String GetPixelShaderDefineExcludes() const;
42
43    tolua_readonly tolua_property__get_set String name;
44    tolua_readonly tolua_property__get_set unsigned index;
45    tolua_property__get_set BlendMode blendMode;
46    tolua_property__get_set CullMode cullMode;
47    tolua_property__get_set CompareMode depthTestMode;
48    tolua_property__get_set PassLightingMode lightingMode;
49    tolua_property__get_set bool depthWrite;
50    tolua_property__get_set bool alphaToCoverage;
51    tolua_readonly tolua_property__is_set bool desktop;
52    tolua_property__get_set String vertexShader;
53    tolua_property__get_set String pixelShader;
54    tolua_property__get_set String vertexShaderDefines;
55    tolua_property__get_set String pixelShaderDefines;
56    tolua_property__get_set String vertexShaderDefineExcludes;
57    tolua_property__get_set String pixelShaderDefineExcludes;
58};
59
60class Technique : public Resource
61{
62    void SetIsDesktop(bool enable);
63    Pass* CreatePass(const String passName);
64    void RemovePass(const String passName);
65    void ReleaseShaders();
66    tolua_outside Technique* TechniqueClone @ Clone(const String cloneName = String::EMPTY) const;
67
68    bool HasPass(const String type) const;
69    Pass* GetPass(const String type) const;
70    Pass* GetSupportedPass(const String type) const;
71    bool IsSupported() const;
72    bool IsDesktop() const;
73    unsigned GetNumPasses() const;
74    tolua_outside const Vector<String>& TechniqueGetPassNames @ GetPassTypes() const;
75    tolua_outside const PODVector<Pass*>& TechniqueGetPasses @ GetPasses() const;
76
77    tolua_readonly tolua_property__is_set bool supported;
78    tolua_readonly tolua_property__is_set bool desktop;
79    tolua_readonly tolua_property__get_set unsigned numPasses;
80};
81
82${
83static const Vector<String>& TechniqueGetPassNames(const Technique* technique)
84{
85    static Vector<String> vector = technique->GetPassNames();
86    return vector;
87}
88
89static const PODVector<Pass*>& TechniqueGetPasses(const Technique* technique)
90{
91    static PODVector<Pass*> vector = technique->GetPasses();
92    return vector;
93}
94
95static Technique* TechniqueClone(const Technique* technique, const String& cloneName = String::EMPTY)
96{
97    if (!technique)
98        return 0;
99
100    SharedPtr<Technique> clonedTechniquePtr = technique->Clone(cloneName);
101    Technique* clonedTechnique = clonedTechniquePtr.Get();
102    clonedTechniquePtr.Detach();
103
104    return clonedTechnique;
105}
106$}
107