I want to capture the screen. Libgdx provides some functions defined in the ScreenUtils class.
For instance final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);
My problem is that it takes about 1-3 seconds to get that information. During that time the game loop is blocked and the user will define it as a lag.
Internally the ScreenUtils
class, uses Gdx.gl.glReadPixels
. If I run the ScreenUtils.getFrameBufferPixmap
method in a thread, there is no lag, but it captures the screen at the wrong method, which is logical since the game loop runs and changes stuff.
Is it somehow possible to copy the GL context or save it and generate the Pixmap at a later point of time with the help of a Thread? Of course the copy/save operation should be done instantly, otherwise I don't spare anything.
I use ShapeRenderer
to render my stuff onto the screen.