Strange result from getScreenshot() with makeTextureBuffer

i was trying to snap a single image from a texture buffer (without stopping/interrupting the texture bufffer).

in this case i took the teapot-on-tv sample, and executed this code when i hit a key.

fp = self.tvMen[0].find("**/faceplate")
fp.setTexture(self.buf.getScreenshot(),1)

(self.buf = altBuffer = mainWindow.makeTextureBuffer(“hello”, 256, 256) )

as expected, it snaps a picture of and applies it to the tv-man (like i wanted). but instead of the buffer, it takes the visible screen.

i don’t think that’s supposed to happen. and if it is. how can i snap a texture from a texture buffer then?

You must have been given a ParasiteBuffer from mainWindow.makeTextureBuffer(). In general, buffer.getScreenshot() doesn’t work unless you know a priori that you have a true offscreen buffer.

For what you are doing, though, it’s probably better to use buffer.addRenderTexture(tex, buffer.RTMCopyTexture) to copy the frame contents to a Texture at the end of the frame. This works for both ParasiteBuffers and true buffers. You can use buffer.clearRenderTextures() to remove it when you have determined that the texture is ready (though this also removes any other buffers you have set up).

David

Depending on your needs, (ie if you’re willing to wait a frame) there is also the RTMTriggeredCopyRam mode, when you call triggerCopy it will copy the texture to RAM the next frame so that you can then read it out by simply storing the texture in a PNMImage.