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.

Minimap example

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.

Thanks in advance!

€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


1 Answer 1


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


    //1. set the function to LESS

    //2. enable depth writing

    //3. Enable depth writing, disable RGBA color writing
    Gdx.gl.glColorMask(false, false, false, false);

    shapeRenderer.setColor(1f, 0f, 0f, 0.5f);
    shapeRenderer.circle(x, y, radius);

That enables my circular clipping area

now I draw some shapes:

Gdx.gl.glColorMask(true, true, true, true);

//4. Make sure testing is enabled.

//5. Now depth discards pixels outside our masked shapes

And finally you need to disable the depth func, so it's only for this specific purpose, which is clipped


I got my informations out of this github project: github

So props to mattdesl!


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .