False window size property

Hello all,

Problem:
After changing the main window size, the window properties do not report the correct size.

Platform: Windows XP, Panda3D 1.7.1.

Try the following:

import atexit
import sys

from direct.showbase.ShowBase import ShowBase
from panda3d.core import WindowProperties

class World(ShowBase):
 
    def __init__(self, width, height, isFullscreen, title):
        
        ShowBase.__init__(self)

        win_props = WindowProperties(self.win.getProperties())
        win_props.setTitle(title)
        win_props.setSize(width, height)
        win_props.setFullscreen(isFullscreen)
        self.win.requestProperties(win_props)
        rp = self.win.getRejectedProperties()
        p  = self.win.getProperties()
        
        print 'Rejected properties: {0}'.format(rp)
        print 'Properties: size({0},{1})'.format(p.getXSize(), p.getYSize())

        self.taskMgr.add(self.myTask, 'test')

        atexit.register(self.exitfunc)
        self.accept('escape', sys.exit)

    def myTask(self, task):
        print 'Aspect2d left margin: {0}, aspect ratio:{1}, size: {2}'\
        .format(self.a2dLeft,
                self.getAspectRatio(),
                self.getSize())

if __name__ == "__main__":
    
 
    app = World(width=1680, height=1050, isFullscreen=True, title='Maze')

    app.run()

Output:

Rejected properties: !undecorated !fixed_size 
Properties: size(800,600)
Aspect2d left margin: -1.33333333333, aspect ratio:1.33333333333, size: (800, 600)

You will probably see that even if the window has been resized to 1680x1050, panda reports it as 800x600. Hence the aspect ratio is also wrong.

Am I missing something?

Thank you,

UB

requestProperties() doesn’t take effect immediately. Call base.openWindows() after calling requestProperties() if you want to wait for it to finish updating the window before you query the new properties.

Note that if you want to open the window that way initially, it’s better to set the desired properties in the Config.prc settings, instead of changing the already-open window.

David

Thank you David.

Changing part of the top post’s code to:

...
        self.win.requestProperties(win_props)
        self.graphicsEngine.openWindows()

works as you mentioned.