LibGDX FrameBufferObject和SpriteBatch分层和透明度问题

时间:2015-08-19 05:41:56

标签: java android libgdx opengl-es-2.0 box2d

我有以下问题:当我将密钥卡渲染到屏幕时,它不会从最后一次清除自己。但是当我添加清晰的屏幕代码时,背景不可见。

没有清算的代码:

public void render(float delta) {

    // Temporary variable
    float zoom = camera.zoom;

    frameBufferObject.begin();
    {
        // Render
        sb.setProjectionMatrix(camera.combined);
        sb.begin();
        groundManager.render(sb);
        sb.end();
    }
    frameBufferObject.end();

    // Clear the screen
    Gdx.gl.glClearColor(0.25f, 0.25f, 0.3f, 1f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    // Render the images
    sb.setProjectionMatrix(camera.combined);
    sb.begin();
    {
        sb.draw(backgroundTexture,
                camera.position.x - camera.viewportWidth * zoom / 2,
                camera.position.y - camera.viewportHeight * zoom / 2,
                camera.viewportWidth * zoom,
                camera.viewportHeight * zoom);

        sb.draw(frameBufferObject.getColorBufferTexture(),
                camera.position.x - camera.viewportWidth * zoom / 2,
                camera.position.y - camera.viewportHeight * zoom / 2,
                camera.viewportWidth * zoom,
                camera.viewportHeight * zoom,
                0, 0, 1, 1);

        // Render the ground
        surfaceFragmentManager.render(sb);
    }
    sb.end();
}

有这个输出: enter image description here

但是当我添加

Gdx.gl.glClearColor(0.25f, 0.25f, 0.3f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

它只是清除屏幕并用纯色绘制背景。

我怎样才能让自己清楚,并让背景可见?

谢谢。

1 个答案:

答案 0 :(得分:0)

痛苦的3个小时之后,答案就像在FBO开头添加以下片段一样简单

Object not found!