It would currently be useful to me to create a Python Object containing the visual output of Panda. I wondered if there was a way either of tweaking Panda , or using a Panda class to recuperate the rendered image into a sort of array, or any python Object.
When you render to an image it gets rendered to a texture on the GPU normally it does not send this texture back to CPU (its slow) but you can force it. After you got it on the CPU you can use the PnmImage class to do any thing you want, read and write pixels if you like!
Hmm. I just see base.win.getTexture() returns None.
treeform, those are unnecessary complicated. From Panda 1.5.0, thereās the amazing FilterManager class.
Hereās how to use it:
from direct.filter.FilterManager import FilterManager
fm = FilterManager(base.win, base.cam)
yourTexture = Texture()
fm.renderSceneInto(colortex = yourTexture)
#now do with yourTexture whatever you want.
Thats only part of the code,
at self.tex.store(self.image), I get the following error:
Iād like to know if anybody has an idea of how either to bypass this error or do something so it doesnāt happen(which can be quite the same thing).
Or is there an other solution than using textures and PNMImages?\
Hmm. For some reason, Panda3D tries to access the mipmap levels but canāt since they are not loaded into RAM.
Iām just fishing here, but does calling self.tex.setupTexture() or self.tex.prepare() do any good?
Otherwise you can try with different functions like makeRamImage.
The FilterManager class creates offscreen buffers with RTMBindOrCopy, which is the normal, fast way to create offscreen buffers. It means that the texture image is not available in system RAM, however.
You will have to create offscreen buffers with RTMCopyRam if you want the texture image to be accessible to system RAM. This is the slow way to render to texture (itās slow because copying to system RAM is an expensive operation).
Youāre probably best off not using the FilterManager class, but rather by creating an offscreen buffer yourself, using something like: