【发布时间】:2017-02-09 18:52:15
【问题描述】:
我正在尝试将前景纹理蒙版到 LibGDX 中的背景纹理上。在屏幕上绘制时效果很好,但在 FBO 中绘制时背景消失了。
以下是蒙版的绘制方式:
batch.draw(background, x, y);
batch.flush();
Gdx.gl.glColorMask(false, false, false, true);
batch.setBlendFunction(GL20.GL_ONE, GL20.GL_ZERO);
batch.draw(mask, x, y);
batch.flush();
Gdx.gl.glColorMask(true, true, true, true);
batch.setBlendFunction(GL20.GL_DST_ALPHA, GL20.GL_ONE_MINUS_DST_ALPHA);
batch.draw(foreground, x, y);
batch.flush();
batch.setBlendFunction(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
这是我绘制普通版和 FBO 版的方式:
常规
batch.begin();
batch.enableBlending();
batch.setProjectionMatrix(camera.combined);
drawFull(32, 600 - (64 * 4) - 32);
batch.end();
FBO
// draw the FB mask
fb.begin();
batch.begin();
batch.setProjectionMatrix(fbcamera.combined);
batch.enableBlending();
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
drawFull(0, 0);
batch.end();
fb.end();
// draw the FB mask to the main batch
batch.begin();
batch.enableBlending();
batch.setProjectionMatrix(camera.combined);
batch.draw(fb.getColorBufferTexture(), 32, 600 - (64 * 7) - 32);
batch.end();
【问题讨论】: