在iOS上渲染纹理的最小配置

时间:2014-09-17 08:43:41

标签: ios opengl-es framebuffer

我的代码:

// setup framebuffer
glGenFramebuffers(1, &_internalFramebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, _internalFramebuffer);

// reference texture
glGenTextures(1, &_referenceRectifiedTexture);
glBindTexture(GL_TEXTURE_2D, _referenceRectifiedTexture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, width, height, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, _referenceRectifiedTexture, 0);

glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT);

// check status
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);

if (status != GL_FRAMEBUFFER_COMPLETE) {
  NSLog(@"failed to make complete framebuffer object %x", status);
  return NO;
}

它永远不会通过状态检查。除了绑定帧缓冲区和纹理之外,我还需要做其他的事吗?

0 个答案:

没有答案