makeGsg, creating offscreen buffers without a window

I was messing around with making offscreen buffers when I noticed that the GraphicsEngine section and the API ref doesn’t agree anymore. It seems that the makeGsg function has been removed from GraphicsEngine.

I’m trying to create an offscreen buffer that’s not tied to a window but all the methods that I can find in the API reference seem to require some sort of window. Is there still a way to do it? I’m trying to see if I can tie Panda and PyQt together and make a transparent window with 3d content from the offscreen buffer I’m trying to create.

3d transparent windows? Hmm that would takes more magic then i have!

You can create an offscreen buffer with:

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

David

You can also do this automatically for the main window by putting:

window-type offscreen

in your Config.prc.

David

I’m getting an error with ‘window-type offscreen’. Is this a bug with Panda? I’m on ubuntu running Panda 1.5.2 and this is the output with notify-level at debug:

>>> StdErr: :interrogatedb(debug): Creating interrogate database
:interrogatedb(debug): Got interrogate data for module libexpress
StdErr: :interrogatedb(debug): Got interrogate data for module libdownloader
StdErr: :interrogatedb(debug): Got interrogate data for module libpnmtext
StdErr: :interrogatedb(debug): Got interrogate data for module libvrpn
:interrogatedb(debug): Got interrogate data for module libnativenet
:interrogatedb(debug): Got interrogate data for module libnet
:interrogatedb(debug): Got interrogate data for module libpgui
:interrogatedb(debug): Got interrogate data for module libaudio
:interrogatedb(debug): Got interrogate data for module libputil
:interrogatedb(debug): Got interrogate data for module liblerp
:interrogatedb(debug): Got interrogate data for module libtform
:interrogatedb(debug): Got interrogate data for module libtext
:interrogatedb(debug): Got interrogate data for module libpnmimage
:pnmimage:png(debug): PNG version 10215
:pnmimage:tiff(debug): LIBTIFF, Version 3.8.2
Copyright (c) 1988-1996 Sam Leffler
Copyright (c) 1991-1996 Silicon Graphics, Inc.
:interrogatedb(debug): Got interrogate data for module libparametrics
:interrogatedb(debug): Got interrogate data for module libmathutil
:interrogatedb(debug): Got interrogate data for module liblinmath
:interrogatedb(debug): Got interrogate data for module libgsgbase
:interrogatedb(debug): Got interrogate data for module libgobj
:interrogatedb(debug): Got interrogate data for module libevent
:interrogatedb(debug): Got interrogate data for module libpipeline
:interrogatedb(debug): Got interrogate data for module libdisplay
:interrogatedb(debug): Got interrogate data for module libdgraph
:interrogatedb(debug): Got interrogate data for module libdevice
:interrogatedb(debug): Got interrogate data for module libcollide
:interrogatedb(debug): Got interrogate data for module libchar
:interrogatedb(debug): Got interrogate data for module libpstatclient
:interrogatedb(debug): Got interrogate data for module libchan
:interrogatedb(debug): Got interrogate data for module libgrutil
:interrogatedb(debug): Got interrogate data for module libmovies
:interrogatedb(debug): Got interrogate data for module libpgraph
:interrogatedb(debug): Got interrogate data for module librecorder
StdErr: :interrogatedb(debug): Got interrogate data for module libparticlesystem
:interrogatedb(debug): Got interrogate data for module libphysics
StdErr: :interrogatedb(debug): Got interrogate data for module libeffects
:interrogatedb(debug): Got interrogate data for module libdistort
:interrogatedb(debug): Got interrogate data for module libdistributed
:interrogatedb(debug): Got interrogate data for module libinterval
:interrogatedb(debug): Got interrogate data for module libdeadrec
:interrogatedb(debug): Got interrogate data for module libshowbase
:interrogatedb(debug): Got interrogate data for module libdcparser
StdErr: :interrogatedb(debug): Got interrogate data for module libskel
StdErr: :interrogatedb(debug): Got interrogate data for module libegg
StdErr: :interrogatedb(debug): Got interrogate data for module libegg2pg
DirectStart: Starting the game.
StdErr: :pgraph(debug): Constructing 0x86b6fbc, hidden
:pgraph(debug): Constructing 0x8712594, render
:pgraph(debug): Constructing 0x871282c, render2d
:pgraph(debug): Constructing 0x8712d8c, aspect2d
:pgraph(debug): Constructing 0x871314c, a2dBackground
:pgraph(debug): Constructing 0x8713234, a2dTopCenter
:pgraph(debug): Constructing 0x871331c, a2dBottomCenter
:pgraph(debug): Constructing 0x8713444, a2dLeftCenter
:pgraph(debug): Constructing 0x871356c, a2dRightCenter
:pgraph(debug): Constructing 0x87136c4, a2dTopLeft
:pgraph(debug): Constructing 0x87137dc, a2dTopRight
:pgraph(debug): Constructing 0x8713904, a2dBottomLeft
:pgraph(debug): Constructing 0x8713a2c, a2dBottomRight
:pgraph(debug): Constructing 0x8713cfc, dataRoot
:pgraph(debug): Constructing 0x8713e14, dataUnused
:pgraph(debug): Constructing 0x871409c, render2dp
:pgraph(debug): Constructing 0x871427c, aspect2dp
:pgraph(debug): Constructing 0x87143b4, a2dpTopCenter
:pgraph(debug): Constructing 0x871449c, a2dpBottomCenter
:pgraph(debug): Constructing 0x87145a4, a2dpLeftCenter
:pgraph(debug): Constructing 0x87146c4, a2dpRightCenter
:pgraph(debug): Constructing 0x87147ec, a2dpTopLeft
:pgraph(debug): Constructing 0x8714944, a2dpTopRight
:pgraph(debug): Constructing 0x8714a5c, a2dpBottomLeft
:pgraph(debug): Constructing 0x8714b84, a2dpBottomRight
:display: loading display module: libpandagl.so
Warning: DirectNotify: category 'Interval' already exists
StdErr: Known pipe types:
  glxGraphicsPipe
