2012-04-08 14:16:29 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2008-2010 Ricardo Quesada
|
2014-01-07 11:25:07 +08:00
|
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
2012-04-08 14:16:29 +08:00
|
|
|
Copyright (c) 2011 Zynga Inc.
|
2015-03-24 14:43:54 +08:00
|
|
|
Copyright (c) 2013-2015 Chukong Technologies Inc.
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2014-05-17 05:36:00 +08:00
|
|
|
#ifndef __BASE_CCTYPES_H__
|
|
|
|
#define __BASE_CCTYPES_H__
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-05-07 05:27:54 +08:00
|
|
|
#include <string>
|
2014-05-17 05:36:00 +08:00
|
|
|
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "math/CCGeometry.h"
|
2014-04-26 13:03:25 +08:00
|
|
|
#include "math/CCMath.h"
|
2014-09-10 07:50:02 +08:00
|
|
|
#include "base/CCRef.h"
|
|
|
|
#include "platform/CCGL.h"
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/**
|
|
|
|
* @addtogroup base
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2015-03-26 15:40:54 +08:00
|
|
|
NS_CC_BEGIN
|
|
|
|
|
2013-11-08 01:13:33 +08:00
|
|
|
struct Color4B;
|
|
|
|
struct Color4F;
|
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-24 14:43:54 +08:00
|
|
|
* RGB color composed of bytes 3 bytes.
|
|
|
|
* @since v3.0
|
2012-04-08 14:16:29 +08:00
|
|
|
*/
|
2014-07-15 10:04:24 +08:00
|
|
|
struct CC_DLL Color3B
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-11-08 01:13:33 +08:00
|
|
|
Color3B();
|
|
|
|
Color3B(GLubyte _r, GLubyte _g, GLubyte _b);
|
|
|
|
explicit Color3B(const Color4B& color);
|
|
|
|
explicit Color3B(const Color4F& color);
|
|
|
|
|
|
|
|
bool operator==(const Color3B& right) const;
|
|
|
|
bool operator==(const Color4B& right) const;
|
|
|
|
bool operator==(const Color4F& right) const;
|
|
|
|
bool operator!=(const Color3B& right) const;
|
|
|
|
bool operator!=(const Color4B& right) const;
|
|
|
|
bool operator!=(const Color4F& right) const;
|
|
|
|
|
2016-01-22 05:09:27 +08:00
|
|
|
bool equals(const Color3B& other) const
|
2013-07-05 16:49:22 +08:00
|
|
|
{
|
2013-11-08 01:13:33 +08:00
|
|
|
return (*this == other);
|
2013-07-05 16:49:22 +08:00
|
|
|
}
|
2013-11-08 01:13:33 +08:00
|
|
|
|
2013-01-14 21:51:47 +08:00
|
|
|
GLubyte r;
|
|
|
|
GLubyte g;
|
2012-04-19 14:35:52 +08:00
|
|
|
GLubyte b;
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2014-07-10 16:50:25 +08:00
|
|
|
static const Color3B WHITE;
|
|
|
|
static const Color3B YELLOW;
|
|
|
|
static const Color3B BLUE;
|
|
|
|
static const Color3B GREEN;
|
|
|
|
static const Color3B RED;
|
|
|
|
static const Color3B MAGENTA;
|
|
|
|
static const Color3B BLACK;
|
|
|
|
static const Color3B ORANGE;
|
|
|
|
static const Color3B GRAY;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-24 14:43:54 +08:00
|
|
|
* RGBA color composed of 4 bytes.
|
|
|
|
* @since v3.0
|
|
|
|
*/
|
2014-07-15 10:04:24 +08:00
|
|
|
struct CC_DLL Color4B
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-11-08 01:13:33 +08:00
|
|
|
Color4B();
|
|
|
|
Color4B(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a);
|
2016-03-17 06:08:49 +08:00
|
|
|
explicit Color4B(const Color3B& color, GLubyte _a = 255);
|
2013-11-08 01:13:33 +08:00
|
|
|
explicit Color4B(const Color4F& color);
|
2015-08-31 17:25:34 +08:00
|
|
|
|
|
|
|
inline void set(GLubyte _r, GLubyte _g, GLubyte _b, GLubyte _a)
|
|
|
|
{
|
|
|
|
r = _r;
|
|
|
|
g = _g;
|
|
|
|
b = _b;
|
|
|
|
a = _a;
|
|
|
|
}
|
2013-11-08 01:13:33 +08:00
|
|
|
|
|
|
|
bool operator==(const Color4B& right) const;
|
|
|
|
bool operator==(const Color3B& right) const;
|
|
|
|
bool operator==(const Color4F& right) const;
|
|
|
|
bool operator!=(const Color4B& right) const;
|
|
|
|
bool operator!=(const Color3B& right) const;
|
|
|
|
bool operator!=(const Color4F& right) const;
|
2013-07-05 16:49:22 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
GLubyte r;
|
|
|
|
GLubyte g;
|
|
|
|
GLubyte b;
|
|
|
|
GLubyte a;
|
2013-08-23 08:19:07 +08:00
|
|
|
|
2014-07-10 16:50:25 +08:00
|
|
|
static const Color4B WHITE;
|
|
|
|
static const Color4B YELLOW;
|
|
|
|
static const Color4B BLUE;
|
|
|
|
static const Color4B GREEN;
|
|
|
|
static const Color4B RED;
|
|
|
|
static const Color4B MAGENTA;
|
|
|
|
static const Color4B BLACK;
|
|
|
|
static const Color4B ORANGE;
|
|
|
|
static const Color4B GRAY;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-24 14:43:54 +08:00
|
|
|
* RGBA color composed of 4 floats.
|
|
|
|
* @since v3.0
|
|
|
|
*/
|
2014-07-15 10:04:24 +08:00
|
|
|
struct CC_DLL Color4F
|
2013-07-05 16:49:22 +08:00
|
|
|
{
|
2013-11-08 01:13:33 +08:00
|
|
|
Color4F();
|
|
|
|
Color4F(float _r, float _g, float _b, float _a);
|
2016-03-17 06:08:49 +08:00
|
|
|
explicit Color4F(const Color3B& color, float _a = 1.0f);
|
2013-11-08 01:13:33 +08:00
|
|
|
explicit Color4F(const Color4B& color);
|
|
|
|
|
|
|
|
bool operator==(const Color4F& right) const;
|
|
|
|
bool operator==(const Color3B& right) const;
|
|
|
|
bool operator==(const Color4B& right) const;
|
|
|
|
bool operator!=(const Color4F& right) const;
|
|
|
|
bool operator!=(const Color3B& right) const;
|
|
|
|
bool operator!=(const Color4B& right) const;
|
|
|
|
|
2016-01-22 05:09:27 +08:00
|
|
|
bool equals(const Color4F &other) const
|
2013-07-05 16:49:22 +08:00
|
|
|
{
|
2013-11-08 01:13:33 +08:00
|
|
|
return (*this == other);
|
2013-07-05 16:49:22 +08:00
|
|
|
}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
GLfloat r;
|
|
|
|
GLfloat g;
|
|
|
|
GLfloat b;
|
|
|
|
GLfloat a;
|
2013-08-23 08:19:07 +08:00
|
|
|
|
2014-07-10 16:50:25 +08:00
|
|
|
static const Color4F WHITE;
|
|
|
|
static const Color4F YELLOW;
|
|
|
|
static const Color4F BLUE;
|
|
|
|
static const Color4F GREEN;
|
|
|
|
static const Color4F RED;
|
|
|
|
static const Color4F MAGENTA;
|
|
|
|
static const Color4F BLACK;
|
|
|
|
static const Color4F ORANGE;
|
|
|
|
static const Color4F GRAY;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
/** A vertex composed of 2 floats: x, y
|
2013-07-05 16:49:22 +08:00
|
|
|
@since v3.0
|
2012-04-08 14:16:29 +08:00
|
|
|
*/
|
2014-04-02 15:25:37 +08:00
|
|
|
// struct Vertex2F
|
|
|
|
// {
|
|
|
|
// Vertex2F(float _x, float _y) :x(_x), y(_y) {}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2014-04-02 15:25:37 +08:00
|
|
|
// Vertex2F(): x(0.f), y(0.f) {}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2014-04-02 15:25:37 +08:00
|
|
|
// GLfloat x;
|
|
|
|
// GLfloat y;
|
|
|
|
// };
|
2012-04-08 14:16:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
/** A vertex composed of 2 floats: x, y
|
2013-07-05 16:49:22 +08:00
|
|
|
@since v3.0
|
2012-04-08 14:16:29 +08:00
|
|
|
*/
|
2014-04-02 15:06:16 +08:00
|
|
|
// struct Vertex3F
|
|
|
|
// {
|
|
|
|
// Vertex3F(float _x, float _y, float _z)
|
|
|
|
// : x(_x)
|
|
|
|
// , y(_y)
|
|
|
|
// , z(_z)
|
|
|
|
// {}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2014-04-02 15:06:16 +08:00
|
|
|
// Vertex3F(): x(0.f), y(0.f), z(0.f) {}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2014-04-02 15:06:16 +08:00
|
|
|
// GLfloat x;
|
|
|
|
// GLfloat y;
|
|
|
|
// GLfloat z;
|
|
|
|
// };
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct Tex2F
|
|
|
|
* A TEXCOORD composed of 2 floats: u, y
|
|
|
|
* @since v3.0
|
2012-04-08 14:16:29 +08:00
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL Tex2F {
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F(float _u, float _v): u(_u), v(_v) {}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F(): u(0.f), v(0.f) {}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
GLfloat u;
|
|
|
|
GLfloat v;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct PointSprite
|
|
|
|
* Vec2 Sprite component.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL PointSprite
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 pos; // 8 bytes
|
2013-07-05 16:49:22 +08:00
|
|
|
Color4B color; // 4 bytes
|
|
|
|
GLfloat size; // 4 bytes
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct Quad2
|
|
|
|
* A 2D Quad. 4 * 2 floats.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL Quad2
|
2013-07-05 16:49:22 +08:00
|
|
|
{
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 tl;
|
|
|
|
Vec2 tr;
|
|
|
|
Vec2 bl;
|
|
|
|
Vec2 br;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct Quad3
|
|
|
|
* A 3D Quad. 4 * 3 floats.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL Quad3 {
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec3 bl;
|
|
|
|
Vec3 br;
|
|
|
|
Vec3 tl;
|
|
|
|
Vec3 tr;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V2F_C4B_T2F
|
|
|
|
* A Vec2 with a vertex point, a tex coord point and a color 4B.
|
|
|
|
*/
|
2013-07-05 16:49:22 +08:00
|
|
|
struct V2F_C4B_T2F
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// vertices (2F)
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 vertices;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// colors (4B)
|
2013-07-05 16:49:22 +08:00
|
|
|
Color4B colors;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// tex coords (2F)
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F texCoords;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V2F_C4B_PF
|
|
|
|
*
|
|
|
|
*/
|
2015-01-13 22:30:50 +08:00
|
|
|
struct V2F_C4B_PF
|
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// vertices (2F)
|
2015-01-13 22:30:50 +08:00
|
|
|
Vec2 vertices;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// colors (4B)
|
2015-01-13 22:30:50 +08:00
|
|
|
Color4B colors;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// pointsize
|
2015-01-13 22:30:50 +08:00
|
|
|
float pointSize;
|
|
|
|
};
|
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V2F_C4F_T2F
|
|
|
|
* A Vec2 with a vertex point, a tex coord point and a color 4F.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V2F_C4F_T2F
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// vertices (2F)
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec2 vertices;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// colors (4F)
|
2013-07-05 16:49:22 +08:00
|
|
|
Color4F colors;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// tex coords (2F)
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F texCoords;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V3F_C4B_T2F
|
|
|
|
* A Vec2 with a vertex point, a tex coord point and a color 4B.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V3F_C4B_T2F
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// vertices (3F)
|
2014-05-15 01:07:09 +08:00
|
|
|
Vec3 vertices; // 12 bytes
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-26 15:40:54 +08:00
|
|
|
/// colors (4B)
|
2013-07-05 16:49:22 +08:00
|
|
|
Color4B colors; // 4 bytes
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// tex coords (2F)
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F texCoords; // 8 bytes
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V3F_T2F
|
|
|
|
* A Vec2 with a vertex point, a tex coord point.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V3F_T2F
|
2014-06-06 16:15:46 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// vertices (2F)
|
2014-06-18 18:19:13 +08:00
|
|
|
Vec3 vertices;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// tex coords (2F)
|
2014-06-06 16:15:46 +08:00
|
|
|
Tex2F texCoords;
|
|
|
|
};
|
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V2F_C4B_T2F_Triangle
|
|
|
|
* A Triangle of V2F_C4B_T2F.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V2F_C4B_T2F_Triangle
|
2012-11-14 18:05:15 +08:00
|
|
|
{
|
2016-06-15 10:43:15 +08:00
|
|
|
V2F_C4B_T2F a;
|
|
|
|
V2F_C4B_T2F b;
|
|
|
|
V2F_C4B_T2F c;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V2F_C4B_T2F_Quad
|
|
|
|
* A Quad of V2F_C4B_T2F.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V2F_C4B_T2F_Quad
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom left
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4B_T2F bl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom right
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4B_T2F br;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top left
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4B_T2F tl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top right
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4B_T2F tr;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V3F_C4B_T2F_Quad
|
|
|
|
* 4 Vertex3FTex2FColor4B.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V3F_C4B_T2F_Quad
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top left
|
2013-07-05 16:49:22 +08:00
|
|
|
V3F_C4B_T2F tl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom left
|
2013-07-05 16:49:22 +08:00
|
|
|
V3F_C4B_T2F bl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top right
|
2013-07-05 16:49:22 +08:00
|
|
|
V3F_C4B_T2F tr;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom right
|
2013-07-05 16:49:22 +08:00
|
|
|
V3F_C4B_T2F br;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V2F_C4F_T2F_Quad
|
|
|
|
* 4 Vertex2FTex2FColor4F Quad.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V2F_C4F_T2F_Quad
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom left
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4F_T2F bl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom right
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4F_T2F br;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top left
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4F_T2F tl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top right
|
2013-07-05 16:49:22 +08:00
|
|
|
V2F_C4F_T2F tr;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct V3F_T2F_Quad
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
2015-03-24 14:43:54 +08:00
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL V3F_T2F_Quad
|
2014-06-06 16:15:46 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom left
|
2014-06-18 18:19:13 +08:00
|
|
|
V3F_T2F bl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom right
|
2014-06-18 18:19:13 +08:00
|
|
|
V3F_T2F br;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top left
|
2014-06-18 18:19:13 +08:00
|
|
|
V3F_T2F tl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top right
|
2014-06-18 18:19:13 +08:00
|
|
|
V3F_T2F tr;
|
2014-06-06 16:15:46 +08:00
|
|
|
};
|
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct BlendFunc
|
|
|
|
* Blend Function used for textures.
|
|
|
|
*/
|
2014-07-15 10:04:24 +08:00
|
|
|
struct CC_DLL BlendFunc
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/** source blend function */
|
2012-04-19 14:35:52 +08:00
|
|
|
GLenum src;
|
2015-03-26 15:40:54 +08:00
|
|
|
/** destination blend function */
|
2012-04-19 14:35:52 +08:00
|
|
|
GLenum dst;
|
2013-07-26 04:36:19 +08:00
|
|
|
|
2015-03-26 15:40:54 +08:00
|
|
|
/** Blending disabled. Uses {GL_ONE, GL_ZERO} */
|
2014-07-10 16:50:25 +08:00
|
|
|
static const BlendFunc DISABLE;
|
2015-03-26 15:40:54 +08:00
|
|
|
/** Blending enabled for textures with Alpha premultiplied. Uses {GL_ONE, GL_ONE_MINUS_SRC_ALPHA} */
|
2014-07-10 16:50:25 +08:00
|
|
|
static const BlendFunc ALPHA_PREMULTIPLIED;
|
2015-03-26 15:40:54 +08:00
|
|
|
/** Blending enabled for textures with Alpha NON premultiplied. Uses {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA} */
|
2014-07-10 16:50:25 +08:00
|
|
|
static const BlendFunc ALPHA_NON_PREMULTIPLIED;
|
2015-03-26 15:40:54 +08:00
|
|
|
/** Enables Additive blending. Uses {GL_SRC_ALPHA, GL_ONE} */
|
2014-07-10 16:50:25 +08:00
|
|
|
static const BlendFunc ADDITIVE;
|
2013-11-07 06:24:56 +08:00
|
|
|
|
2013-12-17 15:39:35 +08:00
|
|
|
bool operator==(const BlendFunc &a) const
|
2013-11-07 06:24:56 +08:00
|
|
|
{
|
|
|
|
return src == a.src && dst == a.dst;
|
|
|
|
}
|
|
|
|
|
2014-08-20 14:21:13 +08:00
|
|
|
bool operator!=(const BlendFunc &a) const
|
|
|
|
{
|
|
|
|
return src != a.src || dst != a.dst;
|
|
|
|
}
|
|
|
|
|
2013-12-17 15:39:35 +08:00
|
|
|
bool operator<(const BlendFunc &a) const
|
2013-11-07 06:24:56 +08:00
|
|
|
{
|
2014-05-30 17:57:27 +08:00
|
|
|
return src < a.src || (src == a.src && dst < a.dst);
|
2013-11-07 06:24:56 +08:00
|
|
|
}
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2012-11-14 18:05:15 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct TextVAlignment
|
|
|
|
* Vertical text alignment type.
|
|
|
|
*
|
|
|
|
* @note If any of these enums are edited and/or reordered, update Texture2D.m.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
enum class CC_DLL TextVAlignment
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-07-27 07:04:21 +08:00
|
|
|
TOP,
|
|
|
|
CENTER,
|
2014-08-17 06:03:04 +08:00
|
|
|
BOTTOM
|
2013-07-27 07:04:21 +08:00
|
|
|
};
|
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct TextHAlignment
|
|
|
|
* Horizontal text alignment type.
|
|
|
|
*
|
|
|
|
* @note If any of these enums are edited and/or reordered, update Texture2D.m.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
enum class CC_DLL TextHAlignment
|
2013-07-27 07:04:21 +08:00
|
|
|
{
|
|
|
|
LEFT,
|
|
|
|
CENTER,
|
2014-08-17 06:03:04 +08:00
|
|
|
RIGHT
|
2013-07-25 18:46:43 +08:00
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-07-30 11:33:18 +08:00
|
|
|
/**
|
|
|
|
* @brief Possible GlyphCollection used by Label.
|
|
|
|
*
|
|
|
|
* Specify a collections of characters to be load when Label created.
|
|
|
|
* Consider using DYNAMIC.
|
|
|
|
*/
|
|
|
|
enum class GlyphCollection {
|
|
|
|
DYNAMIC,
|
|
|
|
NEHE,
|
|
|
|
ASCII,
|
|
|
|
CUSTOM
|
|
|
|
};
|
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
// Types for animation in particle systems
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct T2F_Quad
|
|
|
|
* Texture coordinates for a quad.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL T2F_Quad
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom left
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F bl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// bottom right
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F br;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top left
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F tl;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// top right
|
2013-07-05 16:49:22 +08:00
|
|
|
Tex2F tr;
|
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct AnimationFrameData
|
|
|
|
* Struct that holds the size in pixels, texture coordinates and delays for animated ParticleSystemQuad.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL AnimationFrameData
|
2012-04-08 14:16:29 +08:00
|
|
|
{
|
2013-07-05 16:49:22 +08:00
|
|
|
T2F_Quad texCoords;
|
2012-06-08 13:55:28 +08:00
|
|
|
float delay;
|
2015-04-10 14:18:16 +08:00
|
|
|
Size size;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2012-04-08 14:16:29 +08:00
|
|
|
|
2013-05-07 05:27:54 +08:00
|
|
|
/**
|
|
|
|
types used for defining fonts properties (i.e. font name, size, stroke or shadow)
|
|
|
|
*/
|
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct FontShadow
|
|
|
|
* Shadow attributes.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL FontShadow
|
2013-05-07 05:27:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-05-07 05:27:54 +08:00
|
|
|
// shadow is not enabled by default
|
2013-07-26 05:49:43 +08:00
|
|
|
FontShadow()
|
|
|
|
: _shadowEnabled(false)
|
|
|
|
, _shadowBlur(0)
|
|
|
|
, _shadowOpacity(0)
|
|
|
|
{}
|
|
|
|
|
2015-03-26 15:40:54 +08:00
|
|
|
/// true if shadow enabled
|
2013-06-15 14:03:30 +08:00
|
|
|
bool _shadowEnabled;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// shadow x and y offset
|
2016-06-15 10:43:15 +08:00
|
|
|
Size _shadowOffset;
|
2016-06-22 10:22:05 +08:00
|
|
|
/// shadow blurriness
|
2016-06-15 10:43:15 +08:00
|
|
|
float _shadowBlur;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// shadow opacity
|
2016-06-15 10:43:15 +08:00
|
|
|
float _shadowOpacity;
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2013-05-07 05:27:54 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct FontStroke
|
|
|
|
* Stroke attributes.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL FontStroke
|
2013-05-07 05:27:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-05-07 05:27:54 +08:00
|
|
|
// stroke is disabled by default
|
2013-07-09 21:47:17 +08:00
|
|
|
FontStroke()
|
2016-06-15 10:43:15 +08:00
|
|
|
: _strokeEnabled(false)
|
2013-07-09 21:47:17 +08:00
|
|
|
, _strokeColor(Color3B::BLACK)
|
2015-01-20 16:04:14 +08:00
|
|
|
, _strokeAlpha(255)
|
2015-03-13 06:47:58 +08:00
|
|
|
, _strokeSize(0)
|
2013-07-26 05:49:43 +08:00
|
|
|
{}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-26 15:40:54 +08:00
|
|
|
/// true if stroke enabled
|
2013-07-05 16:49:22 +08:00
|
|
|
bool _strokeEnabled;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// stroke color
|
2016-06-15 10:43:15 +08:00
|
|
|
Color3B _strokeColor;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// stroke alpha
|
2015-01-20 16:04:14 +08:00
|
|
|
GLubyte _strokeAlpha;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// stroke size
|
2013-07-05 16:49:22 +08:00
|
|
|
float _strokeSize;
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2013-05-07 05:27:54 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct FontDefinition
|
|
|
|
* Font attributes.
|
|
|
|
*/
|
2014-07-21 17:45:56 +08:00
|
|
|
struct CC_DLL FontDefinition
|
2013-05-07 05:27:54 +08:00
|
|
|
{
|
|
|
|
public:
|
2013-09-13 11:41:20 +08:00
|
|
|
/**
|
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
2013-07-26 05:49:43 +08:00
|
|
|
FontDefinition()
|
|
|
|
: _fontSize(0)
|
2013-07-27 07:04:21 +08:00
|
|
|
, _alignment(TextHAlignment::CENTER)
|
|
|
|
, _vertAlignment(TextVAlignment::TOP)
|
2016-06-15 10:43:15 +08:00
|
|
|
, _dimensions(Size::ZERO)
|
2013-07-26 05:49:43 +08:00
|
|
|
, _fontFillColor(Color3B::WHITE)
|
2015-01-20 16:04:14 +08:00
|
|
|
, _fontAlpha(255)
|
2016-06-15 10:43:15 +08:00
|
|
|
, _enableWrap(true)
|
|
|
|
, _overflow(0)
|
2013-07-26 05:49:43 +08:00
|
|
|
{}
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-03-26 15:40:54 +08:00
|
|
|
/// font name
|
2013-07-05 16:49:22 +08:00
|
|
|
std::string _fontName;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// font size
|
2013-07-05 16:49:22 +08:00
|
|
|
int _fontSize;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// horizontal alignment
|
2013-07-27 07:04:21 +08:00
|
|
|
TextHAlignment _alignment;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// vertical alignment
|
2013-07-27 07:04:21 +08:00
|
|
|
TextVAlignment _vertAlignment;
|
2015-12-03 20:00:51 +08:00
|
|
|
/// rendering box
|
2013-06-20 14:13:12 +08:00
|
|
|
Size _dimensions;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// font color
|
2013-07-05 16:49:22 +08:00
|
|
|
Color3B _fontFillColor;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// font alpha
|
2015-01-20 16:04:14 +08:00
|
|
|
GLubyte _fontAlpha;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// font shadow
|
2013-07-05 16:49:22 +08:00
|
|
|
FontShadow _shadow;
|
2015-03-26 15:40:54 +08:00
|
|
|
/// font stroke
|
2013-07-05 16:49:22 +08:00
|
|
|
FontStroke _stroke;
|
2016-06-15 10:43:15 +08:00
|
|
|
/// enable text wrap
|
|
|
|
bool _enableWrap;
|
|
|
|
/** There are 4 overflows: none, clamp, shrink and resize_height.
|
2016-06-22 10:22:05 +08:00
|
|
|
* The corresponding integer values are 0, 1, 2, 3 respectively
|
2016-06-15 10:43:15 +08:00
|
|
|
* For more information, please refer to Label::Overflow enum class.
|
|
|
|
*/
|
|
|
|
int _overflow;
|
2015-04-10 14:18:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-01-20 12:41:31 +08:00
|
|
|
* @brief Effects used by `Label`
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
enum class LabelEffect {
|
2016-01-20 12:41:31 +08:00
|
|
|
// FIXME: Covert them to bitwise. More than one effect should be supported
|
2015-04-10 14:18:16 +08:00
|
|
|
NORMAL,
|
|
|
|
OUTLINE,
|
|
|
|
SHADOW,
|
2015-04-17 14:39:52 +08:00
|
|
|
GLOW,
|
2016-01-20 12:41:31 +08:00
|
|
|
ITALICS,
|
|
|
|
BOLD,
|
|
|
|
UNDERLINE,
|
|
|
|
STRIKETHROUGH,
|
2015-04-17 14:39:52 +08:00
|
|
|
ALL
|
2013-07-05 16:49:22 +08:00
|
|
|
};
|
2013-05-07 05:27:54 +08:00
|
|
|
|
2015-03-24 14:43:54 +08:00
|
|
|
/** @struct Acceleration
|
|
|
|
* The device accelerometer reports values for each axis in units of g-force.
|
2013-09-03 18:22:03 +08:00
|
|
|
*/
|
2014-07-15 11:18:05 +08:00
|
|
|
class CC_DLL Acceleration
|
2014-07-03 23:42:06 +08:00
|
|
|
: public Ref
|
2013-09-03 18:22:03 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
double x;
|
|
|
|
double y;
|
|
|
|
double z;
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
double timestamp;
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2013-09-03 18:22:03 +08:00
|
|
|
Acceleration(): x(0), y(0), z(0), timestamp(0) {}
|
|
|
|
};
|
2013-05-07 05:27:54 +08:00
|
|
|
|
2014-07-15 12:00:31 +08:00
|
|
|
extern const std::string CC_DLL STD_STRING_EMPTY;
|
|
|
|
extern const ssize_t CC_DLL CC_INVALID_INDEX;
|
2013-12-24 15:49:58 +08:00
|
|
|
|
2012-04-18 18:43:45 +08:00
|
|
|
NS_CC_END
|
2015-03-24 14:43:54 +08:00
|
|
|
// end group
|
|
|
|
/// @}
|
2014-05-17 05:36:00 +08:00
|
|
|
#endif //__BASE_CCTYPES_H__
|