I have a texture buffer and I would like to get the content of that buffer into a PNMImage from time to time (not every frame!).
getScreenshot() gives me a part of the main window, even if I set “prefer-parasite-buffer 0”.
After a search on the forum I bumped into “extractTextureData” but I’m afraid I don’t know how to use it
Nothing gets written to disk. I had this problem some time ago what I wanted to remove alpha from a texture buffer (done that with a shader in the end), but this time I really need the image back - I want to use it to regenerate a geomipmap terrain and save the image to disk.
As for it not being rendered yet - I use the texture from this buffer like this:
Have you tried setting to_ram to True in the buffer constructor? If you don’t do this, the texture is still shown in the buffer viewer, but you cannot use it because it’s not available in system RAM memory.
to_ram is not what you want as you indicated that you don’t want to transfer the data every frame, but only once in a while.
The fact that you see something in the buffer viewer or with projectTexture indicates that the data is there when the buffer viewer or the projected texture is rendered, not at the time when you move it to the PNMImage. Try calling base.graphicsEngine.renderFrame() twice or something like that.
You could also look at the source code of base.screenshot. I believe that it uses getScreenshot methods on GraphicsOutput that can get your data in PNMImage right away without having to mess with any of this.