Window resizing

What am I doing wrong? The window maintains it default size and does not change to the specified size:

import math
import time
from panda3d.core import loadPrcFileData 
loadPrcFileData("", "win-size 1000 800")

from direct.gui.DirectGui import *
from direct.showbase.ShowBase import ShowBase
from panda3d.core import *
from ImprovedTrackball import ImprovedTrackball

...

Hmm, does your code import DirectStart? If so, make sure that any loadPrcFileData line comes before the DirectStart import.

Otherwise, it’s hard to tell what the issue might be without seeing more code.

Sorry, I was incorrect. It does not resize the window when packed into a .p3d.

Regarding DirectStart, I am a bit confused. I am subclassing ShowBase: I thought it was equivalent, isn’t it?

import math
import time
from panda3d.core import *
loadPrcFileData("", "win-size 1000 800")

from direct.gui.DirectGui import *
from direct.showbase.ShowBase import ShowBase


class  Sfc(ShowBase):

	def __init__(self):
		ShowBase.__init__(self)

		m = loader.loadModel("teapot.bam")
		m.setColor( 0, 0, 1, 1 )
		m.reparentTo(render)
		m.setPos( 0, 10, 0 )

sfc = Sfc()
sfc.run()

Yes, it should be. Youŕe doing everything correctly. I’m not entirely sure why the window size is ignored, but you could try this:

