4 description: 主要使用OpenGL提供的glScissor函数。
10 <div class="page-header">
11 <h3>一、在Cocos2d-x中就这样来实现区域的显示</h3>
13 <pre class="prettyprint">
14 class HelloLayer: cocos2d::CCLayer
17 virtual void visit(void);
21 void HelloLayer::visit()
23 glEnable(GL_SCISSOR_TEST); // 开启显示指定区域
24 float x = this->getPositionX();
25 float y = this->getPositionY();
26 float n_width = this->getContentSize().width;
27 float n_height = this->getContentSize().height;
28 glScissor(x, y, n_width, n_height); // 只显示当前窗口的区域
29 CCLayer::visit(); // 调用下面的方法
30 glDisable(GL_SCISSOR_TEST); // 禁用