Introduce TEX_LEN macro for texture arrays lengths (#2541)

This commit is contained in:
Dragorn421
2025-05-25 18:33:24 +02:00
committed by GitHub
parent b44ff69ded
commit eeeaa77d3f
2 changed files with 28 additions and 4 deletions
+14
View File
@@ -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