python 中没有 glGenFramebuffers,但在 javascript 中可用

No glGenFramebuffersin python but available in javascript

我正在尝试使用 OpenGL 库将 hackathon-slicer 移植到 python3。黑客马拉松切片器在 node/javascript 中编程,在我的旧笔记本电脑上运行良好。

然而,当我使用 OpenGL 库将它移植到 python 时,我在 'glGenFramebuffers' 上收到错误,因为 glGenFramebuffers 不可用。我检查了一下,OpenGL 库有可用的功能。此外,由于它在 node/javascript 中运行良好,我的笔记本电脑显卡也有可用的 FrameBuffer。

那么真正的问题是什么以及如何解决呢?非常感谢任何帮助!

找到问题了。在创建 OpenGL 上下文之后,您显然只有 glGenFramebuffers。上下文现在在 class init.

中创建
class Viewport:
def display(self):
    # Clear the color and depth buffers
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)

    # ... render stuff in here ...
    # It will go to an off-screen frame buffer.

    # Copy the off-screen buffer to the screen.
    glutSwapBuffers()

def __init__(self):
    glutInit(sys.argv)

    # Create a double-buffer RGBA window.   (Single-buffering is possible.
    # So is creating an index-mode window.)
    glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_DEPTH)

    # Create a window, setting its title
    glutCreateWindow('interactive')

    # Set the display callback.  You can set other callbacks for keyboard and
    # mouse events.
    glutDisplayFunc(self.display)

在此之后,以下代码开始工作:

    def renderSlice(self):
    glDisable(GL_DEPTH_TEST)
    glEnable(GL_STENCIL_TEST)
    glViewport(0, 0, 2560,1440)#printer.resolution.x, printer.resolution.y)

    # Bind the target framebuffer
    sliceFbo = glGenFramebuffers(1)