#include 2d/CCNode.h//用到节点头文件和OPENGL深度缓冲定义头文件#include CCGL.h#include renderer/CCGroupCommand.h//用到GroupCommand和CustomCommand渲染#include renderer/CCCustomCommand.hNS_CC_BEGIN/** ClippingNode is a subclass of Node. It dr
#include "2d/CCNode.h"//用到节点头文件和OPENGL深度缓冲定义头文件 #include "CCGL.h" #include "renderer/CCGroupCommand.h"//用到GroupCommand和CustomCommand渲染 #include "renderer/CCCustomCommand.h" NS_CC_BEGIN /** ClippingNode is a subclass of Node. It draws its content (childs) clipped using a stencil. The stencil is an other Node that will not be drawn. The clipping is done using the alpha part of the stencil (adjusted with an alphaThreshold). */ class CC_DLL ClippingNode : public Node { public: /** Creates and initializes a clipping node without a stencil. */ static ClippingNode* create();//静态创建对象 /** Creates and initializes a clipping node with an other node as its stencil. The stencil node will be retained. */ static ClippingNode* create(Node *stencil);//用模板创建裁剪节点 /** The Node to use as a stencil to do the clipping. The stencil node will be retained. This default to nil. */ Node* getStencil() const;//获取节点模板 void setStencil(Node *stencil);//设置节点模板 /** The alpha threshold. The content is drawn only where the stencil have pixel with alpha greater than the alphaThreshold. Should be a float between 0 and 1. This default to 1 (so alpha test is disabled). *///ALPHA测试参考值,用于进行ALPHA测试比较,一般比较算法为小于此值的像素会直接被舍弃,这样就实现了图像的镂空 GLfloat getAlphaThreshold() const;//获取ALPHT的测试参考值 void setAlphaThreshold(GLfloat alphaThreshold);//设置ALPHA的测试参考值 /** Inverted. If this is set to true, the stencil is inverted, so the content is drawn where the stencil is NOT drawn. This default to false. */ bool isInverted() const;//获取遮罩运算是否取反设置 void setInverted(bool inverted);//设置遮罩运算取反 // Overrides//继承的函数 /** * @js NA * @lua NA */ virtual void onEnter() override; /** * @js NA * @lua NA */ virtual void onEnterTransitionDidFinish() override; /** * @js NA * @lua NA */ virtual void onExitTransitionDidStart() override; /** * @js NA * @lua NA */ virtual void onExit() override; virtual void visit(Renderer *renderer, const Mat4 &parentTransform, bool parentTransformUpdated) override; CC_CONSTRUCTOR_ACCESS: ClippingNode(); /** * @js NA * @lua NA */ virtual ~ClippingNode(); /** Initializes a clipping node without a stencil. */ virtual bool init(); /** Initializes a clipping node with an other node as its stencil. The stencil node will be retained, and its parent will be set to this clipping node. */ virtual bool init(Node *stencil); protected: /**draw fullscreen quad to clear stencil bits */ void drawFullScreenQuadClearStencil(); Node* _stencil; GLfloat _alphaThreshold; bool _inverted; //renderData and callback void onBeforeVisit(); void onAfterDrawStencil(); void onAfterVisit(); GLboolean _currentStencilEnabled; GLuint _currentStencilWriteMask; GLenum _currentStencilFunc; GLint _currentStencilRef; GLuint _currentStencilValueMask; GLenum _currentStencilFail; GLenum _currentStencilPassDepthFail; GLenum _currentStencilPassDepthPass; GLboolean _currentDepthWriteMask; GLboolean _currentAlphaTestEnabled; GLenum _currentAlphaTestFunc; GLclampf _currentAlphaTestRef; GLint _mask_layer_le; GroupCommand _groupCommand; CustomCommand _beforeVisitCmd; CustomCommand _afterDrawStencilCmd; CustomCommand _afterVisitCmd; private: CC_DISALLOW_COPY_AND_ASSIGN(ClippingNode); }; NS_CC_END
3、使用实例
<pre name="code" class="cpp">class NewClippingNode : public Layer { public: CREATE_FUNC(NewClippingNode); virtual bool init(); };
boolNewClippingNode::init()
{
auto s =Director::getInstance()->getWinSize();
bool bRet = false;
do{
CC_BREAK_IF(!Layer::init());
auto clipper = ClippingNode::create();
clipper->setTag(kTagClipperNode);
clipper->setContentSize(Size(200,200));//设置剪裁区域大小
clipper->ignoreAnchorPointForPosition(false);
clipper->setAnchorPoint(Vec2(0.5,0.5));//设置锚点
clipper->setPosition(Vec2(s.width/2, s.height/2));
this->addChild(clipper);
clipper->setAlphaThreshold(0.05f);//设置透明度的阈值ALPHA值
//设置剪裁模板
auto stencil = Sprite::create("grossini.png");
stencil->setScale(2);
stencil->setPosition(Vec2(s.width/2, s.height/2));
clipper->setStencil(stencil);//设置剪裁模板
//TODO Fix draw node as clip node
// auto stencil = NewDrawNode::create();
// Vec2 rectangle[4];
// rectangle[0] = Vec2(0, 0);
// rectangle[1] = Vec2(clipper->getContentSize().width, 0);
// rectangle[2] = Vec2(clipper->getContentSize().width, clipper->getContentSize().height);
// rectangle[3] = Vec2(0, clipper->getContentSize().height);
//
// Color4F white(1, 1, 1, 1);
// stencil->drawPolygon(rectangle, 4, white, 1, white);
// clipper->setStencil(stencil);
//设置剪裁节点内容
auto content = Sprite::create("background2.png");
content->setTag(kTagContentNode);
content->ignoreAnchorPointForPosition(false);
content->setAnchorPoint(Vec2(0.5,0.5));
content->setPosition(Vec2(s.width/2,200));
clipper->addChild(content);
bRet =true;
}while(0);
return bRet;
}

