CCDrawNode
#ifndef __CCDRAWNODES_CCDRAW_NODE_H__
#define __CCDRAWNODES_CCDRAW_NODE_H__
#include "base_nodes/CCNode.h"
#include "ccTypes.h"
NS_CC_BEGIN
/** CCDrawNode
Node that draws dots, segments and polygons.
Faster than the "drawing primitives" since they it draws everything in one single batch.
@since v2.1
*/
class CC_DLL CCDrawNode : public CCNode
{
protected:
GLuint m_uVao;
GLuint m_uVbo;
unsigned int m_uBufferCapacity;
GLsizei m_nBufferCount;
ccV2F_C4B_T2F *m_pBuffer;
ccBlendFunc m_sBlendFunc;
bool m_bDirty;
public:
static CCDrawNode* create();
virtual ~CCDrawNode();
virtual bool init();
virtual void draw();
/** draw a dot at a position, with a given radius and color */
void drawDot(const CCPoint &pos, float radius, const ccColor4F &color);
/** draw a segment with a radius and color */
void drawSegment(const CCPoint &from, const CCPoint &to, float radius, const ccColor4F &color);
/** draw a polygon with a fill color and line color */
void drawPolygon(CCPoint *verts, unsigned int count, const ccColor4F &fillColor, float borderWidth, const ccColor4F &borderColor);
/** Clear the geometry in the node's buffer. */
void clear();
ccBlendFunc getBlendFunc() const;
void setBlendFunc(const ccBlendFunc &blendFunc);
CCDrawNode();
private:
void ensureCapacity(unsigned int count);
void render();
};
NS_CC_END
#endif // __CCDRAWNODES_CCDRAW_NODE_H__
浙公网安备 33010602011771号