我想剪辑屏幕的某个部分,因此不会绘制位于外部的所有内容。我的代码如下所示:
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外部的形状。我的代码有什么问题?
问候
除非renderer.end()
将其放入您的中,否则渲染不会发生ScissorStack
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句