I'm writing an app with multiple openGL windows showing views of a single world. I want to use a shared context (or at least contexts which share textures etc) to minimize code complexity and resource duplication.
I've discovered that wxPython differs somewhat from wxWidgets in the GLCanvas constructor. Specifically, wxWidgets offers a "shared" constructor parameter to allow canvases to share a context. wxPython's GLCanvas class doesn't have this parameter, but there is a module (factory) function GLCanvasWithContext which has a "shared" parameter which hopefully makes a shared GLCanvas instance.
What I'm struggling with is how to use this in an inherited class...
class MyGLCanvas(wx.glcanvas.GLCanvas):
def __init__(self, parent):
glcanvas.GLCanvas.__init__(self, parent, -1)
obviously works fine with the standard constructor, but how can I use the factory method in the constructor of a derived class?
I'm rather new to Python, and haven't faced this problem before, so any help would be useful.
I'm writing an app with multiple openGL windows showing views of a single world. I want to use a shared context (or at least contexts which share textures etc) to minimize code complexity and resource duplication.
I've discovered that wxPython differs somewhat from wxWidgets in the GLCanvas constructor. Specifically, wxWidgets offers a "shared" constructor parameter to allow canvases to share a context. wxPython's GLCanvas class doesn't have this parameter, but there is a module (factory) function GLCanvasWithContext which has a "shared" parameter which hopefully makes a shared GLCanvas instance.
What I'm struggling with is how to use this in an inherited class...
class MyGLCanvas(wx.glcanvas.GLCanvas):
def __init__(self, parent):
glcanvas.GLCanvas.__init__(self, parent, -1)
obviously works fine with the standard constructor, but how can I use the factory method in the constructor of a derived class?
The PostCreate method is a Python specific function that transfers the internal proxy pointer from canvas to self, as well as some other housekeeping chores. Normally you would use it for the final step in a 2-phase create situation, but it should work here too.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
I'm writing an app with multiple openGL windows showing views of a single world. I want to use a shared context (or at least contexts which share textures etc) to minimize code complexity and resource duplication.
Just a note, AFAIK the bug discussed here a few weeks ago with wxPython not properly dispatching events to the proper GLCanvas when multiple canvases are active is still unresolved. Be prepared to have to figure out a work-around for that as you move forward in your project.
The PostCreate method is a Python specific function that transfers the internal proxy pointer from canvas to self, as well as some other housekeeping chores. Normally you would use it for the final step in a 2-phase create situation, but it should work here too.
Just a note, AFAIK the bug discussed here a few weeks ago with wxPython not properly dispatching events to the proper GLCanvas when multiple canvases are active is still unresolved. Be prepared to have to figure out a work-around for that as you move forward in your project.
Ahah... hvaen't observed this yet but good to know.