cocos2d/cocos2d-iphone — pull request #252 by pierredavidbelanger (2012-10-22 05:21:07+00:00)
Title: Clipping node

Here is a new type of node: CCClippingNode.

This node can be used to restrict the drawing of some content (its childs) inside a stencil (an other node and its childs), also the clipping node can be used in inverted mode to restrict the drawing to the outside of the stencil instead of inside.

This node uses
- the graphic card stencil buffer to achieve fast clipping.,
- and can optionally treat pixel bellow an alpha threshold as an absence of pixel, using the graphic card alpha test on OSX or shaders on iOS, thus allowing one to use as a stencil an image with alpha.

This branch contains:
- the code to enable the stencil buffer on iOS OES framebuffer
- a new node (CCClippingNode)
- a set of tests and demos + a new target for those tests

Everything works on iOS and OS X, using optimizations on OS X where possible.

Do not hesitate to let me know what you think.

I will stop working on this branch for now unless you need me to commit something else.

Thank you, and I hope you and the community will find this little addition as useful as I am.