Can't set the depth buffer?

In some cocos2d-iphone documentation , I was told to attach this

// IMPORTANT: Call this function at the very beginning, before running your 1st scene // Create a depth buffer of 24 bits // These means that openGL z-order will be taken into account [[CCDirector sharedDirector] setDepthBufferFormat:kDepthBuffer16]; 

Allow some 3D effects in my action game. However, for some reason, Xcode does not recognize either setDepthBufferFormat or kDepthBuffer16 . Any ideas?

+4
source share
1 answer

Unfortunately, the cocos2d documentation is partially outdated. The method you specified no longer exists. Instead, you have to change the line in the application delegation application applicationDidFinishLaunching, which initializes the EAGLView. There's a “viewWithFrame” option that accepts additional depthFormat parameters:

 // Create an EAGLView with a RGB8 color buffer, and a depth buffer of 24-bits EAGLView* glView = [EAGLView viewWithFrame:[window bounds] pixelFormat:kCCTexture2DPixelFormat_RGBA8888 depthFormat:GL_DEPTH_COMPONENT16_OES preserveBackbuffer:NO sharegroup:nil multiSampling:NO numberOfSamples:0]; 
+6
source

All Articles