# Libgdx shaperender within a circle as limitter

I encountered a problem, where my small entities would be rendered out of the bounds of my radar.

At the time I solved it like this: ensure, that the object would be within the circle, but, that's not optimal, because I need variable scale for different entitie sizes, which causes further problems to be solved.

So is there a way, that I can do the following:

draw all items within the circle and ensure that nothing is drawn outside

I thought about something, like a circle canvas, which draws all, but displays only that, which is in the bounds.

The points and lines within the circle are of a variable width / height. I'd prefer to draw everything, and cut the other stuff off.

€dit: Gosh forgot an important thing: I draw the items with a shaperenderer, and all things are rect's , and it probably wont be polygons

I did it! Yay, I'm so proud! :P

Ofc I didn't stopped to google, and I found my answer in a depth buffer.

What I'm currently doing is the following stuff

    Gdx.gl.glClearDepthf(1f);
Gdx.gl.glClear(GL20.GL_DEPTH_BUFFER_BIT);

//1. set the function to LESS
Gdx.gl.glDepthFunc(GL20.GL_LESS);

//2. enable depth writing
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);

//3. Enable depth writing, disable RGBA color writing

shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
shapeRenderer.setColor(1f, 0f, 0f, 0.5f);
shapeRenderer.end();


That enables my circular clipping area

now I draw some shapes:

shaperenderer.begin();

//4. Make sure testing is enabled.
Gdx.gl.glEnable(GL20.GL_DEPTH_TEST);


  Gdx.gl.glDepthFunc(GL20.GL_ALWAYS);