我想创建一个 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);