无法设置深度缓冲区?

发布于 2024-12-10 14:31:11 字数 530 浏览 0 评论 0原文

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

允许在我的游戏中使用一些 3D 效果和动作。但是,由于某种原因,XCode 无法识别 setDepthBufferFormatkDepthBuffer16。有什么想法吗?

In some cocos2d-iphone documentation, I was told to put 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];

To allow some 3D effects in my game with actions. However, for some reason, neither setDepthBufferFormat nor kDepthBuffer16 are recognized by XCode. Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

难忘№最初的完美 2024-12-17 14:31:11

不幸的是,cocos2d 文档部分已过时。你提到的方法已经不存在了。相反,您必须修改应用程序委托方法 applicationDidFinishLaunching 中初始化 EAGLView 的行。有一个“viewWithFrame”变体,它采用 heightFormat 的额外参数:

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

The cocos2d documentation is partially out of date, unfortunately. The method you mentioned no longer exists. Instead, you will have to modify the line in the app delegate method applicationDidFinishLaunching that initializes the EAGLView. There's a "viewWithFrame" variant that takes the extra parameters of 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];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文