ccTypes(各种类型--ccColor3B ccVertex2F ccQuad2 ccQuad3 ccBlendFunc ccFontDefinition)

本文主要是介绍ccTypes(各种类型--ccColor3B ccVertex2F ccQuad2 ccQuad3 ccBlendFunc ccFontDefinition),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!


#ifndef __CCTYPES_H__

#define __CCTYPES_H__


#include <string>

#include "cocoa/CCGeometry.h"

#include "CCGL.h"



NS_CC_BEGIN


/** RGB color composed(组成) of bytes 3 bytes

@since v0.8

 */

typedef struct _ccColor3B

{

    GLubyte r;

/

typedef unsigned char   GLubyte;

    GLubyte g;

    GLubyte b;

} ccColor3B;


//! helper macro(宏) that creates an ccColor3B type  //ccc3 用于创建一个ccColor3B type的宏

static inline ccColor3B

ccc3(const GLubyte r, const GLubyte g, const GLubyte b)

{

    ccColor3B c = {r, g, b};

    return c;

}


/** returns true if both ccColor3B are equal. Otherwise it returns false.

 */

static inline bool ccc3BEqual(const ccColor3B &col1, const ccColor3B &col2)  //判断两个cccolor3b是否相同

{

    return col1.r == col2.r && col1.g == col2.g && col1.b == col2.b;

}


//ccColor3B predefined(预先定义的) colors

//! White color (255,255,255)

static const ccColor3B ccWHITE={255,255,255};

//! Yellow color (255,255,0)

static const ccColor3B ccYELLOW={255,255,0};

//! Blue color (0,0,255)

static const ccColor3B ccBLUE={0,0,255};

//! Green Color (0,255,0)

static const ccColor3B ccGREEN={0,255,0};

//! Red Color (255,0,0,)

static const ccColor3B ccRED={255,0,0};

//! Magenta Color (255,0,255)

static const ccColor3B ccMAGENTA={255,0,255};

//! Black Color (0,0,0)

static const ccColor3B ccBLACK={0,0,0};

//! Orange Color (255,127,0)

static const ccColor3B ccORANGE={255,127,0};

//! Gray Color (166,166,166)

static const ccColor3B ccGRAY={166,166,166};


/** RGBA color composed(组成) of 4 bytes

*/

typedef struct _ccColor4B

{

    GLubyte r;

    GLubyte g;

    GLubyte b;

    GLubyte a;

} ccColor4B;

//! helper macro that creates an ccColor4B type  //ccc4 用于创建一个ccColor3B type的宏

static inline ccColor4B

ccc4(const GLubyte r, const GLubyte g, const GLubyte b, const GLubyte o)

{

    ccColor4B c = {r, g, b, o};

    return c;

}



/** RGBA color composed of 4 floats

@since v0.8

*/

typedef struct _ccColor4F {

    GLfloat r;

    GLfloat g;

    GLfloat b;

    GLfloat a;

} ccColor4F;



/** Returns a ccColor4F from a ccColor3B. Alpha will be 1.

 @since v0.99.1

 */

static inline ccColor4F ccc4FFromccc3B(ccColor3B c)

{

    ccColor4F c4 = {c.r/255.f, c.g/255.f, c.b/255.f, 1.f};

    return c4;

}


//! helper that creates a ccColor4f type

static inline ccColor4F 

ccc4f(const GLfloat r, const GLfloat g, const GLfloat b, const GLfloat a)

{

    ccColor4F c4 = {r, g, b, a};

    return c4;

}


/** Returns a ccColor4F from a ccColor4B.

 @since v0.99.1

 */

static inline ccColor4F ccc4FFromccc4B(ccColor4B c)

{

    ccColor4F c4 = {c.r/255.f, c.g/255.f, c.b/255.f, c.a/255.f};

    return c4;

}


static inline ccColor4B ccc4BFromccc4F(ccColor4F c)

{

    ccColor4B ret = {(GLubyte)(c.r*255), (GLubyte)(c.g*255), (GLubyte)(c.b*255), (GLubyte)(c.a*255)};

return ret;

}


/** returns YES if both ccColor4F are equal. Otherwise it returns NO.

 @since v0.99.1

 */

static inline bool ccc4FEqual(ccColor4F a, ccColor4F b)

{

    return a.r == b.r && a.g == b.g && a.b == b.b && a.a == b.a;

}


/** A vertex composed of 2 floats: x, y

 @since v0.8

 */

