【发布时间】:2012-03-08 11:59:36
【问题描述】:
为什么glTexSubImage2D()会突然导致GL_INVALID_OPERATION?
我正在尝试将我过时的增强现实应用程序从 iOS4.x 升级到 iOS5.x,但我遇到了困难。我运行iOS5.0。上周我跑了iOS4.3。我的设备是 iPhone4。
这是我的captureOutput:didOutputSampleBuffer:fromConnection: 代码中的一个 sn-p
uint8_t *baseAddress = /* pointer to camera buffer */
GLuint texture = /* the texture name */
glBindTexture(GL_TEXTURE_2D, texture);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 480, 360, GL_BGRA, GL_UNSIGNED_BYTE, baseAddress);
/* now glGetError(); -> returns 0x0502 GL_INVALID_OPERATION on iOS5.0, works fine on iOS4.x */
这是我的设置代码中的一个 sn-p
GLuint texture = /* the texture name */
glGenTextures(1, &texture);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 512, 512, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
为简单起见,我在此处插入了硬编码值。在我的实际代码中,我使用 CVPixelBufferGetWidth/Height/BaseAddress 获取这些值。 EAGLContext 使用 kEAGLRenderingAPIOpenGLES2 初始化。
【问题讨论】:
标签: ios opengl-es-2.0 augmented-reality