Skip to content

Instantly share code, notes, and snippets.

@zaneclaes
Created November 7, 2013 23:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaneclaes/7363611 to your computer and use it in GitHub Desktop.
Save zaneclaes/7363611 to your computer and use it in GitHub Desktop.
@implementation AMLayer
- (void)visit {
CGRect mask = self.maskArea;
BOOL shouldMask = !CGSizeEqualToSize(mask.size, CGSizeZero);
if(shouldMask) {
CGFloat s = CC_CONTENT_SCALE_FACTOR();
CGPoint origin = CGPointMake(mask.origin.x*s, mask.origin.y*s);
CGSize size = CGSizeMake(mask.size.width*s, mask.size.height*s);
glEnable(GL_SCISSOR_TEST);
glScissor(origin.x, origin.y, size.width, size.height);
}
[super visit];
if(shouldMask) {
glDisable(GL_SCISSOR_TEST);
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment