From 2c1f0e85737b6cadd7e5b371328c9f2017ea0c7f Mon Sep 17 00:00:00 2001 From: msmith-codes Date: Sun, 21 Dec 2025 15:34:04 -0500 Subject: [PATCH] Removed examples, and generation. --- examples/textures/generate_test_dds.py | 125 ------------------ .../textures/resources/test_rgba_mipmaps.dds | Bin 349652 -> 0 bytes examples/textures/textures_test_dds_mipmaps.c | 66 --------- src/external/rl_gputex.h | 4 +- 4 files changed, 2 insertions(+), 193 deletions(-) delete mode 100644 examples/textures/generate_test_dds.py delete mode 100644 examples/textures/resources/test_rgba_mipmaps.dds delete mode 100644 examples/textures/textures_test_dds_mipmaps.c diff --git a/examples/textures/generate_test_dds.py b/examples/textures/generate_test_dds.py deleted file mode 100644 index 426b3c679..000000000 --- a/examples/textures/generate_test_dds.py +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python3 -"""Generate a test DDS file with mipmaps to verify swizzling fix""" - -import struct -import os - -def write_dword(f, value): - """Write a 32-bit unsigned integer (little-endian)""" - f.write(struct.pack(' 1 or mip_h > 1: - mip_w = max(1, mip_w // 2) - mip_h = max(1, mip_h // 2) - mipmap_count += 1 - - print(f"Generating DDS: {width}x{height} with {mipmap_count} mipmaps") - - with open(filename, 'wb') as f: - # Write DDS magic number - f.write(b'DDS ') - - # Write DDS header (124 bytes) - write_dword(f, 124) # dwSize - write_dword(f, 0x1 | 0x2 | 0x4 | 0x1000 | 0x20000) # dwFlags (CAPS, HEIGHT, WIDTH, PIXELFORMAT, MIPMAPCOUNT) - write_dword(f, height) # dwHeight - write_dword(f, width) # dwWidth - write_dword(f, width * 4) # dwPitchOrLinearSize - write_dword(f, 0) # dwDepth - write_dword(f, mipmap_count) # dwMipMapCount - - # Reserved1[11] - for _ in range(11): - write_dword(f, 0) - - # DDS_PIXELFORMAT (32 bytes) - write_dword(f, 32) # dwSize - write_dword(f, 0x41) # dwFlags (RGBA) - write_dword(f, 0) # dwFourCC - write_dword(f, 32) # dwRGBBitCount - write_dword(f, 0x00FF0000) # dwRBitMask (R at byte 2) - write_dword(f, 0x0000FF00) # dwGBitMask (G at byte 1) - write_dword(f, 0x000000FF) # dwBBitMask (B at byte 0) - write_dword(f, 0xFF000000) # dwABitMask (A at byte 3) - - # dwCaps - write_dword(f, 0x1000 | 0x8 | 0x400000) # TEXTURE | COMPLEX | MIPMAP - write_dword(f, 0) # dwCaps2 - write_dword(f, 0) # dwCaps3 - write_dword(f, 0) # dwCaps4 - write_dword(f, 0) # dwReserved2 - - # Write image data with mipmaps - mip_w, mip_h = width, height - mip_data = generate_bgra_image(width, height) - - for mip in range(mipmap_count): - print(f" Mipmap {mip}: {mip_w}x{mip_h} ({len(mip_data)} bytes)") - f.write(mip_data) - - if mip < mipmap_count - 1: - mip_data = generate_mipmap(mip_data, mip_w, mip_h) - mip_w = max(1, mip_w // 2) - mip_h = max(1, mip_h // 2) - - print(f"✓ Created {filename}") - -if __name__ == "__main__": - # Create resources directory if it doesn't exist - os.makedirs("resources", exist_ok=True) - - # Generate test DDS file - write_dds_file("resources/test_rgba_mipmaps.dds", 256, 256) - - print("\nTest file created!") - print("Left half should be RED, right half should be BLUE") - print("If the fix is working, all mipmap levels will show correct colors") diff --git a/examples/textures/resources/test_rgba_mipmaps.dds b/examples/textures/resources/test_rgba_mipmaps.dds deleted file mode 100644 index 6543189818103583995010c2ecaff819d94a4080..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 349652 zcmeIzQL3#+6@}5G2#zU$$AA6bKYsf+|NhIrede#PpTGa---o~a@VE2N z>#v{BzvS=e8wfrc{4eO)Z|^?-`L_eQJAi-w`RCsrXzl^_yY^4^+&A5S&z=7^f$u%= z&*mQBpMUn7_D}Bo^REQ_+XKx#z<$@h?|;+$?t1?D-#(aIJAr@xnQxijy!q#U`(SSE z0{;1DzGZ&%=AZxVgSoW}_~)Pbmif(_fBv@*=GHFYpMU0C<~MKt`QJX6Tf2aN{+Vx? z-@N(ffBRr=?E?P!XTD{A^X8xb?Sr|s3;5@s`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-+JHQdOv^u*Y~sc)4yNq!2jFN{d@QSx8Ljk{{3Fx@B6=;&%b;A-1mR} E3k63lqW}N^ diff --git a/examples/textures/textures_test_dds_mipmaps.c b/examples/textures/textures_test_dds_mipmaps.c deleted file mode 100644 index 63a00db2e..000000000 --- a/examples/textures/textures_test_dds_mipmaps.c +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************************* -* -* raylib [textures] example - Test DDS loading with mipmaps -* -********************************************************************************************/ - -#include "raylib.h" - -int main(void) -{ - const int screenWidth = 800; - const int screenHeight = 450; - - InitWindow(screenWidth, screenHeight, "raylib [textures] - DDS mipmaps test"); - - // Load DDS texture with mipmaps (create one with a distinct color pattern) - Texture2D texture = LoadTexture("resources/test_rgba_mipmaps.dds"); - - if (texture.id == 0) - { - TraceLog(LOG_ERROR, "Failed to load DDS texture"); - } - else - { - TraceLog(LOG_INFO, "DDS texture loaded: %dx%d, mipmaps: %d", - texture.width, texture.height, texture.mipmaps); - } - - SetTargetFPS(60); - - while (!WindowShouldClose()) - { - BeginDrawing(); - ClearBackground(RAYWHITE); - - // Draw texture at different scales to see mipmap levels - DrawTexturePro(texture, - (Rectangle){0, 0, texture.width, texture.height}, - (Rectangle){50, 50, 256, 256}, - (Vector2){0, 0}, 0.0f, WHITE); - - DrawTexturePro(texture, - (Rectangle){0, 0, texture.width, texture.height}, - (Rectangle){350, 50, 128, 128}, - (Vector2){0, 0}, 0.0f, WHITE); - - DrawTexturePro(texture, - (Rectangle){0, 0, texture.width, texture.height}, - (Rectangle){520, 50, 64, 64}, - (Vector2){0, 0}, 0.0f, WHITE); - - DrawText("256x256", 50, 320, 20, DARKGRAY); - DrawText("128x128", 350, 190, 20, DARKGRAY); - DrawText("64x64", 520, 125, 20, DARKGRAY); - - DrawText("If colors look wrong (blue/red swapped), mipmaps have swizzling bug", - 10, 400, 10, RED); - - EndDrawing(); - } - - UnloadTexture(texture); - CloseWindow(); - - return 0; -} \ No newline at end of file diff --git a/src/external/rl_gputex.h b/src/external/rl_gputex.h index 84ab33eba..78d618db5 100644 --- a/src/external/rl_gputex.h +++ b/src/external/rl_gputex.h @@ -308,7 +308,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_ unsigned char alpha = 0; // NOTE: Data comes as A1R5G5B5, it must be reordered to R5G5B5A1 - for (int i = 0; i < image_pixel_size; i++) + for (int i = 0; i < data_size/sizeof(unsigned short); i++) { alpha = ((unsigned short *)image_data)[i] >> 15; ((unsigned short *)image_data)[i] = ((unsigned short *)image_data)[i] << 1; @@ -328,7 +328,7 @@ void *rl_load_dds_from_memory(const unsigned char *file_data, unsigned int file_ unsigned char alpha = 0; // NOTE: Data comes as A4R4G4B4, it must be reordered R4G4B4A4 - for (int i = 0; i < image_pixel_size; i++) + for (int i = 0; i < data_size/sizeof(unsigned short); i++) { alpha = ((unsigned short *)image_data)[i] >> 12; ((unsigned short *)image_data)[i] = ((unsigned short *)image_data)[i] << 4;