axmol/cocos/renderer/CCPrimitive.h

93 lines
2.9 KiB
C
Raw Normal View History

2014-07-31 13:52:39 +08:00
/****************************************************************************
2016-08-05 09:42:15 +08:00
Copyright (c) 2013-2016 Chukong Technologies Inc.
2014-08-07 15:53:20 +08:00
2014-07-31 13:52:39 +08:00
http://www.cocos2d-x.org
2014-08-07 15:53:20 +08:00
2014-07-31 13:52:39 +08:00
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
2014-08-07 15:53:20 +08:00
2014-07-31 13:52:39 +08:00
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
2014-08-07 15:53:20 +08:00
2014-07-31 13:52:39 +08:00
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#ifndef __CC_PRIMITIVE_H__
#define __CC_PRIMITIVE_H__
#include "renderer/CCVertexIndexData.h"
/**
* @addtogroup renderer
* @{
*/
2014-07-31 13:52:39 +08:00
NS_CC_BEGIN
2014-08-29 15:39:52 +08:00
class IndexBuffer;
/**
Primitive can support sending points, lines and triangles to glpipeline, which is an abstraction
of primitive data.
*/
2014-08-12 11:56:21 +08:00
class CC_DLL Primitive : public Ref
2014-07-31 13:52:39 +08:00
{
public:
/**
Create an instance of primitive.
@param verts VertexData used in the primitive.
@param indices Optional index data.
@param type The type (Points, Lines, Triangles) used.
*/
2014-08-05 17:49:35 +08:00
static Primitive* create(VertexData* verts, IndexBuffer* indices, int type);
/**Get the vertexData.*/
const VertexData* getVertexData() const;
/**Get the optional index data, will return null if index data is not used.*/
const IndexBuffer* getIndexData() const;
/**Get the primitive type.*/
2014-08-05 17:49:35 +08:00
int getType() const { return _type; }
2014-08-01 14:46:35 +08:00
/**called by rendering framework, will send the data to GLPipeline.*/
2014-08-01 14:46:35 +08:00
void draw();
2014-08-04 17:00:08 +08:00
/**Get the start index of primitive.*/
2014-08-04 17:00:08 +08:00
int getStart() const { return _start; }
/**Get the number of vertices or indices used for drawing.*/
2014-08-04 17:00:08 +08:00
int getCount() const { return _count; }
/**Setter for the start index.*/
2015-08-26 06:07:03 +08:00
void setStart(int start);
/**Setter for the count. */
2015-08-26 06:07:03 +08:00
void setCount(int count);
2014-08-04 17:00:08 +08:00
2014-07-31 13:52:39 +08:00
protected:
Primitive();
virtual ~Primitive();
2014-08-05 17:49:35 +08:00
bool init(VertexData* verts, IndexBuffer* indices, int type);
2014-07-31 13:52:39 +08:00
protected:
VertexData* _verts;
2014-08-04 17:00:08 +08:00
IndexBuffer* _indices;
int _start;
int _count;
2014-08-05 17:49:35 +08:00
int _type;
2014-07-31 13:52:39 +08:00
};
NS_CC_END
/**
end of support group
@}
*/
2014-07-31 13:52:39 +08:00
#endif //__CC_PRIMITIVE_H__