multiple windows under wx -----> openGl Problem

Dear Forum,

after some experiments (multiple windows under wx) turns into -----> openGl Problem.

http://picturepush.com/public/13136750

Only the first camera is redered correctly. under Directx9 Panda crashes while resizing

# OPenGl Problem only one cam rendered correctly


import wx

from math import pi, sin, cos
from direct.showbase.ShowBase import ShowBase

from direct.task import Task

from direct.wxwidgets.WxPandaWindow import WxPandaWindow

from pandac.PandaModules import VBase4
from pandac.PandaModules import NodePath
from pandac.PandaModules import Camera

import panda3d.core as core

core.loadPrcFileData('startup', 'window-type none')

class Frame(wx.Frame):
    def __init__(self, *args, **kwargs):
        wx.Frame.__init__(self, *args, **kwargs)
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        
        
        #self.split1 = wx.SplitterWindow(self)        
        #sizer.Add(self.split1,1,flag=wx.EXPAND)
        
        #self.split2 = wx.SplitterWindow(self.split1)           
        
        #self.p0 = wx.Panel(self.split1)
        #self.p1 = wx.Panel(self.split2)       
        #self.p2 = wx.Panel(self.split2)
        
        self.p0 = wx.Panel(self)
        self.p1 = wx.Panel(self)       
        self.p2 = wx.Panel(self)        

        #self.split2.SetMinimumPaneSize(10)
        #self.split2.SplitHorizontally(self.p1,self.p2,400) 
        #self.split1.SetMinimumPaneSize(10)
        #self.split1.SplitVertically(self.p0,self.split2,250)  

        #self.split1.SetPosition((0,0))
        #self.split1.SetSize((800,600))
        #self.split2.SetSashPosition(300)
        sizer.Add(self.p0,1,flag=wx.EXPAND)
        sizer.Add(self.p1,1,flag=wx.EXPAND)
        sizer.Add(self.p2,1,flag=wx.EXPAND)
        
        self.SetSizer(sizer)
        self.Fit()
        
        
   
    def onQuit(self, evt):
        self.Close()  


class App(ShowBase):
    def __init__(self):
        ShowBase.__init__(self, fStartDirect=False, windowType=None)              
        self.startWx()
        self.frame = Frame(None, wx.ID_ANY, 'Editor', size=(800, 600))

        self.wxApp.Bind(wx.EVT_CLOSE, self.quit)
        self.wxApp.Bind(wx.EVT_SIZE , self.OnResize)
        
        env = self.loader.loadModel("models/environment")
        env.reparentTo(render)
        env.setScale(0.025, 0.025, 0.025)
        env.setPos(-8, 42, 0)
        
        base.disableMouse()
        
        wp0 = core.WindowProperties()
        wp0.setOrigin(0,0)
        wp0.setSize(self.frame.p0.GetSize().width,self.frame.p0.GetSize().height)
        wp0.setParentWindow(self.frame.p0.GetHandle())
        self.win0 = base.openWindow(type = 'onscreen', props=wp0,makeCamera = False)
        self.cam0 = base.makeCamera(self.win0, camName = 'cam0')
        print"win0"
        print self.win0
        print self.win0.getPipe()        
        self.dr = self.win0.makeDisplayRegion()
        self.dr.setClearColor(VBase4(1, 0, 0, 1))
        self.dr.setClearColorActive(True)
        self.dr.setClearDepthActive(True)        
        #camNode = Camera('cam')
        camNP = NodePath(self.cam0)
        self.dr.setCamera(camNP)
        self.cam0.reparentTo(base.camera)
        
        wp1 = core.WindowProperties()
        wp1.setOrigin(0,0)
        wp1.setSize(self.frame.p1.GetSize().width,self.frame.p1.GetSize().height)
        wp1.setParentWindow(self.frame.p1.GetHandle())
        self.win1 = base.openWindow(type = 'onscreen', props=wp1,makeCamera = False)
        self.cam1 = base.makeCamera(self.win1, camName = 'cam1')
        print"win1"
        print self.win1
        print self.win1.getPipe() 
        self.dr1 = self.win1.makeDisplayRegion()
        self.dr1.setClearColor(VBase4(0, 1, 0, 1))
        self.dr1.setClearColorActive(True)
        self.dr1.setClearDepthActive(True)         
        #camNode1 = Camera('cam1')
        camNP1 = NodePath(self.cam1)
        self.dr1.setCamera(camNP1)
        self.cam0.reparentTo(base.camera)
        #self.cam1.reparentTo(render)
        #self.cam1.setPos(0,0,100)
        #self.cam1.lookAt(0,0,0)        

        
        
        wp2 = core.WindowProperties()
        wp2.setOrigin(0,0)
        wp2.setSize(self.frame.p2.GetSize().width,self.frame.p2.GetSize().height)
        wp2.setParentWindow(self.frame.p2.GetHandle())
        self.win2 = base.openWindow(type = 'onscreen', props=wp2,makeCamera = False)
        print"win2"
        print self.win2
        print self.win2.getPipe()  
        self.cam2 = base.makeCamera(self.win2, camName = 'cam2')
        self.dr2 = self.win2.makeDisplayRegion()
        self.dr2.setClearColor(VBase4(0, 0, 1, 1))
        self.dr2.setClearColorActive(True)
        self.dr2.setClearDepthActive(True)        
        #camNode2 = Camera('cam2')
        camNP2 = NodePath(self.cam2)
        self.dr2.setCamera(camNP2)
        self.cam2.reparentTo(base.camera)
        
        print self.winList
        print self.camList
        

        self.frame.Show()
       
        # setup mouse/picking/selection system

        def foo():
            print "debug"
        self.accept("mouse1", foo)
        self.accept("mouse3", foo)
        self.accept("t", foo)
               
        
    def OnResize(self, event):
        pass
        wp = core.WindowProperties()
        wp.setOrigin(0,0)
        wp.setSize(self.frame.p0.GetSize().width,self.frame.p0.GetSize().height)
        wp.setParentWindow(self.frame.p0.GetHandle())
        self.win0.requestProperties(wp)
        
        wp1 = core.WindowProperties()
        wp1.setOrigin(0,0)
        wp1.setSize(self.frame.p1.GetSize().width,self.frame.p1.GetSize().height)
        wp1.setParentWindow(self.frame.p1.GetHandle())
        self.win1.requestProperties(wp1)
        
        wp2= core.WindowProperties()
        wp2.setOrigin(0,0)
        wp2.setSize(self.frame.p2.GetSize().width,self.frame.p2.GetSize().height)
        wp2.setParentWindow(self.frame.p2.GetHandle())
        self.win2.requestProperties(wp2)        
        

    def quit(self, event=None):
        self.onDestroy(event)
        try:
            base
        except NameError:
            sys.exit()
        base.userExit()

app = App()
app.run()

any ideas?

Martin

Hi,

There are some fiddly issues with interacting with wx and multiple windows. Previous version of Panda (including, possibly, the 1.8.x branch) haven’t always dealt with this correctly; but I’m pretty sure the top of the trunk does it well–I do this a lot in my day-to-day work lately. Are you running with a branch, or are you using the buildbot development release?

But more importantly, you seem to be making explicit calls to base.openWindow(), instead of just using the WxPandaWindow class that you imported. That’s not correct. Why not simply add WxPandaWindow to your frame as any other Panda widget? That’s the way the class is meant to be used, and it’s got the code to handle most of these fiddly issues.

David