In iOS7 and before, everything goes well, in simulator and device.
After I upgrade my XCode to version 6.0, iOS simulator also became iOS8, “Stencil buffer is not enabled.” raised then. My iOS8 device has the same problems.
In AppController.mm, depthFormat is always be setted:
[[UIApplication sharedApplication] setStatusBarHidden: YES];
// Add this line code, force calling resizeFromLayer, which will actually create the render buffer with depth buffer and stencil buffer
[__glView layoutSubviews];
cocos2d::CCApplication::sharedApplication()->run();
This fix is not very elegant, as “layoutSubviews” in apple’s documents said:
"You should not call this method directly. If you want to force a layout update, call the setNeedsLayout method instead to do so prior to the next drawing update. "
I tried “setNeedsLayout” but not works. As my first scene will be drawn immediately.
As a result if your first scene need to use “Stencil Buffer”, a short fix is directly call “layoutSubviews” before CCApplication run.
If this issue can be fixed in cocos2dx, that will be nice.
This problem has bugged me for several days.