mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 09:23:03 -04:00
add base.adjustWindowAspectRatio()
This commit is contained in:
parent
2e3667e7d4
commit
17f27744a9
@ -2626,8 +2626,23 @@ class ShowBase(DirectObject.DirectObject):
|
||||
|
||||
# If we have not forced the aspect ratio, let's see if it has
|
||||
# changed and update the camera lenses and aspect2d parameters
|
||||
self.adjustWindowAspectRatio(self.getAspectRatio())
|
||||
|
||||
# Temporary hasattr for old Pandas
|
||||
if not hasattr(win, 'getSbsLeftXSize'):
|
||||
self.pixel2d.setScale(2.0 / win.getXSize(), 1.0, 2.0 / win.getYSize())
|
||||
self.pixel2dp.setScale(2.0 / win.getXSize(), 1.0, 2.0 / win.getYSize())
|
||||
else:
|
||||
self.pixel2d.setScale(2.0 / win.getSbsLeftXSize(), 1.0, 2.0 / win.getSbsLeftYSize())
|
||||
self.pixel2dp.setScale(2.0 / win.getSbsLeftXSize(), 1.0, 2.0 / win.getSbsLeftYSize())
|
||||
|
||||
def adjustWindowAspectRatio(self, aspectRatio):
|
||||
""" This function is normally called internally by
|
||||
windowEvent(), but it may also be called to explicitly adjust
|
||||
the aspect ratio of the render/render2d DisplayRegion, by a
|
||||
class that has redefined these. """
|
||||
|
||||
if not self.__configAspectRatio:
|
||||
aspectRatio = self.getAspectRatio()
|
||||
if aspectRatio != self.__oldAspectRatio:
|
||||
self.__oldAspectRatio = aspectRatio
|
||||
# Fix up some anything that depends on the aspectRatio
|
||||
@ -2660,7 +2675,6 @@ class ShowBase(DirectObject.DirectObject):
|
||||
self.a2dpLeft = -aspectRatio
|
||||
self.a2dpRight = aspectRatio
|
||||
|
||||
|
||||
# Reposition the aspect2d marker nodes
|
||||
self.a2dTopCenter.setPos(0, 0, self.a2dTop)
|
||||
self.a2dBottomCenter.setPos(0, 0, self.a2dBottom)
|
||||
@ -2694,14 +2708,6 @@ class ShowBase(DirectObject.DirectObject):
|
||||
# If anybody needs to update their GUI, put a callback on this event
|
||||
messenger.send("aspectRatioChanged")
|
||||
|
||||
# Temporary hasattr for old Pandas
|
||||
if not hasattr(win, 'getSbsLeftXSize'):
|
||||
self.pixel2d.setScale(2.0 / win.getXSize(), 1.0, 2.0 / win.getYSize())
|
||||
self.pixel2dp.setScale(2.0 / win.getXSize(), 1.0, 2.0 / win.getYSize())
|
||||
else:
|
||||
self.pixel2d.setScale(2.0 / win.getSbsLeftXSize(), 1.0, 2.0 / win.getSbsLeftYSize())
|
||||
self.pixel2dp.setScale(2.0 / win.getSbsLeftXSize(), 1.0, 2.0 / win.getSbsLeftYSize())
|
||||
|
||||
def userExit(self):
|
||||
# The user has requested we exit the program. Deal with this.
|
||||
if self.exitFunc:
|
||||
|
Loading…
x
Reference in New Issue
Block a user