Render a SceneGraph with PyOpenGL

2019-07-10 13:02发布

问题:

I'm using OpenGLContext to load a VRML file into a SceneGraph object. Unfortunately, for the life of me I can't find any example showing how to render the SceneGraph.

I've created a context with testcontext.getInteractive(), but now what? How do I render a SceneGraph?

回答1:

It's quite poorly documented. All that needs to be done is create a context class and set its sg field, like so:

def MyContext(BaseContext):
    def OnInit(self):
        self.sg = ... load your scene graph here ...

    def OnRender(self, mode):
        return

And that's it, the scene is rendered properly.



回答2:

Take a look at: http://pyopengl.sourceforge.net/context/tutorials/shader_1.xhtml It steps you through the process with some thorough explanations.