Using glScissor from JS

Using glScissor from JS
0.0 0


I’d like to add the option to make some of my views clip their children. It doesn’t look like this is possible, though, as the standard solution involves making the relevant glScissor calls in the CCNode::visit() method, which I can’t override in my own JS classes. What’s the recommended way to add support for this behavior?

It looks like CCClippingNode might provide what I want, but there are no JSB bindings for it. Is this intentional, or has it just not been done yet?


You could implement a simple layer and override the `draw` method.
In the beginning of draw method, you should enable GL_SCISSOR_TEST and invoke`glScissor` while at the end, disable GL_SCISSOR_TEST. You could refer to CCScrollView.
Then expose this class to JS.


I too had this requirement and was trying to use CCClippingNode or glScissor but there were no bindings.

Can we have JSB for CCClippingNode in the next version? It would be very useful.


But not finished.


Thats great, thanks so much James


Looks like a fairly straightforward way to expose it. I’ll test it out on my end and see what extra bits I need to add to get it to play nicely.