我只是想绘制背景,用0.5f透明黑色覆盖它以使其变暗并在暂停菜单上呈现。
我试过了:
Gdx.gl.glClearColor(0f, 0f, 0f, 0.5f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
并没有任何效果。我也无法在网上找到任何解决方案。我的另一个选择是覆盖黑色精灵,但我不想这样做。无论如何用GL来画它?
答案 0 :(得分:2)
好吧,我会画一个透明的矩形
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(new Color(0, 0, 0, 0.5f));
shapeRenderer.rect(0, 0, screenWidth, screenHeight);
shapeRenderer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
希望这有帮助
答案 1 :(得分:1)
您唯一的解决方案是覆盖黑色精灵。是最有效率和最有效的。
根据文件:
Alpha function, blend function, logical operation, stenciling,
texture mapping, and depth-buffering are ignored by glClear.
glClear takes a single argument that is the bitwise OR of several
values indicating which buffer is to be cleared.
The values are as follows:
GL_COLOR_BUFFER_BIT
Indicates the buffers currently enabled for color writing.
运行glClear后,“under”下面没有更多颜色