PyOpenGL 帧缓冲

3
我正在尝试使用PyOpenGL中的framebuffer对象,并找到了一些教程来自学。我使用Python 2.7.3在WinXP机器上工作,并刚刚安装了PyOpenGL 3.0.2和PyOpenGL-accelerate 3.0.2的二进制分发版。然而,在开始时我就遇到了一个问题,即我收到错误消息,提示fbo函数似乎不存在。以下是重现我的问题的步骤:
导入模块:
from OpenGL.GL import *
from OpenGL.GLU import *
from OpenGL.GL.framebufferobjects import *

我现在应该能够使用帧缓冲对象/函数了。
print glGenFramebuffers
print glBindFramebuffer

展示
<OpenGL.extensions.glGenFramebuffers object at 0x03172260>
<OpenGL.extensions.glBindFramebuffer object at 0x03172120>

然而,如果按照教程指定的方式尝试调用(创建一个实例)该对象,使用以下代码:
fbo = glGenFramebuffers(1)
glBindFramebuffer(GL_FRAMEBUFFER, fbo )

I get the error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "latebind.pyx", line 31, in OpenGL_accelerate.latebind.LateBind.__call__ (src\latebind.c:645)
  File "C:\Python27\lib\site-packages\OpenGL\extensions.py", line 189, in finalise
    self.__name__,
OpenGL.error.NullFunctionError: Attempt to call an undefined alternate function (glGenFramebuffers, glGenFramebuffersEXT), check for bool(glGenFramebuffers) before calling

使用

bool(glGenFramebuffers)

确实返回False。

我做错了什么?难道PyOpenGL(-accelerate)的二进制文件不应该安装所有必需的帧缓冲库吗?

感谢任何能够帮助我的人提前。

编辑:我刚刚发现https://stackoverflow.com/questions/12953134/problems-with-frame-buffer-objects-fbos-in-pyopengl,有一个类似的问题,但没有解决方案。


1
http://pyopengl.sourceforge.net/context/tutorials/shadow_2.xhtmlorhttp://www.opengl.org/wiki/Framebuffer_Object_Examples#Quick_example.2C_render_to_texture_.282D.29orhttp://bazaar.launchpad.net/~mcfletch/openglcontext/trunk/view/head:/tests/shadow_2.py - undefined
1个回答

1

显然,如果您从文件中运行它,则上述代码不会显示此行为并且可以正常运行。我在控制台中尝试了上述命令,然后

bool(glGenFramebuffers)

返回 False

当从文件运行时,它返回 True 并且一切正常运作。 此外,您似乎不需要包括


from OpenGL.GL.framebufferobjects import *

在较新版本的PyOpenGL(>= 3.0.2)中,您也可以访问帧缓冲对象,而无需使用它。

这可能是因为在进行任何与帧缓冲对象相关的操作之前,你必须创建一个OpenGL上下文(即打开OpenGL窗口并启动glut主循环)。我也曾多次被这个问题困扰。 - undefined

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接