1.10: GUI stretched?

I’ve encountered an issue in version 1.10: when the window’s size is changed, 2D elements seem to stretch with it, rather than retaining their previous aspect ratios. I think that all affected elements are parented beneath “aspect2d”. (I would expect such stretching if they were under “render2d”.)

It looks almost as though “aspect2d”'s scale isn’t being changed to reflect the window’s new aspect ratio. o_0

For reference, I’m changing the window’s size by creating a “WindowProperties” object, setting the appropriate size (along with a few other properties) in that, and then calling “base.win.requestProperties”, passing in the “WindowProperties” object. Like so:

        # "xSize" and "ySize" compose the requested window-size

        wp = WindowProperties()
        wp.setSize(xSize, ySize)
        wp.setFullscreen(self.fullscreenMode)
        wp.setCursorFilename(CURSOR_FILE)
        base.win.requestProperties(wp)

        # More code then follows to handle various other matters that
        #  should be handled in response to the change, such as the
        #  rendered FOV.

it may be worth noting that this happens after another call to “base.win.requestProperties”, in which I set the window to not be in fullscreen; I think that I found that I had trouble setting the resolution while in fullscreen mode. The full process then looks like this:

    def setResolution(self):
        self.updatingResolution = True
        
        wp = WindowProperties()
        wp.setFullscreen(False)
        wp.setCursorFilename(CURSOR_FILE)
        base.win.requestProperties(wp)
        
        taskMgr.doMethodLater(0.1, self.setResolutionInternal, "reset resolution", extraArgs=[])
    
    def setResolutionInternal(self):
        # This simply fetches the desired resolution
        xSize, ySize = OPTION_RESOLUTION_LIST[self.resolutionIndex]
        
        self.setOption(OPTION_GRAPHICS_RESOLUTION, self.resolutionIndex)
        
        # The size-setting code, as before
        wp = WindowProperties()
        wp.setSize(xSize, ySize)
        wp.setFullscreen(self.fullscreenMode)
        wp.setCursorFilename(CURSOR_FILE)
        base.win.requestProperties(wp)

        # Once again, more code follows here...

(This issue didn’t occur in 1.9.4, I believe.)

Make sure you are (1) not intercepting the “window-event” on the ShowBase instance, and (2) not overriding the windowEvent function in a subclass of ShowBase.

If you are doing neither of those, could you add a print statement inside “def windowEvent” in direct/showbase/ShowBase.py in your Panda installation, to see whether it is being triggered properly? If so, you can add further print statements there and adjustWindowAspectRatio to see which part isn’t getting triggered for some reason. If not, please enable “notify-level-display debug” output to see whether the window system is even receiving the size changes.

Ah, I think that I’ve found the problem!

To cover all of your points:

I’m pretty confident that I’m doing neither.

This is what led me to what appears to be the source of the problem:

I did as requested. First of all, as far as I see both methods are being called, and seem to be executing as I’d expect of them. However, one of my print-statements printed 1.0 / aspectRatio (as used to scale “aspect2d”), which printed as 0.75–in a rather wider window (~1280x720). Looking at the code, I saw that “aspectRatio” seemed to be coming from a call to “self.getAspectRatio()”–and it’s here that the problem seems to be.

Taking a diff of the file between this version and 1.9.4, I see that the condition used when calculating the aspect ratio has changed: " and win.getSideBySideStereo()" seems to have been added. (This seems to be at line ~1263.) I presume that this is for stereo rendering; I imagine that since I’m not using stereo rendering, this is returning “False”, and so the aspect ratio isn’t being recalculated. Removing this condition from the if-statement causes the GUI to update as expected again!

Thanks for the detective work! Seems to have been introduced by #204. I’ve just backed out that check in 27fb1a4, thanks!

It’s my pleasure, and thank you for the quick fix! I’ve just tested the new version (I believe; I’m still a little uncertain with GitHub ^^; ), and the GUI appears to be working as expected again! :slight_smile: