123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- #ifndef __cocos2d_libs__CCMaterial__
- #define __cocos2d_libs__CCMaterial__
- #include <string>
- #include "renderer/CCRenderState.h"
- #include "renderer/CCTechnique.h"
- #include "base/CCRef.h"
- #include "base/CCVector.h"
- #include "math/Vec2.h"
- #include "math/Vec3.h"
- #include "math/Vec4.h"
- #include "math/Mat4.h"
- #include "platform/CCPlatformMacros.h"
- NS_CC_BEGIN
- class Technique;
- class Pass;
- class GLProgramState;
- class Node;
- class Properties;
- class CC_DLL Material : public RenderState
- {
- friend class Node;
- friend class Technique;
- friend class Pass;
- friend class MeshCommand;
- friend class Renderer;
- friend class Mesh;
- public:
-
- static Material* createWithFilename(const std::string& path);
-
- static Material* createWithGLStateProgram(GLProgramState* programState);
-
- static Material* createWithProperties(Properties* materialProperties);
-
- std::string getName() const;
-
- void setName(const std::string& name);
-
- Technique* getTechniqueByName(const std::string& name);
-
- Technique* getTechniqueByIndex(ssize_t index);
-
- Technique* getTechnique() const;
-
- const Vector<Technique*>& getTechniques() const;
-
- ssize_t getTechniqueCount() const;
-
- void addTechnique(Technique* technique);
-
- void setTechnique(const std::string& techniqueName);
-
- virtual Material* clone() const;
- protected:
- Material();
- ~Material();
- bool initWithGLProgramState(GLProgramState* state);
- bool initWithFile(const std::string& file);
- bool initWithProperties(Properties* materialProperties);
- void setTarget(Node* target);
- bool parseProperties(Properties* properties);
- bool parseTechnique(Properties* properties);
- bool parsePass(Technique* technique, Properties* properties);
- bool parseShader(Pass* pass, Properties* properties);
- bool parseSampler(GLProgramState* glProgramState, Properties* properties);
- bool parseUniform(GLProgramState* programState, Properties* properties, const char* uniformName);
- bool parseRenderState(RenderState* renderState, Properties* properties);
-
-
-
- std::string _name;
-
- Vector<Technique*> _techniques;
-
- Technique* _currentTechnique;
-
- Node* _target;
- };
- NS_CC_END
- #endif
|