floooh / sokol

minimal cross-platform standalone C headers
https://floooh.github.io/sokol-html5
zlib License
6.54k stars 469 forks source link

sokol_shape feature: wireframe shapes #773

Open pseregiet opened 1 year ago

pseregiet commented 1 year ago

Would be great if sokol_shape could also generate vertex buffers in such a way that it can be rendered as SG_PRIMITIVETYPE_LINES. Would be really useful for rendering regions, selection boxes, light radius etc.

pmttavara commented 1 year ago

Bumping. If possible, I'd appreciate if maybe sg_pipeline_desc could have a new member, fill_mode, of type sg_fill_mode, that could choose between SG_FILLMODE_FILL and SG_FILLMODE_WIREFRAME. As far as I can tell, D3D11, OpenGL 3, Metal, and WebGPU all support at least filled polygons and line polygons (some of them support points). However, I'm sure there's a valid reason floooh hasn't added support for it. 😢

floooh commented 1 year ago

@pmttavara the main reason why WebGPU doesn't have a fillmode seems to be Vulkan (see https://github.com/gpuweb/gpuweb/issues/137), for sokol_gfx.h the main reason would be GLES and WebGL (you are right that D3D11, desktop GL and Metal have support though).

So at best it would need to be an optional feature which doesn't work on the web and mobile (and that's a pretty big chunk nowadays).

It's unrelated from sokol_shape.h generating geometry that can be rendered as wireframe via line primitives though.

pseregiet commented 1 year ago

Just switching fill mode to lines has also limitations of the thickness of the lines and colors (from my own experiments, changing the line thickness in GL3.3 generates an glError). In my own code I have a line box object that I can scale with a matrix and render boxes around stuff. I could just generate few more, have a sphere and a cilinder and what not but recently I noticed that sokol has a library for generatic such shapes. Just not in the format applicable for rendering lines.