【问题标题】:LibGDX scissors does not work [duplicate]LibGDX剪刀不起作用[重复]
【发布时间】:2014-07-21 05:44:25
【问题描述】:

我想剪辑屏幕的某个部分,因此外面的所有内容都不会被绘制。 我的代码如下所示:

public void draw(Camera camera, ShapeRenderer renderer){
        Rectangle scissors = new Rectangle();
        Rectangle clipBounds = new Rectangle(pos.x, pos.y, pos.x+width, pos.y+height);
        ScissorStack.calculateScissors(camera, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), new Matrix4(), clipBounds, scissors);
        renderer.begin(ShapeType.Filled);
        ScissorStack.pushScissors(scissors);
        for(Block[] row : blocks){
            for(Block block : row)
                block.draw(renderer);// draw some rects
        }
        ScissorStack.popScissors();

        renderer.end();
    }

但是这段代码没有任何作用,也就是说,位于 clipBounds 之外的形状也会被绘制出来。 我的代码有什么问题?

问候

【问题讨论】:

    标签: java libgdx 2d clipping


    【解决方案1】:

    直到renderer.end() 才会进行渲染,因此请将其放在您的ScissorStack 中。

    【讨论】:

      猜你喜欢
      • 2015-06-03
      • 2014-11-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-01-31
      相关资源
      最近更新 更多