14

Yosemite 中的 Xcode 6 iOS SDK 8.0 给我的 OpenGL ES2 代码错误,该代码在 Xcode 5 下编译良好

GLuint depthStencilRenderbuffer;
glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthStencilRenderbuffer);
glRenderbufferStorageOES(GL_RENDERBUFFER_OES,
                         GL_DEPTH24_STENCIL8_OES,
                         self.view.bounds.size.width,
                         self.view.bounds.size.height);

产生错误:

第 2 行:

'glBindRenderBufferOES' 的冲突类型

使用未声明的标识符“GL_RENDERBUFFER_OES”

第 3 行:

包含“glBindRenderBufferOES”的隐式声明在 C99 中无效

编辑:好的,我可以通过替换:

GLuint depthStencilRenderbuffer;
glBindRenderbuffer(GL_RENDERBUFFER, depthStencilRenderbuffer);
glRenderbufferStorage(GL_RENDERBUFFER,
                      GL_STENCIL_INDEX8,
                      self.view.bounds.size.width,
                      self.view.bounds.size.height);

仍然-我不知道为什么需要进行此更改,我希望能进一步了解这里发生的情况。

4

2 回答 2

54

尝试:

#import <OpenGLES/ES2/glext.h>

或者

#import <OpenGLES/ES3/glext.h>

为我工作。

没有它,在 xcode 6 + ios7 上正确运行的应用程序可以找到 GL_FALSE 和其他..

于 2014-06-17T06:29:21.637 回答
6

I think @reto-koradi's comment is correct. I had a problem in my code that was similarly broken in iOS8. They've changed how some of the headers include other headers so here are the steps I took:

  1. Got to Xcode5 and locate the same line that is broken in Xcode6/iOS8.
  2. Command-click that link and find out which header file it's in.
  3. Go back to Xcode6/iOS8 and find that file.

For me it was #import <OpenGLES/ES2/glext.h> because some of the glextensions I was using was missing.

于 2014-06-10T22:52:26.250 回答