1010#include " math/CCMath.h"
1111#include " renderer/CCGLProgram.h"
1212
13-
1413NS_CC_BEGIN
1514
1615/* *
@@ -41,10 +40,8 @@ struct MeshVertexAttrib
4140 GLint size;
4241 // GL_FLOAT
4342 GLenum type;
44-
4543 // VERTEX_ATTRIB_POSITION,VERTEX_ATTRIB_COLOR,VERTEX_ATTRIB_TEX_COORD,VERTEX_ATTRIB_NORMAL, GLProgram for detail
4644 int vertexAttrib;
47-
4845 // size in bytes
4946 int attribSizeBytes;
5047};
@@ -56,9 +53,7 @@ class RenderMeshData
5653 RenderMeshData (): _vertexsizeBytes(0 )
5754 {
5855 }
59-
6056 bool hasVertexAttrib (int attrib);
61-
6257 bool initFrom (std::vector<float >& posions, std::vector<float >& normals, std::vector<float >& texs, const std::vector<unsigned short >& indices);
6358
6459protected:
@@ -69,68 +64,49 @@ class RenderMeshData
6964 std::vector<MeshVertexAttrib> _vertexAttribs;
7065};
7166
72-
7367class Mesh : public Ref
7468{
7569public:
76-
77- virtual ~Mesh ();
78-
7970 // create
8071 static Mesh* create (std::vector<float >& posions, std::vector<float >& normals, std::vector<float >& texs, const std::vector<unsigned short >& indices);
81-
82- bool init (std::vector<float >& posions, std::vector<float >& normals, std::vector<float >& texs, const std::vector<unsigned short >& indices);
8372
8473 // get vertex buffer
8574 inline GLuint getVertexBuffer () const { return _vertexBuffer; }
8675
8776 // get mesh vertex attribute count
8877 int getMeshVertexAttribCount () const { return _renderdata._vertexAttribs .size (); }
89-
9078 // get MeshVertexAttribute by index
9179 const MeshVertexAttrib& getMeshVertexAttribute (int idx) const { return _renderdata._vertexAttribs [idx]; }
92-
9380 // has vertex attribute?
9481 bool hasVertexAttrib (int attrib) { return _renderdata.hasVertexAttrib (attrib); }
95-
9682 // get per vertex size in bytes
9783 int getVertexSizeInBytes () const { return _renderdata._vertexsizeBytes ; }
9884
9985 PrimitiveType getPrimitiveType () const { return _primitiveType; }
100-
10186 unsigned int getIndexCount () const { return _indexCount; }
102-
10387 IndexFormat getIndexFormat () const { return _indexFormat; }
104-
10588 GLuint getIndexBuffer () const {return _indexBuffer; }
10689
10790 // build vertex buffer from renderdata
10891 void restore ();
10992protected:
11093 Mesh ();
94+ virtual ~Mesh ();
95+ bool init (std::vector<float >& posions, std::vector<float >& normals, std::vector<float >& texs, const std::vector<unsigned short >& indices);
11196
11297 // build buffer
11398 void buildBuffer ();
114-
11599 void cleanAndFreeBuffers ();
116100
117- // void releaseMeshPart();
118-
119- // void addMeshPart(PrimitiveType primitiveType, IndexFormat indexformat, void* indexData, unsigned int indexCount);
120-
121101protected:
122- void countVertexData () const ;
123102 std::string _name;
124-
125103 GLuint _vertexBuffer;
126-
127104 PrimitiveType _primitiveType;
128105 IndexFormat _indexFormat;
129106 unsigned int _indexCount;
130107 GLuint _indexBuffer;
131108
132109private:
133-
134110 RenderMeshData _renderdata;
135111};
136112
0 commit comments