typedef struct _ccVertex2F  //向量

{

    GLfloat x;

    GLfloat y;

} ccVertex2F;


static inline ccVertex2F vertex2(const float x, const float y)  //vertex2 创建向量

{

    ccVertex2F c = {x, y};

    return c;

}



/** A vertex composed of 2 floats: x, y

 @since v0.8

 */

typedef struct _ccVertex3F //三维向量

{

    GLfloat x;

    GLfloat y;

    GLfloat z;

} ccVertex3F;


static inline ccVertex3F vertex3(const float x, const float y, const float z) //vertex3创建三维向量

{

    ccVertex3F c = {x, y, z};

    return c;

}

        

/** A texcoord composed of 2 floats: u, y

 @since v0.8

 */

typedef struct _ccTex2F {   //纹理坐标

     GLfloat u;

     GLfloat v;

} ccTex2F;


static inline ccTex2F tex2(const float u, const float v)//tex2 创建纹理坐标

{

    ccTex2F t = {u , v};

    return t;

}


 

//! Point Sprite component

typedef struct _ccPointSprite

{

    ccVertex2F    pos;        // 8 bytes

    ccColor4B    color;        // 4 bytes

    GLfloat        size;        // 4 bytes

} ccPointSprite;


//!    A 2D Quad. 4 * 2 floats    //图块 4个顶点(ccVertex2F)组成

typedef struct _ccQuad2 {

    ccVertex2F        tl;

    ccVertex2F        tr;

    ccVertex2F        bl;

    ccVertex2F        br;

} ccQuad2;



//!    A 3D Quad. 4 * 3 floats

typedef struct _ccQuad3 {     //3d图块 4个顶点(ccVertex3F)组成

    ccVertex3F        bl;

    ccVertex3F        br;

    ccVertex3F        tl;

    ccVertex3F        tr;

} ccQuad3;


//! a Point with a vertex point, a tex coord point and a color 4B

typedef struct _ccV2F_C4B_T2F     //采用2维向量 4b颜色 的ccpoint

{

    //! vertices (2F)

    ccVertex2F        vertices;

    //! colors (4B)

    ccColor4B        colors;

    //! tex coords (2F)

    ccTex2F            texCoords;

} ccV2F_C4B_T2F;


//! a Point with a vertex point, a tex coord point and a color 4F

typedef struct _ccV2F_C4F_T2F     //采用2维向量 4f颜色 的ccpoint

{

    //! vertices (2F)

    ccVertex2F        vertices;

    //! colors (4F)

    ccColor4F        colors;

    //! tex coords (2F)

    ccTex2F            texCoords;

} ccV2F_C4F_T2F;


//! a Point with a vertex point, a tex coord point and a color 4B

typedef struct _ccV3F_C4B_T2F    //采用3维向量 4b颜色 的ccpoint

{

    //! vertices (3F)

    ccVertex3F        vertices;            // 12 bytes

//    char __padding__[4];


    //! colors (4B)

    ccColor4B        colors;                // 4 bytes

//    char __padding2__[4];


    // tex coords (2F)

    ccTex2F            texCoords;            // 8 bytes

} ccV3F_C4B_T2F;


//! A Triangle(三角形) of ccV2F_C4B_T2F

typedef struct _ccV2F_C4B_T2F_Triangle   //采用ccV2F_C4B_T2F的三角形

{

//! Point A

ccV2F_C4B_T2F a;

//! Point B

ccV2F_C4B_T2F b;

//! Point B

ccV2F_C4B_T2F c;

} ccV2F_C4B_T2F_Triangle;


//! A Quad of ccV2F_C4B_T2F

typedef struct _ccV2F_C4B_T2F_Quad    //采用ccV2F_C4B_T2F的图块

{

    //! bottom left

    ccV2F_C4B_T2F    bl;

    //! bottom right

    ccV2F_C4B_T2F    br;

    //! top left

    ccV2F_C4B_T2F    tl;

    //! top right

    ccV2F_C4B_T2F    tr;

} ccV2F_C4B_T2F_Quad;


//! 4 ccVertex3FTex2FColor4B

typedef struct _ccV3F_C4B_T2F_Quad   //采用ccV3F_C4B_T2F的图块

{

    //! top left

    ccV3F_C4B_T2F    tl;

    //! bottom left

    ccV3F_C4B_T2F    bl;

    //! top right

    ccV3F_C4B_T2F    tr;

    //! bottom right

    ccV3F_C4B_T2F    br;

} ccV3F_C4B_T2F_Quad;


