starting panda invisibly

I would like to be able to start panda without seeing a black render window like it typically does until it is loaded. My original idea was to quickly load a single card as a loading screen and then call base.graphicsEngine.renderFrame() a couple times to make it visible before I begin the long load. However there would still be a brief black while loading the card. To help this, I tell panda to not create a window before calling DirectStart, then after loading the card, I call base.openMainWindow. However, there is still a brief flash of black between that call and the renderFrame call. Here’s where we are so far:

from pandac.PandaModules import *
ConfigVariableString("window-type","none").setStringValue("none")
import direct.directbase.DirectStart

# load card here

base.openMainWindow(type='onscreen')
base.graphicsEngine.renderFrame()
base.graphicsEngine.renderFrame()

# rest of loading

Now I am trying to eliminate even that brief flash. I tried creating a WindowProperties and calling props.setOpen(False) and passing those props to base.openMainWindow, but for some reason it still opens the window and doesn’t hide it until I call renderFrame on the next line. Is this a bug? This doesn’t seem like the right behavior. What is worse, is later when I request the properties with setOpen(True), it doesn’t appear until I call renderFrame again, but then when it do the window appear but is black and no longer renders anymore. What is the right way to use setOpen? the documentation does say “It is legal to create a GraphicsWindow in the closed state, and later request it to open by changing this flag.” Am I just doing something wrong? Code:

from pandac.PandaModules import *
ConfigVariableString("window-type","none").setStringValue("none")
import direct.directbase.DirectStart

# load card here

props = WindowProperties.getDefault()
props.setOpen(False)
base.openMainWindow(props=props,type='onscreen')
base.graphicsEngine.renderFrame()

props.setOpen(True)
base.win.requestProperties(props)
base.graphicsEngine.renderFrame()
base.graphicsEngine.renderFrame()

# rest of loading

I actually have a bit more complex solution to this, but the main thing is, how do use setOpen without it breaking rendering?

Hmm, the documentation may be in error there. That was probably true at one point in the distant past, but we have moved away from allowing that feature.

But, even if it did work as advertised, I’m not sure that you could avoid that flash of black. Windows requires you to create a window before you can create an OpenGL context. Windows doesn’t specify whether the window needs to be actually visible yet or not, but some graphics drivers do seem to require that.

It follows that the window must exist and be visible before the first frame is rendered.

I guess the only way to put something non-black in the window initially is to use the standard 2-D GDI. This is probably what other games do when they are opening their splash screen. This would, of course, require adding a new feature to support this sort of thing in the WindowProperties.

David

A possible suggestion (it’s been a while since I’ve done Windows programming), what about displaying a splash screen first, creating a small Panda3D window behind the splash (not worrying about what it looks like), then hiding the splash and resizing the window once the display is set? This way no special window properties are needed for the Panda3D window.

What I actually ended up doing was make the window 1x1 pixel, undecorated, and position at -50,-50. I tried make it show up under a 2d gui (wxWidgets) splash screen, but even setting setZOrder(WindowProperties.ZBottom) still makes it flash in front of the splash screen for a second. The real reason I’m so paranoid is because I have this persistant splash screen (so that the windows desktop is never visible) displayed by a non-panda launcher application that runs panda games and I want as smooth a transition as possible between that screen and the same image display in panda that panda then fades out into the actual game and fades back at the end.

What I really need then (what I’m guessing you were hinting at) is something like the setParentWindow function that I hear is coming the next version so that I can display panda in the same window the launcher uses.

Although, ideally I wouldn’t have a launcher program running subprocesses of panda, I’d have a panda launcher that loads classes that represent games and a way to completely clear and reset the scene graph and other panda managers and things between games. I’ll probably be making a forum post about that at a later date since this isn’t the first project I’ve wanted something like separate panda contexts for (although it is the first time I’ve actually tried to do it and failed).