[ci skip]update comments CCVertexIndexData.h

This commit is contained in:
Huabing.Xu 2015-03-18 14:43:44 +08:00
parent aa5f257243
commit eb2786f40d
1 changed files with 48 additions and 1 deletions

View File

@ -31,7 +31,18 @@
NS_CC_BEGIN
class VertexBuffer;
/**
VertexStreamAttribute is used to specify the vertex attribute for drawing, which is correspondent to
glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr)
_semantic -> index
_size -> size
_type -> type
_normalize -> normalized
_offset is used to compute the start offset in a interleaved array, take a V3F_C4B_T2F array,
offset of vertex will be 0, offset of color would be 0 + sizeof(float) * 3 = 12,
offset of texture coord would be 12 + sizeof(char) * 4 = 16
*/
struct CC_DLL VertexStreamAttribute
{
VertexStreamAttribute()
@ -56,30 +67,66 @@ struct CC_DLL VertexStreamAttribute
int _size;
};
/**
VertexData is a class used for specify input streams for GPU rendering pipeline,
a VertexData will be composed by several streams, every stream will contain a VertexStreamAttribute
and the binding VertexBuffer. streams will be identified by semantic
*/
class CC_DLL VertexData : public Ref
{
public:
/**
Create function, used to create a instance of VertexData
*/
static VertexData* create();
/*Get the number of streams in the VertexData*/
size_t getVertexStreamCount() const;
/**
Set a stream to VertexData,given that stream is identified by semantic, so if the semantic is not
specified before, it will add a stream, or it will override the old one
@param buffer The binding buffer of the stream
@param stream The binding vertex attribute, its member semantic will be used as the identifier.
*/
bool setStream(VertexBuffer* buffer, const VertexStreamAttribute& stream);
/**
Remove the given streams
@param semantic The semantic of the stream
*/
void removeStream(int semantic);
/**
Get the attribute of stream const version
@param semantic The semantic of the stream
*/
const VertexStreamAttribute* getStreamAttribute(int semantic) const;
/**
Get the attribute of stream
@param semantic The semantic of the stream
*/
VertexStreamAttribute* getStreamAttribute(int semantic);
/**
Get the binded buffer of the stream
@param semantic The semantic of the stream
*/
VertexBuffer* getStreamBuffer(int semantic) const;
/*Called for rendering, it will bind the state of vertex data to current rendering pipeline*/
void use();
protected:
/*Constructor*/
VertexData();
/*Destructor*/
virtual ~VertexData();
protected:
/*Simple struct to bundle buffer and attribute*/
struct BufferAttribute
{
VertexBuffer* _buffer;
VertexStreamAttribute _stream;
};
/*Streams in the VertexData*/
std::map<int, BufferAttribute> _vertexStreams;
};