Libgdx Saving Textures To Avoid Context Loss
Solution 1:
The PixmapIO
class is supposed to help with writing a run-time generated pixmap out. Its not quite what you're looking for with an FBO texture, though. (Its easy to go from Pixmap
to Texture
, but not so easy to go the other way.) If the primitives you use to generate the data in your FBO are available on Pixmap
(e.g., the basic geometric primitives), that may be an alternative. I believe this is the closest libGDX comes to a supported mechanism for saving a run-time texture, but I'm not positive.
There is some libGDX code around for scraping bytes off the framebuffer (the texture data of an FBO all lives on your GPU, so you need to jump through some hoops to copy it into normal memory). See ScreenUtils
and the links here about screenshots and PNGs.
It should be easy to adapt the PixmapIO
to write out a "CIM" formatted file using the byte[]
returned from on of the ScreenUtils
methods.
Alternatively, you could track the list of "operations" that were done to the FBO, so you can just replay them (reconstructing the content later). It depends a lot on what's going into your texture, though ...
Post a Comment for "Libgdx Saving Textures To Avoid Context Loss"