diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-05 18:13:39 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-05 18:13:39 +0100 |
| commit | dcda45d8ae46197d304d737c102b13643808203f (patch) | |
| tree | fa8b19907d56a054fcc8f35dd4f1c6ec1a713387 /tools/gen_test_tga.cc | |
| parent | e44c71ffb3b9d25cc8341d25bf3e63d6224dfbe6 (diff) | |
test(assets): Add tests for Texture Asset support
- Added test_image.tga (generated via tools/gen_test_tga.cc).
- Updated test_assets_list.txt to include the TGA.
- Updated test_assets.cc to verify image decompression and pixel values.
Diffstat (limited to 'tools/gen_test_tga.cc')
| -rw-r--r-- | tools/gen_test_tga.cc | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tools/gen_test_tga.cc b/tools/gen_test_tga.cc new file mode 100644 index 0000000..7414eea --- /dev/null +++ b/tools/gen_test_tga.cc @@ -0,0 +1,35 @@ +#include <cstdio> +#include <cstdint> + +int main() { + FILE* f = fopen("assets/final/test_image.tga", "wb"); + if (!f) return 1; + + // TGA Header (Uncompressed True-Color, 2x2, 32-bit) + uint8_t header[18] = { + 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 2, 0, // Width: 2 (LE) + 2, 0, // Height: 2 (LE) + 32, // Depth: 32 bit + 0x28 // Descriptor: Top-Left origin, 8-bit alpha + }; + fwrite(header, 1, 18, f); + + // Pixel Data (BGRA order for TGA usually, but let's see what stbi expects/returns) + // stbi converts to requested format (RGBA). + // Let's write BGRA: + // Pixel 0 (0,0): Red -> 00 00 FF FF + // Pixel 1 (1,0): Green -> 00 FF 00 FF + // Pixel 2 (0,1): Blue -> FF 00 00 FF + // Pixel 3 (1,1): White -> FF FF FF FF + + uint8_t pixels[] = { + 0x00, 0x00, 0xFF, 0xFF, // Red + 0x00, 0xFF, 0x00, 0xFF, // Green + 0xFF, 0x00, 0x00, 0xFF, // Blue + 0xFF, 0xFF, 0xFF, 0xFF // White + }; + fwrite(pixels, 1, sizeof(pixels), f); + fclose(f); + return 0; +} |
