Skip to content

Instantly share code, notes, and snippets.

@binho
Forked from l4u/gist:2233073
Created March 29, 2012 14:26
Show Gist options
  • Save binho/2237952 to your computer and use it in GitHub Desktop.
Save binho/2237952 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