I came across a rather strange screenshot behavior of my desktop application in LibGDX. I redid a small program to reproduce this "error", which displays only a black background and a red rectangle. These images are the result of:

The left side is a screenshot from the screen clipping tool, this is what looks like starting a program. To the right of the screenshot code, I placed a little further. To clarify, I want the screenshot of the program to get the result of the left image, without transparency, getting all weird.
This is my visualization code, ignoring the coordinates. Since I can see that the rectangle renders perfectly, it makes no sense for me to have the error in the rendering method. But I still post it.
@Override public void render() { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); Gdx.gl.glActiveTexture(GL20.GL_TEXTURE0); Gdx.gl.glEnable(GL20.GL_BLEND); Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); shape.begin(ShapeType.Filled); shape.setColor(Color.BLACK); shape.rect(0, 0, 300, 300); shape.setColor(1f, 0f, 0f, 0.5f); shape.rect(100, 100, 100, 100); shape.end(); Gdx.gl.glDisable(GL20.GL_BLEND); }
This is the code for the screenshot:
public static void screenshot() { Pixmap pixmap = getScreenshot(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); PixmapIO.writePNG(new FileHandle(Gdx.files.getLocalStoragePath() + "screenshots/test.png"), pixmap); pixmap.dispose(); } private static Pixmap getScreenshot(int x, int y, int w, int h) { final Pixmap pixmap = ScreenUtils.getFrameBufferPixmap(x, y, w, h);
I went and researched, I found this topic , which is exactly the same problem. However, it has a little less information and answer. I hope one of you can answer this secret.