Libgdx战争迷雾(纹理混合),Framebuffer bug

时间:2016-05-14 16:41:57

标签: java opengl opengl-es libgdx blending

我试图在战略游戏中获得一场简单的战争迷雾。

我现在在framebuffer绘图上失败了。 我是一个绝对的openGL初学者。

新问题1;

构造器:

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

    this.fbo = new FrameBuffer(Pixmap.Format.RGB565, width, height, false);
    this.fboRegion = new TextureRegion(fbo.getColorBufferTexture(), 0, 0, 1000, 1000); // 1000,1000 = Test mapsize

    fboRegion.flip(false, true);

    Units.camera.setCam(new OrthographicCamera(fbo.getWidth(), fbo.getHeight()));
    OrthographicCamera cam = Units.camera.getCam();
    cam.position.set(fbo.getWidth() / 2, fbo.getWidth() / 2, 0);
    cam.update();

渲染部分:

public void draw(float delta)
{
    Gdx.gl.glClearColor(0, 0, 0, 1.0f);
    Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

    Units.camera().update();

    fbo.begin();
        Gdx.gl.glClearColor(0.1f, 0.1f, 0.1f, 1f);
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);

        batch.setProjectionMatrix(Units.camera().getCam().combined);

        batch.begin();

            background.draw(batch);
            this.unitDraw.draw(batch, delta);
            this.shotDraw.draw(batch, delta);

        batch.end();
    fbo.end();


    batch.begin();
        batch.draw(fboRegion, 0, 0);
    batch.end();
}

问题: 相机移动错了。帧缓冲区和纹理区域移动速度不同。 我的对象在纹理区域上具有低分辨率,因为它的缩放。但我需要缩放我的对象图片。如何在不将图像缩放到原始尺寸的情在framebuffer中写入之前缩放批量?或者这是相机问题?

请参阅: https://www.youtube.com/watch?v=sMGe1Sgh5JA&feature=youtu.be

此帖子中的最后一篇帖子(http://badlogicgames.com/forum/viewtopic.php?f=11&t=4207)存在同样的问题。

0 个答案:

没有答案
相关问题