//! 4 ccVertex2FTex2FColor4F Quad

typedef struct _ccV2F_C4F_T2F_Quad  //采用ccV2F_C4F_T2F的图块

{

    //! bottom left

    ccV2F_C4F_T2F    bl;

    //! bottom right

    ccV2F_C4F_T2F    br;

    //! top left

    ccV2F_C4F_T2F    tl;

    //! top right

    ccV2F_C4F_T2F    tr;

} ccV2F_C4F_T2F_Quad;


//! Blend(混合) Function used for textures

typedef struct _ccBlendFunc      //用于纹理的混合函数

{

    //! source blend function

    GLenum src;    //资源函数

///

typedef unsigned int    GLenum;

//

    //! destination blend function

    GLenum dst;  //目标函数

} ccBlendFunc;


static const ccBlendFunc kCCBlendFuncDisable = {GL_ONE, GL_ZERO};

//

#define GL_ONE                                           1

#define GL_ZERO                                          0


///


// XXX: If any of these enums(枚举) are edited(编辑的) and/or reordered(再订购;重新整理), update CCTexture2D.m

//! Vertical(垂直的) text(文本) alignment(队列) type

typedef enum

{

    kCCVerticalTextAlignmentTop,

    kCCVerticalTextAlignmentCenter,

    kCCVerticalTextAlignmentBottom,

} CCVerticalTextAlignment;


// XXX: If any of these enums are edited and/or reordered, update CCTexture2D.m

//! Horizontal(水平的) text alignment type

typedef enum

{

    kCCTextAlignmentLeft,

    kCCTextAlignmentCenter,

    kCCTextAlignmentRight,

} CCTextAlignment;


// types for animation in particle systems  粒子系统动画类型


// texture coordinates for a quad

typedef struct _ccT2F_Quad

{

    //! bottom left

    ccTex2F    bl;

    //! bottom right

    ccTex2F    br;

    //! top left

    ccTex2F    tl;

    //! top right

    ccTex2F    tr;

} ccT2F_Quad;


// struct that holds the size in pixels, texture coordinates and delays for animated CCParticleSystemQuad

typedef struct

{

    ccT2F_Quad texCoords;

    float delay;

    CCSize size; 

} ccAnimationFrameData;




/**

 types used for defining fonts properties (i.e. font name, size, stroke or shadow(阴影 渐变)) 用于定义字体属性的类型(字体名 大小、、、)

 */


// shadow attributes (阴影 渐变)属性

typedef struct _ccFontShadow

{

public:

    

    // shadow is not enabled by default 默认情况阴影不使用

    _ccFontShadow(): m_shadowEnabled(false) {}

    

    // true if shadow enabled

    bool   m_shadowEnabled;

    // shadow x and y offset

CCSize m_shadowOffset;   //偏移量

    // shadow blurrines

float  m_shadowBlur; //模糊值

    // shadow opacity

float  m_shadowOpacity; //透明值

    

} ccFontShadow;


// stroke attributes

typedef struct _ccFontStroke

{

public:

    

    // stroke is disabled by default

    _ccFontStroke(): m_strokeEnabled(false) {}

    

    // true if stroke enabled

    bool        m_strokeEnabled;

    // stroke color

ccColor3B   m_strokeColor;

    // stroke size

    float       m_strokeSize;

    

} ccFontStroke;


// font attributes

typedef struct _ccFontDefinition   //字体定义

{

public:

    

    _ccFontDefinition():  m_alignment(kCCTextAlignmentCenter),

    m_vertAlignment(kCCVerticalTextAlignmentTop),

    m_fontFillColor(ccWHITE)

    { m_dimensions = CCSizeMake(0,0); }

    

    // font name

    std::string             m_fontName;

    // font size

    int                     m_fontSize;

    // horizontal alignment

    CCTextAlignment         m_alignment;

    // vertical alignment

    CCVerticalTextAlignment m_vertAlignment;

    // renering box

    CCSize                  m_dimensions;

    // font color

    ccColor3B               m_fontFillColor;

    // font shadow

    ccFontShadow            m_shadow;

    // font stroke

    ccFontStroke            m_stroke;

    

} ccFontDefinition;



NS_CC_END


#endif //__CCTYPES_H__


这篇关于ccTypes(各种类型--ccColor3B ccVertex2F ccQuad2 ccQuad3 ccBlendFunc ccFontDefinition)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/661564

