我想创建一个FrameBufferObject,但它失败了,我不知道为什么。
这是我的代码,它在第4行失败并显示以下错误消息:
ERROR:
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
CODE:
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);
答案 0 :(得分:1)
glGenRenderbuffersEXT
应该获得您想要创建的缓冲区数量(在这种情况下可能为1),而不是GL_RENDERBUFFER_EXT作为参数。