0

我想创建一个 FrameBufferObject,但它失败了,我不知道为什么。

这是我的代码,它在第 4 行失败并显示以下错误消息:

错误:

Traceback (most recent call last):
  File "/home/julius/workspace/Bachelor/Final/Exporter/FBOtest.py", line 154, in <module>
    fbo.mainGameLoop()
  File "/home/julius/workspace/Bachelor/Final/Exporter/FBOtest.py", line 142, in mainGameLoop
    self.createFBO()
  File "/home/julius/workspace/Bachelor/Final/Exporter/FBOtest.py", line 55, in createFBO
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, self.depthbuffer)
  File "/usr/lib/pymodules/python2.7/OpenGL/platform/baseplatform.py", line 335, in __call__
    return self( *args, **named )
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type

代码:

    self.fbo = glGenFramebuffersEXT(1)
    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, self.fbo)
    self.depthbuffer = glGenRenderbuffersEXT(GL_RENDERBUFFER_EXT)
    glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, self.depthbuffer)
    glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, width, height)
    glFramebufferReadBufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, self.depthbuffer)

    self.texture = glGenTextures(1)
    glBindTexture(GL_TEXTURE_2D, self.texture)
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST)
    glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST)
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, None);
    glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,  GL_TEXTURE_2D, self.texture, 0);
4

1 回答 1

1

glGenRenderbuffersEXT应该获取您希望创建的缓冲区数量(在这种情况下可能为 1),而不是 GL_RENDERBUFFER_EXT 作为参数。

于 2012-07-26T13:59:13.690 回答