diff options
| author | Dragorn421 <Dragorn421@users.noreply.github.com> | 2025-05-25 18:33:24 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-05-25 12:33:24 -0400 |
| commit | eeeaa77d3fb1d5c428ab2ace8f88f415192c6060 (patch) | |
| tree | 3f7d06cabd0c95b452829b1c4f50ac299de83437 /include | |
| parent | b44ff69ded55eeda1f17a6d3989bc350a10d4543 (diff) | |
Introduce TEX_LEN macro for texture arrays lengths (#2541)
Diffstat (limited to 'include')
| -rw-r--r-- | include/tex_len.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/include/tex_len.h b/include/tex_len.h new file mode 100644 index 000000000..f6e54a82d --- /dev/null +++ b/include/tex_len.h @@ -0,0 +1,14 @@ +#ifndef TEX_LEN_H +#define TEX_LEN_H + +/** + * Compute a length for an array holding a texture. + * `type` is the array's element type. + * `width`, `height` are the texture dimensions. + * `bpp` is the texture's pixel size, in bits per pixels. + * The calculation computes the size of the texture in bits `width * height * bpp`, + * then divides by 8 to get the size in bytes, then divides by the element type size. + */ +#define TEX_LEN(type, width, height, bpp) ((width) * (height) * (bpp) / 8 / sizeof(type)) + +#endif |
