I want to clip a certain part of the screen, thus everything which lays outside is not drawn. My code looks like this:
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();
}
But this code has no effect, i.e. shapes that lay outside clipBounds are drawn, too. What's wrong with my code?
regards
The rendering doesn't happen until renderer.end()
so put that inside your ScissorStack
.