class Sfc(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        wp = WindowProperties()
        wp.setSize(1000, 800)
        self.win.requestProperties(wp)

Yes, this worked! Thanks a lot! I’ll use this method.

Because I was doing some trials with version 1.8 and 1.9 with the method I was using above (that is using loadPrcFileData), I will just complete this post with what I found out, just in case… The method I was using does not change the size of the window (when the program is packed as .p3d and run using panda3d), but I noticed the following:

  1. the configuration parameter gets modified: this is the output from cvMgr.listVariables()
win-size int
  current value = 1000 800  (from )
  default value = 640 480
  1. I tested with the 1.8 runtime, and a self produced 1.9 runtime distribution. I had the same problem in both, but they both gave some (different) errors at the beginning. Here they are for completeness.

1.8 runtime - It gives some errors because it cannot find the r600_dri.so library. However, apart from this issue everything works fine.

:downloader: [0x16e8190] begin GET [ http://runtime.panda3d.org/morepy/cmu_1.8/linux_amd64/morepy.cmu_1.8.linux_amd64.xml ]
:downloader: [0x16e8190] begin GET [ http://runtime.panda3d.org/morepy/cmu_1.8/linux_amd64/morepy.cmu_1.8.linux_amd64.mf.1.pz ]
Installing Python standard library rev 1
Install complete.
:PackageInfo: Package morepy uses 17 MB
:AppRunner: Total Panda3D disk space used: 196 MB
:AppRunner: Configured max usage is: 2048 MB
:display: loading display module: libpandagl.so
:display: loading display module: libp3tinydisplay.so
Known pipe types:
  glxGraphicsPipe
  TinyXGraphicsPipe
  TinyOffscreenGraphicsPipe
(all display modules loaded.)
:ShowBase: Default graphics pipe is glxGraphicsPipe (OpenGL).
libGL error: dlopen /usr/lib/x86_64-linux-gnu/dri/r600_dri.so failed (/home/parisia/.panda3d/hosts/runtime.panda3d.org_0f5faf88846080ae/panda3d/cmu_1.8/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/x86_64-linux-gnu/dri/r600_dri.so))
libGL error: dlopen ${ORIGIN}/dri/r600_dri.so failed (${ORIGIN}/dri/r600_dri.so: cannot open shared object file: No such file or directory)
libGL error: dlopen /usr/lib/dri/r600_dri.so failed (/usr/lib/dri/r600_dri.so: cannot open shared object file: No such file or directory)
libGL error: unable to load driver: r600_dri.so
libGL error: driver pointer missing
libGL error: failed to load driver: r600
libGL error: dlopen /usr/lib/x86_64-linux-gnu/dri/swrast_dri.so failed (/home/parisia/.panda3d/hosts/runtime.panda3d.org_0f5faf88846080ae/panda3d/cmu_1.8/libstdc++.so.6: version `GLIBCXX_3.4.15' not found (required by /usr/lib/x86_64-linux-gnu/libLLVM-3.4.so.1))
libGL error: dlopen ${ORIGIN}/dri/swrast_dri.so failed (${ORIGIN}/dri/swrast_dri.so: cannot open shared object file: No such file or directory)
libGL error: dlopen /usr/lib/dri/swrast_dri.so failed (/usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory)
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
:display: Created output of type glxGraphicsWindow
:display: Unable to set window properties: !undecorated !fixed_size 
:ShowBase: Successfully opened window of type glxGraphicsWindow (OpenGL)
:audio: NullAudioManager
:audio: NullAudioManager
:ShowBase: __dev__ == False
:loader: Reading /home/parisia/.panda3d/start/teapot.bam
:ShowBase: User closed main window.
:ShowBase: Exiting ShowBase.
:TaskManager: TaskManager.destroy()

self-produced 1.9 runtime - It complained that it could not find libpanda.so.1.9. Once again everything works fine (there is in fact a libpanda.so library and I guess it uses that). I expect there should be no reason why it shouldn’t have worked.

:AppRunner: Total Panda3D disk space used: 111 MB
:AppRunner: Configured max usage is: 2048 MB
:display: loading display module: libpandagl.so
:display: loading display module: libp3tinydisplay.so
:display(warning): Unable to load: libpanda.so.1.9: cannot open shared object file: No such file or directory
Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:ShowBase: Default graphics pipe is glxGraphicsPipe (OpenGL).
:display: Created output of type glxGraphicsWindow
:display: Unable to set window properties: !undecorated !fixed_size 
:ShowBase: Successfully opened window of type glxGraphicsWindow (OpenGL)
:audio: NullAudioManager
:audio: NullAudioManager
:ShowBase: __dev__ == False
:loader: Reading /home/panda_user/.panda3d/start/teapot.bam
:ShowBase: User closed main window.
:ShowBase: Exiting ShowBase.
:TaskManager: TaskManager.destroy()
:AppRunner: Normal exit.
:TaskManager: TaskManager.destroy()

Hmm, the errors are a bit troubling, but glad it works nonetheless.

I think the reason why loadPrcFileData doesn’t work is that in the runtime enviromnent, the window is already open by the time the Python file is invoked. The configuration variables controlling window size are only read when the window opens for the first time.

Ok, I see. Thanks a lot for the clarifications.

Just to add some info. I realized I have the library where it should be:
/usr/lib/x86_64-linux-gnu/dri/r600_dri.so

It looks as if there is an incompatible version. However everything seems to work fine (if I understood correctly that’s a mesa library). I don’t know what to think, but it seems to work anyway…

Note when using WindowProperties, the window settings are not going to be changed right away - they are going to be changed the next frame. Also, if you are not using loadPrcFileData, then the program window (if changed right away when it runs) will start the first frame with the default Panda window, then change to your settings the next frame.

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

class World(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        wp = WindowProperties()
        wp.setSize(1000, 800)
        wp.setTitle("Test Program")
        base.win.requestProperties(wp)

app = World()
app.run()

If you try out this code, you will notice it is the default window, and then changes itself to a 1000x800 res window titled “Test Program”. If you look closely, you can see the default window and then it changing. This is why I recommend you use loadPrcFileData for the default settings, and then WindowProperties if you’re changing settings while the program is running. If loadPrcFileData does not work when packed into a .p3d program, then try changing settings in your config.pc file, which I believe is also packed into the program. So, if so, it should read the different settings in the file that you have changed, and set them to that. I hope this helps.

Thanks, yes indeed there is a flickering at start. For the moment is fine, but I will use a configuration file at some point.