123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- #ifndef _CC_MESHCOMMAND_H_
- #define _CC_MESHCOMMAND_H_
- #include <unordered_map>
- #include "renderer/CCRenderCommand.h"
- #include "renderer/CCGLProgram.h"
- #include "renderer/CCRenderState.h"
- #include "math/CCMath.h"
- NS_CC_BEGIN
- class GLProgramState;
- class EventListenerCustom;
- class EventCustom;
- class Material;
- class CC_DLL MeshCommand : public RenderCommand
- {
- public:
- MeshCommand();
- virtual ~MeshCommand();
- void init(float globalZOrder, Material* material, GLuint vertexBuffer, GLuint indexBuffer, GLenum primitive, GLenum indexFormat, ssize_t indexCount, const Mat4 &mv, uint32_t flags);
- void init(float globalZOrder, GLuint textureID, GLProgramState* glProgramState, RenderState::StateBlock* stateBlock, GLuint vertexBuffer, GLuint indexBuffer, GLenum primitive, GLenum indexFormat, ssize_t indexCount, const Mat4 &mv, uint32_t flags);
- void setDisplayColor(const Vec4& color);
- void setMatrixPalette(const Vec4* matrixPalette);
- void setMatrixPaletteSize(int size);
- void setLightMask(unsigned int lightmask);
- void execute();
-
-
- void preBatchDraw();
- void batchDraw();
- void postBatchDraw();
-
- void genMaterialID(GLuint texID, void* glProgramState, GLuint vertexBuffer, GLuint indexBuffer, BlendFunc blend);
-
- uint32_t getMaterialID() const;
-
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
- void listenRendererRecreated(EventCustom* event);
- #endif
- protected:
-
- void buildVAO();
- void releaseVAO();
-
-
- void applyRenderState();
- Vec4 _displayColor;
-
-
- const Vec4* _matrixPalette;
- int _matrixPaletteSize;
-
- uint32_t _materialID;
-
- GLuint _vao;
-
- GLuint _vertexBuffer;
- GLuint _indexBuffer;
- GLenum _primitive;
- GLenum _indexFormat;
- ssize_t _indexCount;
-
-
-
- Mat4 _mv;
-
-
- Material* _material;
-
-
- GLProgramState* _glProgramState;
- RenderState::StateBlock* _stateBlock;
- GLuint _textureID;
- #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
- EventListenerCustom* _rendererRecreatedListener;
- #endif
- };
- NS_CC_END
- #endif
|