模糊当前屏幕的副本,然后将其渲染为游戏暂停屏幕中的纹理

时间:2015-03-15 07:13:15

标签: java android opengl-es libgdx gsl

当屏幕暂停时,我在游戏逻辑中调用applyEffect,但图像未设置。取而代之的是我的黑色背景。相反,当我设置高斯模糊着色器时,我希望它显示模糊的纹理,在Blurred screen下面的图像中的形式。

遗憾的是结果是ghost screen appears

为什么屏幕变黑?

以下是我如何调用方法

    if (Gdx.input.isKeyPressed(Keys.P) || pause)
                        {

                            state = State.GAME_PAUSED;
    setBackgroundTexture(applyEffect());

    gameScreenGamePauseMenu.sendInMenu();
                            }


    public TextureRegion applyEffect()
        {

            boolean m_fboEnabled = true;
            FrameBuffer m_fbo = null;
            float m_fboScaler = 1;
            TextureRegion m_fboRegion = null;

            int width = Gdx.graphics.getWidth();
            int height = Gdx.graphics.getHeight();

            if(m_fboEnabled)      // enable or disable the supersampling
            {
                if(m_fbo == null)
                {
                    // m_fboScaler increase or decrease the antialiasing quality

                    m_fbo = new FrameBuffer(Format.RGB565, (int)(width * m_fboScaler), (int)(height * m_fboScaler), false);
                    m_fboRegion = new TextureRegion(m_fbo.getColorBufferTexture());
                    m_fboRegion.flip(false, true);
                }

                m_fbo.begin();
            }


            if(m_fbo != null)
            {
                m_fbo.end();

                getStage().getBatch().begin();
                getStage().getBatch().draw(m_fboRegion, 0, 0, width, height);
                getStage().getBatch().end();
            }
 return m_fboRegion;

        }

我使用Libgdx制作我的游戏

0 个答案:

没有答案