(all display modules loaded.)
:05-24-2008 19:06:53 ShowBase(warning): Unable to open 'offscreen' window.
>>>

I’ve also tried it out on windows with 1.4.2 and it dies when it tries to create the window with DirectX.

I think I’m going to have to use window-type none and just create the offscreen buffer myself but it would be a whole lot easier if window-type none just worked since I won’t be messing about with reparenting models to the other buffer.

Hmm, it might be a bug in Panda. It doesn’t seem to be working for me either.

David

I would like to know how to make just an offscreen buffer, because the following code fails:

**
selection = GraphicsPipeSelection.getGlobalPtr()
self.pipe = selection.makeDefaultPipe()
self.graphicsEngine = GraphicsEngine()
fbp = FrameBufferProperties()
fbp.setRgbColor(1)
fbp.setColorBits(24)
fbp.setAlphaBits(8)
fbp.setDepthBits(1)
wp = WindowProperties()
wp.setSize(800, 600)
flags = GraphicsPipe.BFRefuseWindow
self.buffer = self.graphicsEngine.makeOutput(self.pipe, ‘offscreen’, 0, fbp, wp, flags)
assert self.buffer
**
The assert fails, but if I set:
flags = GraphicsPipe.BFRequireWindow

then it works. Can anyone help me??

The offscreen buffer code in Panda3D has recently become a little less stable. On some graphics cards and platforms, it doesn’t appear to be possible to create only an offscreen buffer without a window. Which OS are you using, and which graphics card? In what way does the buffer creation attempt fail, precisely?

You can try experimenting with the buffer requirements–the depth bits, alpha bits, and so on. If you’re on Windows, you can also try experimenting with pandadx8 or pandadx9. Or, if visual quality is not important to you, you can use tinydisplay, which certainly does work offscreen.

David

I’m using Ubuntu 10.04, ATI Radeon HD 3400, Panda3d 1.7.

It fails by returning a None to self.buffer (the line before the assert).

