GraphicsStateGuardian?!!

I recently updated my Panda3D engine, and some of my old code isn’t working right.

It seems to be that GraphicsEngine.makeGsg was taken out, and a quick read-over of ShowBase shows that makeOutput now only optionally requires a GSG, so one isn’t made in ShowBase.

So, to adapt my old script, I either need a way to make a GraphicsStateGuardian, or a way to call GraphicsEngine.makeBuffer without using a GSG. Anybody have ideas on how to do this?

Any help appreciated!

Do you already have another window open? You can get the GSG from that, e.g. base.win.getGsg(). If you don’t have another GSG already, use the lower-level makeOutput() call, to which, as you have observed, the GSG is an optional parameter (and you can just omit that parameter):

fbprops = FrameBufferProperties.getDefault()
flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRefuseWindow
buf = self.graphicsEngine.makeOutput(pipe, name, 0, fbprops, props, flags)

David

Perfect! So both GraphicsWindows and GraphicsBuffer’s can be made using GraphicsEngine.makeOutput, just by using the BFRefuseWindow flag. Great! :smiley:

Sadly, I can’t create an offscreen surface without an existing gsg:

props = WindowProperties.getDefault()
fbprops = FrameBufferProperties.getDefault()
flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRefuseWindow
win = base.graphicsEngine.makeOutput(base.pipe, 'temp', 0, fbprops, props, flags)
assert(win!=None)

The app I’m writing doesn’t need an onscreen window, but does need to make an offscreen buffer to render to. I can work around this by creating a temporary on-screen window, grabbing the gsg and then destroying the window. This causes a window to flash on the screen. Which is tolerable, but I’d rather do without it if at all possible. Any ideas on how to get makeOutput to work or on how to create a hidden onscreen window would be greatly appreciated.

Thanks in advance.

When you say, “Sadly, I can’t create an offscreen surface without an existing gsg,” do you mean that make_output is returning NULL? That seems like a bug.

Yes, but if I give make_output a working gsg it’s fine. I’ve tried this on xp with Panda 1.4.1 and with vista using 1.4.2. I’ve tried the directx pipes too, but didn’t have any luck.

I’m working around it by temporarily creating a tiny on screen window, which isn’t so bad at all…

If your temporary window is 1x1 pixel undecorated window, it wouldn’t be noticable.

from pandac.PandaModules import *
loadPrcFileData('','''
win-size 1 1
undecorated 1
''')
import direct.directbase.DirectStart

props = WindowProperties.getDefault()
fbprops = FrameBufferProperties.getDefault()
flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRefuseWindow
win = base.graphicsEngine.makeOutput(base.pipe, 'temp', 0, fbprops, props, flags, gsg=base.win.getGsg())
base.closeWindow(base.win)
print win

That works great, thx!