Aspect Ratio of openWindow()

Hi,

For the main window, panda automatically adjust the display region and aspect ratio of a window that changes size. Now I tried to open a new window with

base.openWindow(props=winProps, keepCamera=True, requireWindow=True)

and when i changes the window size of the new window, the aspect ratio does change, and when i changes the main window, the aspect ratio of the new window follows the main window. Is there a solution for the two windows both listen to respective window size changes?

ok. so i have found a solution -

set keepCamera to false and makeCamera to True in open window.
copy the code from showBase for adjusting the window aspect ratio to new window.

self.win = base.openWindow(props=wp, keepCamera=False, makeCamera=True, requireWindow=True)

self.cam = base.camList[1]
self.cam.node().setLens(self.lens)
self.cam.reparentTo(render)

def windowEvent(self, win): # for adjusting aspect ratio of lens in patient window
   if win != self.win:
        return  # not about our window
   aspect = base.getAspectRatio(win)
   self.lens.setAspectRatio(aspect)
   self.cam.node().setLens(self.lens)

self.accept('window-event', self.windowEvent)

Yes, you need a new camera to do this, essentially, because a camera lens can have only one aspect ratio. If you share the samecamera between windows with different sizes, it can’t have two aspect ratios at once.