axmol/cocos/2d/CCDrawNode.h

371 lines
13 KiB
C
Raw Normal View History

2012-11-09 12:08:18 +08:00
/* Copyright (c) 2012 Scott Lembcke and Howling Moon Software
* Copyright (c) 2012 cocos2d-x.org
2016-08-05 09:42:15 +08:00
* Copyright (c) 2013-2016 Chukong Technologies Inc.
2012-11-09 12:08:18 +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:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* 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.
*/
/*
* Code copied & pasted from SpacePatrol game https://github.com/slembcke/SpacePatrol
*
* Renamed and added some changes for cocos2d
*
*/
#ifndef __CCDRAWNODES_CCDRAW_NODE_H__
#define __CCDRAWNODES_CCDRAW_NODE_H__
#include "2d/CCNode.h"
2014-04-30 08:37:36 +08:00
#include "base/ccTypes.h"
#include "renderer/CCCustomCommand.h"
#include "math/CCMath.h"
2012-11-09 12:08:18 +08:00
NS_CC_BEGIN
static const int DEFAULT_LINE_WIDTH = 2;
class PointArray;
2015-03-21 17:06:26 +08:00
/**
* @addtogroup _2d
* @{
*/
2015-03-21 17:06:26 +08:00
/** @class DrawNode
* @brief Node that draws dots, segments and polygons.
* Faster than the "drawing primitives" since they draws everything in one single batch.
* @since v2.1
*/
class CC_DLL DrawNode : public Node
2012-11-09 12:08:18 +08:00
{
public:
2015-03-21 17:06:26 +08:00
/** creates and initialize a DrawNode node.
*
* @return Return an autorelease object.
*/
static DrawNode* create(GLfloat defaultLineWidth = DEFAULT_LINE_WIDTH);
2015-03-21 17:06:26 +08:00
/** Draw a point.
*
* @param point A Vec2 used to point.
* @param pointSize The point size.
* @param color The point color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawPoint(const Vec2& point, const float pointSize, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draw a group point.
*
* @param position A Vec2 pointer.
* @param numberOfPoints The number of points.
* @param color The point color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawPoints(const Vec2 *position, unsigned int numberOfPoints, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draw a group point.
*
* @param position A Vec2 pointer.
* @param numberOfPoints The number of points.
* @param pointSize The point size.
* @param color The point color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawPoints(const Vec2 *position, unsigned int numberOfPoints, const float pointSize, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draw an line from origin to destination with color.
*
* @param origin The line origin.
* @param destination The line destination.
* @param color The line color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawLine(const Vec2 &origin, const Vec2 &destination, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a rectangle given the origin and destination point measured in points.
* The origin and the destination can not have the same x and y coordinate.
*
* @param origin The rectangle origin.
* @param destination The rectangle destination.
* @param color The rectangle color.
*/
void drawRect(const Vec2 &origin, const Vec2 &destination, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a polygon given a pointer to point coordinates and the number of vertices measured in points.
* The polygon can be closed or open.
*
* @param poli A pointer to point coordinates.
* @param numberOfPoints The number of vertices measured in points.
* @param closePolygon The polygon can be closed or open.
* @param color The polygon color.
*/
void drawPoly(const Vec2 *poli, unsigned int numberOfPoints, bool closePolygon, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a circle given the center, radius and number of segments.
*
* @param center The circle center point.
* @param radius The circle rotate of radius.
2015-05-21 08:22:59 +08:00
* @param angle The circle angle.
2015-03-21 17:06:26 +08:00
* @param segments The number of segments.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
* @param scaleX The scale value in x.
* @param scaleY The scale value in y.
* @param color Set the circle color.
*/
void drawCircle( const Vec2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a circle given the center, radius and number of segments.
*
* @param center The circle center point.
* @param radius The circle rotate of radius.
2015-05-21 08:22:59 +08:00
* @param angle The circle angle.
2015-03-21 17:06:26 +08:00
* @param segments The number of segments.
* @param drawLineToCenter Whether or not draw the line from the origin to center.
* @param color Set the circle color.
*/
void drawCircle(const Vec2 &center, float radius, float angle, unsigned int segments, bool drawLineToCenter, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a quad bezier path.
*
* @param origin The origin of the bezier path.
* @param control The control of the bezier path.
* @param destination The destination of the bezier path.
* @param segments The number of segments.
2015-03-21 17:06:26 +08:00
* @param color Set the quad bezier color.
*/
void drawQuadBezier(const Vec2 &origin, const Vec2 &control, const Vec2 &destination, unsigned int segments, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draw a cubic bezier curve with color and number of segments
*
* @param origin The origin of the bezier path.
* @param control1 The first control of the bezier path.
* @param control2 The second control of the bezier path.
* @param destination The destination of the bezier path.
* @param segments The number of segments.
2015-03-21 17:06:26 +08:00
* @param color Set the cubic bezier color.
*/
void drawCubicBezier(const Vec2 &origin, const Vec2 &control1, const Vec2 &control2, const Vec2 &destination, unsigned int segments, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a Cardinal Spline path.
*
* @param config A array point.
* @param tension The tension of the spline.
* @param segments The number of segments.
2015-03-21 17:06:26 +08:00
* @param color Set the Spline color.
*/
void drawCardinalSpline(PointArray *config, float tension, unsigned int segments, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a Catmull Rom path.
*
* @param points A point array of control point.
* @param segments The number of segments.
2015-03-21 17:06:26 +08:00
* @param color The Catmull Rom color.
*/
void drawCatmullRom(PointArray *points, unsigned int segments, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** draw a dot at a position, with a given radius and color.
*
* @param pos The dot center.
* @param radius The dot radius.
* @param color The dot color.
*/
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void drawDot(const Vec2 &pos, float radius, const Color4F &color);
2012-11-09 12:08:18 +08:00
2015-03-21 17:06:26 +08:00
/** Draws a rectangle with 4 points.
*
* @param p1 The rectangle vertex point.
* @param p2 The rectangle vertex point.
* @param p3 The rectangle vertex point.
* @param p4 The rectangle vertex point.
* @param color The rectangle color.
*/
2015-01-07 11:44:16 +08:00
void drawRect(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Vec2& p4, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a solid rectangle given the origin and destination point measured in points.
* The origin and the destination can not have the same x and y coordinate.
*
* @param origin The rectangle origin.
* @param destination The rectangle destination.
* @param color The rectangle color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawSolidRect(const Vec2 &origin, const Vec2 &destination, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
*
* @param poli A solid polygon given a pointer to CGPoint coordinates.
* @param numberOfPoints The number of vertices measured in points.
* @param color The solid polygon color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawSolidPoly(const Vec2 *poli, unsigned int numberOfPoints, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
* @param radius The circle rotate of radius.
2015-05-21 08:22:59 +08:00
* @param angle The circle angle.
2015-03-21 17:06:26 +08:00
* @param segments The number of segments.
* @param scaleX The scale value in x.
* @param scaleY The scale value in y.
* @param color The solid circle color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** Draws a solid circle given the center, radius and number of segments.
* @param center The circle center point.
* @param radius The circle rotate of radius.
2015-05-21 08:22:59 +08:00
* @param angle The circle angle.
2015-03-21 17:06:26 +08:00
* @param segments The number of segments.
* @param color The solid circle color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
void drawSolidCircle(const Vec2& center, float radius, float angle, unsigned int segments, const Color4F& color);
2015-03-21 17:06:26 +08:00
/** draw a segment with a radius and color.
*
* @param from The segment origin.
* @param to The segment destination.
* @param radius The segment radius.
* @param color The segment color.
*/
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void drawSegment(const Vec2 &from, const Vec2 &to, float radius, const Color4F &color);
2012-11-09 12:08:18 +08:00
/** draw a polygon with a fill color and line color
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var drawPolygon(var Arrayofpoints, var fillColor, var width, var borderColor)
* In lua:local drawPolygon(local pointTable,local tableCount,local fillColor,local width,local borderColor)
* @endcode
2015-03-21 17:06:26 +08:00
* @param verts A pointer to point coordinates.
* @param count The number of verts measured in points.
* @param fillColor The color will fill in polygon.
* @param borderWidth The border of line width.
* @param borderColor The border of line color.
* @js NA
*/
void drawPolygon(const Vec2 *verts, int count, const Color4F &fillColor, float borderWidth, const Color4F &borderColor);
2015-03-21 17:06:26 +08:00
/** draw a triangle with color.
*
* @param p1 The triangle vertex point.
* @param p2 The triangle vertex point.
* @param p3 The triangle vertex point.
* @param color The triangle color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
Squashed commit of the following: commit a9572b8913f3a38b59adbd7b4017ab9848a6b2b5 Author: Ricardo Quesada <ricardoquesada@gmail.com> Date: Wed May 14 10:03:44 2014 -0700 math renames `Vector2` -> `Vec2` `Vector3` -> `Vec3` `Vector4` -> `Vec4` `Matrix` -> `Mat4` commit 4e107f4bd854c26bfceb52b063d6bd9cea02d6a3 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:24:28 2014 -0700 raw version of rename Vector3 commit 1d115573ebe96a5fc815fa44fbe6417ea7dba841 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:07:14 2014 -0700 rename Vector2 after merge commit ab2ed58c129dbc30a4c0970ed94568c5d271657b Merge: 1978d2d 86fb75a Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 09:05:30 2014 -0700 Merge branch 'v3' into v3_renameMathClassName Conflicts: tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UIButtonTest/UIButtonTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UICheckBoxTest/UICheckBoxTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UISliderTest/UISliderTest_Editor.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest.cpp tests/cpp-tests/Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp commit 1978d2d174877172ccddc083020a1bbf43ad3b39 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 08:51:45 2014 -0700 rename vector2 in tests/cpp-empty-test folder commit d4e0ff13dcce62724d2fece656543f26aa28e467 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:58:23 2014 -0700 rename vector2 in tests/cpp-tests cpp files commit be50ca2ec75e0fd32a6fcdaa15fe1ebb4cafe79f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:52:57 2014 -0700 rename vector2 in tests/cpp-tests head files commit 6daef564400d4e28c4ce20859a68e0f583fed125 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:49:48 2014 -0700 rename vector2 in extension folder commit 8f3f0f65ceea92c9e7a0d87ab54e62220c5572e2 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:47:22 2014 -0700 rename vector2 in cocos/2d cpp files commit e1f3105aae06d595661a3030f519f7cc13aefbed Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:44:39 2014 -0700 rename vector2 in cocos/2d head files commit 6708d890bfe486109120c3cd4b9fe5c078b7108f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:59 2014 -0700 rename vector2 in cocos/base folder commit d3978fa5447c31ea2f3ece5469b7e746dfba4248 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:43 2014 -0700 rename vector2 in cocos/deprecated folder commit 4bff45139363d6b9706edbbcf9f322d48b4fd019 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:40:26 2014 -0700 rename vector2 in cocos/editor-support folder commit 353d244c995f8b5d14f635c52aed8bc5e5fc1a6f Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:36:48 2014 -0700 rename vector2 in cocos/ui folder commit 758b8f4d513084b9922d7242e9b8f2c7f316de6c Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:39 2014 -0700 rename vector2 in cocos/renderer folder commit 0bd2710dd8714cecb993880bc37affd9ecb05c27 Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:32:15 2014 -0700 rename vector2 in cocos/physics folder commit b7f0581c4587348bdbc1478d5374c2325735f21d Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:25:01 2014 -0700 rename vector2 in cocos/math folder commit a8631a8e1a4e2740807ccd9be9d70de6ecaad7dd Author: Huabing.Xu <dabingnn@gmail.com> Date: Wed May 14 00:16:55 2014 -0700 rename Vector2 to Vec2 deprecate typedef Vector2
2014-05-15 01:07:09 +08:00
void drawTriangle(const Vec2 &p1, const Vec2 &p2, const Vec2 &p3, const Color4F &color);
2015-03-21 17:06:26 +08:00
/** draw a quadratic bezier curve with color and number of segments, use drawQuadBezier instead.
*
* @param from The origin of the bezier path.
* @param control The control of the bezier path.
* @param to The destination of the bezier path.
* @param segments The number of segments.
2015-03-21 17:06:26 +08:00
* @param color The quadratic bezier color.
* @js NA
2015-03-21 17:06:26 +08:00
*/
CC_DEPRECATED_ATTRIBUTE void drawQuadraticBezier(const Vec2& from, const Vec2& control, const Vec2& to, unsigned int segments, const Color4F &color);
2012-11-09 12:08:18 +08:00
/** Clear the geometry in the node's buffer. */
void clear();
2015-03-21 17:06:26 +08:00
/** Get the color mixed mode.
* @lua NA
*/
const BlendFunc& getBlendFunc() const;
2015-03-21 17:06:26 +08:00
/** Set the color mixed mode.
* @code
* When this function bound into js or lua,the parameter will be changed
* In js: var setBlendFunc(var src, var dst)
* @endcode
* @lua NA
*/
void setBlendFunc(const BlendFunc &blendFunc);
/**
* @js NA
*/
2015-12-04 15:14:47 +08:00
virtual void onDraw(const Mat4 &transform, uint32_t flags);
/**
* @js NA
*/
2015-12-04 15:14:47 +08:00
virtual void onDrawGLLine(const Mat4 &transform, uint32_t flags);
/**
* @js NA
*/
virtual void onDrawGLPoint(const Mat4 &transform, uint32_t flags);
// Overrides
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
2014-03-24 17:44:01 +08:00
void setLineWidth(GLfloat lineWidth);
2015-11-12 18:23:56 +08:00
// Get CocosStudio guide lines width.
GLfloat getLineWidth();
2014-03-24 17:44:01 +08:00
CC_CONSTRUCTOR_ACCESS:
DrawNode(GLfloat lineWidth = DEFAULT_LINE_WIDTH);
virtual ~DrawNode();
virtual bool init() override;
2014-03-24 17:44:01 +08:00
protected:
2013-12-05 17:19:01 +08:00
void ensureCapacity(int count);
void ensureCapacityGLPoint(int count);
void ensureCapacityGLLine(int count);
GLuint _vao;
GLuint _vbo;
GLuint _vaoGLPoint;
GLuint _vboGLPoint;
GLuint _vaoGLLine;
GLuint _vboGLLine;
2013-12-05 17:19:01 +08:00
int _bufferCapacity;
GLsizei _bufferCount;
V2F_C4B_T2F *_buffer;
int _bufferCapacityGLPoint;
GLsizei _bufferCountGLPoint;
2015-01-20 16:50:51 +08:00
V2F_C4B_T2F *_bufferGLPoint;
Color4F _pointColor;
int _pointSize;
int _bufferCapacityGLLine;
GLsizei _bufferCountGLLine;
V2F_C4B_T2F *_bufferGLLine;
BlendFunc _blendFunc;
CustomCommand _customCommand;
CustomCommand _customCommandGLPoint;
CustomCommand _customCommandGLLine;
bool _dirty;
bool _dirtyGLPoint;
bool _dirtyGLLine;
GLfloat _lineWidth;
GLfloat _defaultLineWidth;
private:
CC_DISALLOW_COPY_AND_ASSIGN(DrawNode);
2012-11-09 12:08:18 +08:00
};
2015-03-21 17:06:26 +08:00
/** @} */
2012-11-09 12:08:18 +08:00
NS_CC_END
#endif // __CCDRAWNODES_CCDRAW_NODE_H__