ACID属性包括原子性、一致性、隔离性和持久性,是数据库设计的基石。1.原子性确保事务要么完全成功,要么完全失败。2.一致性保证数据库在事务前后保持一致状态。3.隔离性确保事务之间互不干扰。4.持久性确保事务提交后数据永久保存。

MySQL既是数据库管理系统(DBMS),也与编程语言紧密相关。1)作为DBMS,MySQL用于存储、组织和检索数据,优化索引可提高查询性能。2)通过SQL与编程语言结合,嵌入在如Python中,使用ORM工具如SQLAlchemy可简化操作。3)性能优化包括索引、查询、缓存、分库分表和事务管理。

MySQL使用SQL命令管理数据。1.基本命令包括SELECT、INSERT、UPDATE和DELETE。2.高级用法涉及JOIN、子查询和聚合函数。3.常见错误有语法、逻辑和性能问题。4.优化技巧包括使用索引、避免SELECT*和使用LIMIT。

MySQL是一种高效的关系型数据库管理系统,适用于存储和管理数据。其优势包括高性能查询、灵活的事务处理和丰富的数据类型。实际应用中,MySQL常用于电商平台、社交网络和内容管理系统,但需注意性能优化、数据安全和扩展性。

SQL和MySQL的关系是标准语言与具体实现的关系。1.SQL是用于管理和操作关系数据库的标准语言,允许进行数据的增、删、改、查。2.MySQL是一个具体的数据库管理系统,使用SQL作为其操作语言,并提供高效的数据存储和管理。

InnoDB使用redologs和undologs确保数据一致性和可靠性。1.redologs记录数据页修改,确保崩溃恢复和事务持久性。2.undologs记录数据原始值,支持事务回滚和MVCC。

EXPLAIN命令的关键指标包括type、key、rows和Extra。1)type反映查询的访问类型,值越高效率越高,如const优于ALL。2)key显示使用的索引,NULL表示无索引。3)rows预估扫描行数,影响查询性能。4)Extra提供额外信息,如Usingfilesort提示需要优化。

Usingtemporary在MySQL查询中表示需要创建临时表,常见于使用DISTINCT、GROUPBY或非索引列的ORDERBY。可以通过优化索引和重写查询避免其出现,提升查询性能。具体来说,Usingtemporary出现在EXPLAIN输出中时,意味着MySQL需要创建临时表来处理查询。这通常发生在以下情况:1)使用DISTINCT或GROUPBY时进行去重或分组;2)ORDERBY包含非索引列时进行排序;3)使用复杂的子查询或联接操作。优化方法包括:1)为ORDERBY和GROUPB


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

Dreamweaver Mac版
视觉化网页开发工具

记事本++7.3.1
好用且免费的代码编辑器