无法设置深度缓冲区?

Vol*_*ort 4 iphone objective-c cocos2d-iphone

一些cocos2d-iphone文档中,我被告知要放这个

// 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];
Run Code Online (Sandbox Code Playgroud)

通过动作在我的游戏中允许一些3D效果.但是,出于某种原因,XCode 既setDepthBufferFormat不会kDepthBuffer16识别也不会识别.有任何想法吗?

Lea*_*s2D 6

不幸的是,cocos2d文档已部分过时.您提到的方法不再存在.相反,您必须修改初始化EAGLView的app委托方法applicationDidFinishLaunching中的行.有一个"viewWithFrame"变体,它接受了depthFormat的额外参数:

// 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];
Run Code Online (Sandbox Code Playgroud)