I started a new iOS project recently. I'd like to support also Android so I choose SpriteBuilder with newest cocos2d-iphone (cocos2d-swift).
I use CCClippingNode for clipping contents. It needs 24bit depth buffer and 8 bit stencil buffer, so I needed to add the following line to AppDelegate.m to application:didFinishLaunchingWithOptions:
[cocos2dSetup setObject:@GL_DEPTH24_STENCIL8_OES forKey:CCSetupDepthFormat];
naturally this is only for iOS. According to logs it should work for Android without any additional code, as it logs the following lines on startup:
EGL_DEPTH_SIZE = 24
EGL_STENCIL_SIZE = 8
Later when I create CCClippingNode in code, it logs:
[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.
It happens because the following line in CCClippingNode.m returns 0:
glGetIntegerv(GL_STENCIL_BITS, &_stencilBits);
On iOS GL_STENCIL_BITS is 8 (after setting CCSetupDepthFormat to GL_DEPTH24_STENCIL8_OES). On Android it's 0.
What should I do to make it work also on Android?
I use SpriteBuilder 1.4.0-beta.3 and Cocos2D-Swift version 3.4.1-develop