I have a question, How to draw primitives? draw lines, rectangles, circles, text, etc...

For now I can draw text and Lines:

SharpDX.Direct3D9.Font SharpDX.Direct3D9.Line

However, those lines look ugly, How can I soften the lines? ,How can I draw circles? To draw rectangles should I do it with lines? How can I draw a thick line?

I attach an image:


  • \$\begingroup\$ Why D3D9? I'd recommend using a more modern API if you can. For example, D3D11 will work with Direct2D, which does handle rendering of those sorts of primitive shapes. \$\endgroup\$
    – Adam
    Apr 9 at 23:44
  • \$\begingroup\$ @Adam I plan to add to my library, auxiliary drawing methods, the typical ones, Circles, rectangles, text, lines, triangles. from dx9 to dx12, opengl and vulkan. I'm starting with dx9, I thought it would be easy, but I couldn't find examples. \$\endgroup\$ Apr 10 at 0:31
  • \$\begingroup\$ You should elaborate on what devices and operating systems you want to target. There are easier ways to get beyond where you are now; e.g. WPF and UWP. Which include their own "community libraries". \$\endgroup\$ Apr 10 at 1:27
  • \$\begingroup\$ If it is an external alternative, for example for an external overlay I would use windowsforms, but my library hooks graphics internally from the games, for example if I want to make an ESP, I must at least be able to draw rectangles. I even thought about drawing shapes with GDI and passing that shape to a png and uploading it later as a texture. That's what I did to be able to draw text in OpenGL. \$\endgroup\$ Apr 10 at 1:58
  • \$\begingroup\$ If its rectangles you want, UWP and WPF are full of rectangles (the "bounding box"). You can "animate" rectangles: move along a path; rotate; skew; resize. That's just the beginnig. "Rectangles" can contain other rectangles ... and images ("textures"). \$\endgroup\$ Apr 10 at 2:40

1 Answer 1


Well, you can now draw primitives, all with lines, and using mathematics.

(I tried to place the code here, but it is bugged, but it shows me everything wrong.)

Here I show how I did it: Source

I guess now I have to do some kind of smoothing, anti-Aliasing or whatever it's called, so that the lines don't look pixelated.



You must log in to answer this question.

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