# How to Draw 2D Shapes in DirectX

I am currently trying to draw a simple 2D circle and an arc in DirectX but there are no resources online with info on how I can do this. Lines & Points are built into DirectX anyway so that has never been a problem.

Can somebody explain how I can do this? I'm not talking about a sphere or any other 3D geometry. Just a simple 2D Circle and Arc.

• Can you draw 3d stuff? – Bálint Oct 8 '16 at 9:52
• @Bálint Yeah, Cubes with Textures, Diffuse & Specular reflections etc. Haven't moved on to other types of geometry yet because I'm trying to implement SSAO and other rendering techniques at the moment. But I don't imagine 2D being hard at all. – Arjan Singh Oct 8 '16 at 16:31
• Then drawing circles is just drawing a lot of triangles – Bálint Oct 8 '16 at 19:19

You need to approximate these shapes with triangles. Assembling a circle from triangles can be done like the following pseudo-code:

list<Vector2> vertices;
for (float i = 0; i <= 100; i += 1.0f)
{
float t = PI * 2 * i / 100;
}


Then you can draw these vertices with a triangle fan primitive topology.

You could draw a quad and use a pixel shader to fill the circle/arc.