Skip to content

Instantly share code, notes, and snippets.

@l4u
Created March 29, 2012 03:43
Show Gist options
  • Save l4u/2233073 to your computer and use it in GitHub Desktop.
Save l4u/2233073 to your computer and use it in GitHub Desktop.
Layer Clipping cocos2d-x
//http://codewars.net/304/layer-clipping-in-cocos2d-x/
void CCClippingLayer::visit()
{
// quick return if not visible
if (!getIsVisible())
{
return;
}
glPushMatrix();
glEnable(GL_SCISSOR_TEST);
CCEGLView::sharedOpenGLView().setScissorInPoints( // scissorRect is the rectangle you want to show.
clippingRegion.origin.x + getPosition().x, clippingRegion.origin.y + getPosition().y,
clippingRegion.size.width, clippingRegion.size.height);
CCNode::visit();
glDisable(GL_SCISSOR_TEST);
glPopMatrix();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment