Libgdx uses ScreenUtils asynchronously and does not stop the game loop

I want to capture the screen. Libgdx provides some of the functions defined in the ScreenUtils class.

For example final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);

My problem is that it takes about 1-3 seconds to get this information. During this time, the game cycle is blocked, and the user will define it as a delay.

Inside the ScreenUtils class, ScreenUtils used. If I run the ScreenUtils.getFrameBufferPixmap method in the stream, there is no delay, but it captures the screen using the wrong method, which is logical, since the game loop starts and changes the material.

Is it possible to copy a GL context or save it and generate a Pixmap at a later point with Thread? Of course, the copy / save operation should be done instantly, otherwise I can do nothing.

I use ShapeRenderer to display my stuff on the screen.

+7
java android multithreading libgdx
source share
2 answers

After a little research, I found a faster alternative to glReadPixels - Pixel Buffer Object , which is available with Android 4.3 - https://vec.io/posts/faster-alternatives-to-glreadpixels-and-glteximage2d-in-opengl-es

Unable to call glReadPixels on a different thread than rendering a stream - stack overflow

+2
source share

I found a solution that works in my case, as I only have minor graphics / shapes. Basically, I copy all the objects that are drawn into the view, as described here. In the background thread, I generate a bitmap programmatically and use the information stored in my objects to draw into a bitmap.

+1
source share

All Articles