edubart / sokol_gp

Minimal modern efficient cross platform 2D graphics painter in C
MIT No Attribution
456 stars 24 forks source link

Line thickness? #8

Closed ib00 closed 1 year ago

ib00 commented 2 years ago

Two questions:

  1. Is there a way to specify line thickness?
  2. If yes, are those lines antialiased?
edubart commented 1 year ago
  1. Is there a way to specify line thickness?

There is no cross-platform way to specify line thickness that would work in all backends. This is a limitation for most graphical backends and line thickness is hard fixed to 1 pixel wide (the default thickness for most graphical backends). Some graphical backends do support changing line thickness but I recommend not doing that, because the library automatic batching algorithm will not consider that.

You can still draw thick lines yourself by drawing a rectangle, though the corners wouldn't be round. Or you could make a pixel shader yourself to draw an antialiasing and rounded corner line, though this is not straightforward.

  1. If yes, are those lines antialiased?

Antialiasing is something the graphical backend handles, and again there is no cross platform way to configure it.  You can checkout the underlying graphical backend documentation on how to configure antialiasing for it. Though most graphical backends come with a sane default antialiasing configuration that applies a fair-looking antialiasing for both rectangles and lines.