I had some trouble with the CCClippingNode on the Apportable Compiler earlier this week. I had it working perfectly well in iOS, but when I cross-compiled my application to Android, my CCClippingNode wasn’t working and all I was getting was this lovely little error message:
[CCClippingNode initWithStencil:]_block_invoke : Stencil buffer is not enabled; enable it by passing GL_DEPTH24_STENCIL8_OES into the depthFormat parrameter when initializing CCGLView. Until then, everything will be drawn without stencil.
The solution to this problem is actually pretty simple. We will need to modify function setupView: in Platforms/Android/CCGLView.m.
CCGLView is setting the depth and stencil size to 0 when it calls its eglChooseConfig method. In order to get non-zero values, we’ll have to add the data to our CCGLView class manually.
This can be done by adding the following two lines to structure
configAttribs (at the very beginning of function setupView:)
And Voila! We’ve got our CCClippingNode starting to clip contents on Android too.