相关文章

C# 中变量未赋值能用吗,各种类型的初始值是什么

对于一个局部变量,如果未赋值,是不能使用的 对于属性,未赋值,也能使用有系统默认值,默认值如下: 对于 int 类型,默认值是 0;对于 int? 类型,默认值是 null;对于 bool 类型,默认值是 false;对于 bool? 类型,默认值是 null;对于 string 类型,默认值是 null;对于 string? 类型,哈哈,没有这种写法,会出错;对于 DateTime 类型,默

如何实现各种行业各种类型会员卡体系的设计

背景:目前很多的公司都有自己的会员体系,那么如何让用户成为会员呢?增加用户的粘性。如果你是一个架构师如何长远的设计整体的方案,从而兼容各种业务场景的使用?比如淘宝的88vip会员卡,肯德基的会员卡,麦当劳的会员卡,鲜丰水果的会员卡,京东会员卡,等等各种电子会员卡,有的是收费的,有的是免费的。 设计:

stm32 各种类型错误:HardFault_Handler、MemManage_Handler、BusFault_Handler、UsageFault_Handler

STM32出现HardFault_Handler故障的原因主要有两个方面: 1、内存溢出或者访问越界。这个需要自己写程序的时候规范代码,遇到了需要慢慢排查。 2、堆栈溢出。增加堆栈的大小。   MemManage_Handler:访问了内存管理单元(MPU)定义的不合法的内存区域,比如向只读区域写入数据。 BusFault_Handler:在fetch指令、数据读写、fetch中断向量或

Spring使用@Value注解各种类型的值(Map,List,Set,数组,基本数据类型)

Spring使用@Value注解各种类型的值 在application.properties写入下面代码 test.boolean=truetest.string=abctest.integer=123test.long=123test.float=1.2345678123456test.double=1.2345678123456test.array=1,3,4,5,6,1,2,

在C语言中各种类型数据所占字节数

和机器字长及编译器有关系:所以,int,long int,short int的宽度都可能随编译器而异。但有几条铁定的原则(ANSI/ISO制订的): 1 sizeof(short int)<=sizeof(int) 2 sizeof(int)<=sizeof(long int) 3 short int至少应为16位(2字节) 4 long int至少应为32位。 unsigned 是无符

各种类型的数据的相异度(相似度)的度量

这个大家都懂,这里参考别人的文章,记录下来方便以后回看。 1.对于标量      标量也就是无方向意义的数字,也叫标度变量。现在先考虑元素的所有特征属性都是标量的情况。例如,计算X={2,1,102}和Y={1,3,2}的相异度。一种很自然的想法是用两者的欧几里得距离来作为相异度,欧几里得距离的定义如下:        其意义就是两个元素在欧氏空间中的集合距离,因为其直观易懂且可解释性强,

飘逸的python - 发送带各种类型附件的邮件

上一篇博文演示了如何发送简单的邮件,这一篇将演示如何发送各种类型的附件。 基本思路就是,使用MIMEMultipart来标示这个邮件是多个部分组成的,然后attach各个部分。如果是附件,则add_header加入附件的声明。 在python中,MIME的这些对象的继承关系如下。 MIMEBase     |-- MIMENonMultipart         |-- MIM

探究Android的多分辨率支持以及各种类型图标尺寸大小

术语和概念 屏幕尺寸  屏幕的物理尺寸,以屏幕的对角线长度作为依据(比如 2.8寸, 3.5寸)。  简而言之, Android把所有的屏幕尺寸简化为三大类:大,正常,和小。  程序可以针对这三种尺寸的屏幕提供三种不同的布局方案,然后系统会负责把你的布局方案以合适的方式渲染到对应的屏幕上,这个过程是不需要程序员用代码来干预的。 屏幕长宽比  屏幕的物理长度与物理宽度的比例。程序可以为制定

dbutils各种类型处理器

1.ArrayHandler把结果集的第一行数据转换成对象数组 @Testpublic void testArrayHandler() throws SQLException{QueryRunner qr=new QueryRunner(JdbcUtils.getDataSource());String sql="select * from user";Object result[]

js中各种类型的变量在if条件中是true还是false

申明如下变量: var a, b=-1, c= 1, d= 0, e=null, f=undefined, g='', h=""; if(!a){  console.log('a='+a)  }  if(!b){  console.log("b="+b)  }  if(!c){  console.log("c="+c)  }  if(!d){  console.log("d="+d)  }  if