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