Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 无法设置深度缓冲区?_Iphone_Objective C_Cocos2d Iphone - Fatal编程技术网

Iphone 无法设置深度缓冲区?

Iphone 无法设置深度缓冲区?,iphone,objective-c,cocos2d-iphone,Iphone,Objective C,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:kDep

我被告知要把这个放进去

// 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];

允许在我的游戏中使用动作产生一些3D效果。然而,由于某些原因,XCode既不能识别
setDepthBufferFormat
也不能识别
kDepthBuffer16
。有什么想法吗?

不幸的是,cocos2d文档部分过时了。你提到的方法已经不存在了。相反,您必须修改应用程序委托方法ApplicationIDFinishLaunching中初始化EAGLView的行。有一个“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];

啊。谢谢顺便问一下,你知道为什么当我运行3d动作时,背景会变黑吗?可能是因为缺少深度缓冲区。您可能还必须启用深度测试:[[CCDirector sharedDirector]setDepthTest:YES];