sokol_shape: A proposal
I saw that you're working on a shapes utility for simple functional meshes and I have a proposal which changes the library a lot, so if you end up being interested, it would be better to reflect it before the release.
Flexible vertex format.
I don't mean the retro DirectX FVF, but a way to allow more vertex customization and optional fields.
Instead of relying on a fixed vertex structure sshape_vertex_t, why not create a more flexible struct:
struct sshape_vertex_desc {
void* position_buf;
size_t position_stride;
void* normal_buf;
size_t normal_stride;
// ... etc
}If a pointer is not null, sokol_shape fills it with data. If it is null, it's left it alone. There can be "easy mode" utility functions which create a description for sshape_vertex_t.
This allows the following features
- The user can decide which attributes they want
- Different attributes can potentially go in different vertex buffers
- There can be multiple attributes for the same thing from which the user can choose (for example allow both
uint icolorandvec4 fcolor) - This is future proof. For example it can be reused in a hypothetical future library sokol_mesh_load, which loads obj, or gltf or fbx, which can potentially not hold some attributes. Also adding new attributes to the library (say tangents and bitangents) will be much easier
... which brings be to the second part of the poposal: I don't know if you've already planned this, but I really think tangent and bitangent generation is very important. I suppose a lot of use-cases for sokol are small graphics demos and normal space is probably very important for most of them.
Thanks for the awesome work!
Source: floooh/sokol