floooh / sokol

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

Expose _sg_pixelformat_bytesize to users? #946

Closed logankaser closed 9 months ago

logankaser commented 10 months ago

_sg_pixelformat_bytesize Would be useful to expose to users. I have a texture manager abstraction that internally creates sg_images. Its API accepts sg_pixel_format(s) from callers, and width and height parameters, and it would be nice to be able to use _sg_pixelformat_bytesize to calculate data size.

floooh commented 10 months ago

I would prefer adding that as a field to sg_pixelformat_info returned by the sg_query_pixelformat call.

Thoughts?

logankaser commented 9 months ago

That seems like a great place to add it!

floooh commented 9 months ago

I'll start looking into this today.

floooh commented 9 months ago

Ok, this is now merged. I also exposed two helper functions to compute the number of bytes in a texture row and surface, which might actually be a bit more useful.

Details are in the changelog https://github.com/floooh/sokol/blob/master/CHANGELOG.md#06-jan-2024, and also in the sokol_gfx.h documentation comments.