mirror of https://github.com/axmolengine/axmol.git
Migrate to Vector2 in DrawPrimitive.h
This commit is contained in:
parent
9c33b48b50
commit
5303f50904
|
@ -123,7 +123,7 @@ void free()
|
|||
s_initialized = false;
|
||||
}
|
||||
|
||||
void drawPoint( const Point& point )
|
||||
void drawPoint( const Vector2& point )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -150,7 +150,7 @@ void drawPoint( const Point& point )
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,1);
|
||||
}
|
||||
|
||||
void drawPoints( const Point *points, unsigned int numberOfPoints )
|
||||
void drawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -198,7 +198,7 @@ void drawPoints( const Point *points, unsigned int numberOfPoints )
|
|||
}
|
||||
|
||||
|
||||
void drawLine( const Point& origin, const Point& destination )
|
||||
void drawLine( const Vector2& origin, const Vector2& destination )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -223,7 +223,7 @@ void drawLine( const Point& origin, const Point& destination )
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,2);
|
||||
}
|
||||
|
||||
void drawRect( Point origin, Point destination )
|
||||
void drawRect( Vector2 origin, Vector2 destination )
|
||||
{
|
||||
drawLine(Point(origin.x, origin.y), Point(destination.x, origin.y));
|
||||
drawLine(Point(destination.x, origin.y), Point(destination.x, destination.y));
|
||||
|
@ -231,9 +231,9 @@ void drawRect( Point origin, Point destination )
|
|||
drawLine(Point(origin.x, destination.y), Point(origin.x, origin.y));
|
||||
}
|
||||
|
||||
void drawSolidRect( Point origin, Point destination, Color4F color )
|
||||
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color )
|
||||
{
|
||||
Point vertices[] = {
|
||||
Vector2 vertices[] = {
|
||||
origin,
|
||||
Point(destination.x, origin.y),
|
||||
destination,
|
||||
|
@ -243,7 +243,7 @@ void drawSolidRect( Point origin, Point destination, Color4F color )
|
|||
drawSolidPoly(vertices, 4, color );
|
||||
}
|
||||
|
||||
void drawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon )
|
||||
void drawPoly( const Vector2 *poli, unsigned int numberOfPoints, bool closePolygon )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -295,7 +295,7 @@ void drawPoly( const Point *poli, unsigned int numberOfPoints, bool closePolygon
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
|
||||
}
|
||||
|
||||
void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color )
|
||||
void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color )
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -339,7 +339,7 @@ void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F colo
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1, numberOfPoints);
|
||||
}
|
||||
|
||||
void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -383,12 +383,12 @@ void drawCircle( const Point& center, float radius, float angle, unsigned int se
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+additionalSegment);
|
||||
}
|
||||
|
||||
void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter)
|
||||
{
|
||||
drawCircle(center, radius, angle, segments, drawLineToCenter, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -429,12 +429,12 @@ void drawSolidCircle( const Point& center, float radius, float angle, unsigned i
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
|
||||
}
|
||||
|
||||
void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments)
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments)
|
||||
{
|
||||
drawSolidCircle(center, radius, angle, segments, 1.0f, 1.0f);
|
||||
}
|
||||
|
||||
void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments)
|
||||
void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
@ -525,7 +525,7 @@ void drawCardinalSpline( PointArray *config, float tension, unsigned int segmen
|
|||
CC_INCREMENT_GL_DRAWN_BATCHES_AND_VERTICES(1,segments+1);
|
||||
}
|
||||
|
||||
void drawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments)
|
||||
void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments)
|
||||
{
|
||||
lazy_init();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ THE SOFTWARE.
|
|||
|
||||
#include "ccTypes.h"
|
||||
#include "ccMacros.h"
|
||||
#include "CCGeometry.h" // for Point
|
||||
#include "CCMath.h"
|
||||
|
||||
/**
|
||||
@file
|
||||
|
@ -69,6 +69,8 @@ THE SOFTWARE.
|
|||
|
||||
NS_CC_BEGIN
|
||||
|
||||
USING_NS_CC_MATH;
|
||||
|
||||
/**
|
||||
* @addtogroup global
|
||||
* @{
|
||||
|
@ -85,52 +87,52 @@ namespace DrawPrimitives
|
|||
void free();
|
||||
|
||||
/** draws a point given x and y coordinate measured in points */
|
||||
void drawPoint( const Point& point );
|
||||
void drawPoint( const Vector2& point );
|
||||
|
||||
/** draws an array of points.
|
||||
@since v0.7.2
|
||||
*/
|
||||
void drawPoints( const Point *points, unsigned int numberOfPoints );
|
||||
void drawPoints( const Vector2 *points, unsigned int numberOfPoints );
|
||||
|
||||
/** draws a line given the origin and destination point measured in points */
|
||||
void drawLine( const Point& origin, const Point& destination );
|
||||
void drawLine( const Vector2& origin, const Vector2& destination );
|
||||
|
||||
/** draws a rectangle given the origin and destination point measured in points. */
|
||||
void drawRect( Point origin, Point destination );
|
||||
void drawRect( Vector2 origin, Vector2 destination );
|
||||
|
||||
/** draws a solid rectangle given the origin and destination point measured in points.
|
||||
@since 1.1
|
||||
*/
|
||||
void drawSolidRect( Point origin, Point destination, Color4F color );
|
||||
void drawSolidRect( Vector2 origin, Vector2 destination, Color4F color );
|
||||
|
||||
/** draws a polygon given a pointer to Point coordinates and the number of vertices measured in points.
|
||||
/** draws a polygon given a pointer to point coordinates and the number of vertices measured in points.
|
||||
The polygon can be closed or open
|
||||
*/
|
||||
void drawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon );
|
||||
void drawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon );
|
||||
|
||||
/** draws a solid polygon given a pointer to CGPoint coordinates, the number of vertices measured in points, and a color.
|
||||
*/
|
||||
void drawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color );
|
||||
void drawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color );
|
||||
|
||||
/** draws a circle given the center, radius and number of segments. */
|
||||
void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
|
||||
void drawCircle( const Point& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter, float scaleX, float scaleY);
|
||||
void drawCircle( const Vector2& center, float radius, float angle, unsigned int segments, bool drawLineToCenter);
|
||||
|
||||
/** draws a solid circle given the center, radius and number of segments. */
|
||||
void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
|
||||
void drawSolidCircle( const Point& center, float radius, float angle, unsigned int segments);
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments, float scaleX, float scaleY);
|
||||
void drawSolidCircle( const Vector2& center, float radius, float angle, unsigned int segments);
|
||||
|
||||
/** draws a quad bezier path
|
||||
@warning This function could be pretty slow. Use it only for debugging purposes.
|
||||
@since v0.8
|
||||
*/
|
||||
void drawQuadBezier(const Point& origin, const Point& control, const Point& destination, unsigned int segments);
|
||||
void drawQuadBezier(const Vector2& origin, const Vector2& control, const Vector2& destination, unsigned int segments);
|
||||
|
||||
/** draws a cubic bezier path
|
||||
@warning This function could be pretty slow. Use it only for debugging purposes.
|
||||
@since v0.8
|
||||
*/
|
||||
void drawCubicBezier(const Point& origin, const Point& control1, const Point& control2, const Point& destination, unsigned int segments);
|
||||
void drawCubicBezier(const Vector2& origin, const Vector2& control1, const Vector2& control2, const Vector2& destination, unsigned int segments);
|
||||
|
||||
/** draws a Catmull Rom path.
|
||||
@warning This function could be pretty slow. Use it only for debugging purposes.
|
||||
|
|
|
@ -88,7 +88,7 @@ void ccDrawPoint( const Point& point )
|
|||
DrawPrimitives::drawPoint(point);
|
||||
}
|
||||
|
||||
void ccDrawPoints( const Point *points, unsigned int numberOfPoints )
|
||||
void ccDrawPoints( const Vector2 *points, unsigned int numberOfPoints )
|
||||
{
|
||||
DrawPrimitives::drawPoints(points, numberOfPoints);
|
||||
}
|
||||
|
@ -108,12 +108,12 @@ void ccDrawSolidRect( Point origin, Point destination, Color4F color )
|
|||
DrawPrimitives::drawSolidRect(origin, destination, color);
|
||||
}
|
||||
|
||||
void ccDrawPoly( const Point *vertices, unsigned int numOfVertices, bool closePolygon )
|
||||
void ccDrawPoly( const Vector2 *vertices, unsigned int numOfVertices, bool closePolygon )
|
||||
{
|
||||
DrawPrimitives::drawPoly(vertices, numOfVertices, closePolygon);
|
||||
}
|
||||
|
||||
void ccDrawSolidPoly( const Point *poli, unsigned int numberOfPoints, Color4F color )
|
||||
void ccDrawSolidPoly( const Vector2 *poli, unsigned int numberOfPoints, Color4F color )
|
||||
{
|
||||
DrawPrimitives::drawSolidPoly(poli, numberOfPoints, color);
|
||||
}
|
||||
|
|
|
@ -576,7 +576,7 @@ void CCArmature::drawContour()
|
|||
const std::vector<Point> &vertexList = body->getCalculatedVertexList();
|
||||
|
||||
unsigned long length = vertexList.size();
|
||||
Point *points = new Point[length];
|
||||
Vector2 *points = new Vector2[length];
|
||||
for (unsigned long i = 0; i<length; i++)
|
||||
{
|
||||
Point p = vertexList.at(i);
|
||||
|
|
|
@ -202,7 +202,7 @@ void Skeleton::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
// Slots.
|
||||
DrawPrimitives::setDrawColor4B(0, 0, 255, 255);
|
||||
glLineWidth(1);
|
||||
Point points[4];
|
||||
Vector2 points[4];
|
||||
V3F_C4B_T2F_Quad tmpQuad;
|
||||
for (int i = 0, n = skeleton->slotCount; i < n; i++) {
|
||||
spSlot* slot = skeleton->drawOrder[i];
|
||||
|
|
|
@ -1369,7 +1369,7 @@ void ActionFollow::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
float x = winSize.width*2 - 100;
|
||||
float y = winSize.height;
|
||||
|
||||
Point vertices[] = { Point(5,5), Point(x-5,5), Point(x-5,y-5), Point(5,y-5) };
|
||||
Vector2 vertices[] = { Vector2(5,5), Vector2(x-5,5), Vector2(x-5,y-5), Vector2(5,y-5) };
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
director->popMatrix(MATRIX_STACK_TYPE::MATRIX_STACK_MODELVIEW);
|
||||
|
|
|
@ -165,7 +165,7 @@ void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
// draw 4 small points
|
||||
Point points[] = { Point(60,60), Point(70,70), Point(60,70), Point(70,60) };
|
||||
Vector2 points[] = { Vector2(60,60), Vector2(70,70), Vector2(60,70), Vector2(70,60) };
|
||||
DrawPrimitives::setPointSize(4);
|
||||
DrawPrimitives::setDrawColor4B(0,255,255,255);
|
||||
DrawPrimitives::drawPoints( points, 4);
|
||||
|
@ -196,21 +196,21 @@ void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
// open yellow poly
|
||||
DrawPrimitives::setDrawColor4B(255, 255, 0, 255);
|
||||
glLineWidth(10);
|
||||
Point vertices[] = { Point(0,0), Point(50,50), Point(100,50), Point(100,100), Point(50,100) };
|
||||
Vector2 vertices[] = { Vector2(0,0), Vector2(50,50), Vector2(100,50), Vector2(100,100), Vector2(50,100) };
|
||||
DrawPrimitives::drawPoly( vertices, 5, false);
|
||||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
// filled poly
|
||||
glLineWidth(1);
|
||||
Point filledVertices[] = { Point(0,120), Point(50,120), Point(50,170), Point(25,200), Point(0,170) };
|
||||
Vector2 filledVertices[] = { Vector2(0,120), Vector2(50,120), Vector2(50,170), Vector2(25,200), Vector2(0,170) };
|
||||
DrawPrimitives::drawSolidPoly(filledVertices, 5, Color4F(0.5f, 0.5f, 1, 1 ) );
|
||||
|
||||
|
||||
// closed purble poly
|
||||
DrawPrimitives::setDrawColor4B(255, 0, 255, 255);
|
||||
glLineWidth(2);
|
||||
Point vertices2[] = { Point(30,130), Point(30,230), Point(50,200) };
|
||||
Vector2 vertices2[] = { Vector2(30,130), Vector2(30,230), Vector2(50,200) };
|
||||
DrawPrimitives::drawPoly( vertices2, 3, true);
|
||||
|
||||
CHECK_GL_ERROR_DEBUG();
|
||||
|
@ -226,7 +226,7 @@ void DrawPrimitivesTest::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
CHECK_GL_ERROR_DEBUG();
|
||||
|
||||
//draw a solid polygon
|
||||
Point vertices3[] = {Point(60,160), Point(70,190), Point(100,190), Point(90,160)};
|
||||
Vector2 vertices3[] = {Vector2(60,160), Vector2(70,190), Vector2(100,190), Vector2(90,160)};
|
||||
DrawPrimitives::drawSolidPoly( vertices3, 4, Color4F(1,1,0,1) );
|
||||
|
||||
// restore original values
|
||||
|
|
|
@ -1680,12 +1680,12 @@ void LabelBMFontBounds::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
origin.width = origin.width / 2 - (labelSize.width / 2);
|
||||
origin.height = origin.height / 2 - (labelSize.height / 2);
|
||||
|
||||
Point vertices[4]=
|
||||
Vector2 vertices[4]=
|
||||
{
|
||||
Point(origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Point(origin.width, labelSize.height + origin.height)
|
||||
Vector2(origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Vector2(origin.width, labelSize.height + origin.height)
|
||||
};
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
|
|
|
@ -924,12 +924,12 @@ void LabelFNTBounds::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
origin.width = origin.width / 2 - (labelSize.width / 2);
|
||||
origin.height = origin.height / 2 - (labelSize.height / 2);
|
||||
|
||||
Point vertices[4]=
|
||||
Vector2 vertices[4]=
|
||||
{
|
||||
Point(origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Point(origin.width, labelSize.height + origin.height)
|
||||
Vector2(origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Vector2(origin.width, labelSize.height + origin.height)
|
||||
};
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
||||
|
@ -1532,12 +1532,12 @@ void LabelTTFOldNew::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
origin.width = origin.width / 2 - (labelSize.width / 2);
|
||||
origin.height = origin.height / 2 - (labelSize.height / 2);
|
||||
|
||||
Point vertices[4]=
|
||||
Vector2 vertices[4]=
|
||||
{
|
||||
Point(origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Point(origin.width, labelSize.height + origin.height)
|
||||
Vector2(origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Vector2(origin.width, labelSize.height + origin.height)
|
||||
};
|
||||
DrawPrimitives::setDrawColor4B(Color4B::RED.r,Color4B::RED.g,Color4B::RED.b,Color4B::RED.a);
|
||||
DrawPrimitives::drawPoly(vertices, 4, true);
|
||||
|
@ -1549,12 +1549,12 @@ void LabelTTFOldNew::onDraw(const Matrix &transform, bool transformUpdated)
|
|||
origin.width = origin.width / 2 - (labelSize.width / 2);
|
||||
origin.height = origin.height / 2 - (labelSize.height / 2);
|
||||
|
||||
Point vertices2[4]=
|
||||
Vector2 vertices2[4]=
|
||||
{
|
||||
Point(origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, origin.height),
|
||||
Point(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Point(origin.width, labelSize.height + origin.height)
|
||||
Vector2(origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, origin.height),
|
||||
Vector2(labelSize.width + origin.width, labelSize.height + origin.height),
|
||||
Vector2(origin.width, labelSize.height + origin.height)
|
||||
};
|
||||
DrawPrimitives::setDrawColor4B(Color4B::WHITE.r,Color4B::WHITE.g,Color4B::WHITE.b,Color4B::WHITE.a);
|
||||
DrawPrimitives::drawPoly(vertices2, 4, true);
|
||||
|
|
Loading…
Reference in New Issue