Also, I can set up offscreen buffers (ie. makeOutput() with the optional Gsg and Win arguments) but Gsg and Win must be associated with an onscreen window.

Thanks a lot for the quick reply, and any help you can give!

Hey, I’m trying to set up an offscreen window just like above, and it fails – self.buffer receives a None from:

self.graphicsEngine.makeOutput(self.pipe, 'offscreen', 0, fbp, wp, flags) 

I’m using Ubuntu 11.10, Nvidia NVS 4200m with latest drivers, Panda 1.8.

Thanks

Offscreen buffers require pbuffers, they don’t work with FBOs. There must be something wrong with the code that creates them.

Can you show the framebuffer properties and flags you’re using to open the buffer?

The code fails on two different systems:

  1. Ubuntu 11.10, NVIDIA GeForece 7600GT, Panda 1.8
  2. Ubuntu 11.04, NVIDIA Quadro NVS 290, Panda 1.8
import pdb
from pandac.PandaModules import GraphicsEngine, GraphicsPipe, GraphicsPipeSelection, WindowProperties, FrameBufferProperties

selection = GraphicsPipeSelection.getGlobalPtr()
pipe = selection.makeDefaultPipe()
graphicsEngine = GraphicsEngine.getGlobalPtr()
print '\n', pipe, '\n', graphicsEngine, '\n'

fbp = FrameBufferProperties()
fbp.setRgbColor(1) 
fbp.setColorBits(24)
fbp.setAlphaBits(8) 
fbp.setDepthBits(1)
wp = WindowProperties.size(256, 256)
flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRefuseWindow
#flags = GraphicsPipe.BFFbPropsOptional | GraphicsPipe.BFRequireWindow
print fbp, '\n', wp, '\n', flags, '\n'

win = graphicsEngine.makeOutput(pipe, 'offscreen_win', 0, fbp, wp, flags)

assert win is not None, "Failed to create window."
print "Success"
pdb.set_trace()

The assert fails, and the print output is:

<libpanda.GraphicsPipe object at 0x9fdd308> 
<libpanda.GraphicsEngine object at 0x9fddea8> 

depth_bits=1 color_bits=24 alpha_bits=8  
size=(256, 256)  
2052 

When I uncomment the second “flags” line to set it to “GraphicsPipe.BFRequireWindow”, the window is successfully created.

One more bit, I just dug up this thread:
[Why these codes couldn't create a hiden window)
But, rdb fixed it, which I verified in the source - so I’m still puzzled…

I’m just bumping this thread.

rdb, I can track it down but if you could point me to where to start that’d help because I’m not very familiar with the C side of the api.

I’m hitting this bug on Ubuntu 11.10 using 1.8.0 and also latest CVS.

Here’s my test script:

from panda3d.core import loadPrcFileData
loadPrcFileData("", "window-type offscreen")
import direct.directbase.DirectStart
run()

I did a debug build and stepping through the code in gdb, glxGraphicsPipe::make_output is successfully returning a glxGraphicsBuffer, but glxGraphicsBuffer::open_buffer is not creating the pbuffer due to an incorrect check. Patch attached.

RCS file: /cvsroot/panda3d/panda/src/glxdisplay/glxGraphicsBuffer.cxx,v
retrieving revision 1.31
diff -u -r1.31 glxGraphicsBuffer.cxx
--- panda/src/glxdisplay/glxGraphicsBuffer.cxx	4 Oct 2011 18:05:10 -0000	1.31
+++ panda/src/glxdisplay/glxGraphicsBuffer.cxx	25 Apr 2012 15:50:58 -0000
@@ -187,7 +187,7 @@
     }
   }
   
-  if (glxgsg->_fbconfig == None || glxgsg->_context_has_pbuffer) {
+  if (glxgsg->_fbconfig == None || !glxgsg->_context_has_pbuffer) {
     // If we didn't use an fbconfig to create the GSG, or it doesn't
     // support buffers, we can't create a PBuffer.
     return false;

Great work, many thanks! I’ve committed your fix. And sorry that hadn’t gotten around to looking into it myself yet.