LibGame
v0.4.0
The LG Game Engine - Copyright (C) 2024 ETMSoftware
|
Functions | |
void * | lg_load_dds (const char *path, lg_tc_format *tc_format, size_t *size, int *w, int *h, int *n_mipmaps) |
=== Loading of DDS (DXT1 and DXT3) compressed textures on Linux and Win32 ===
void* lg_load_dds | ( | const char * | path, |
lg_tc_format * | tc_format, | ||
size_t * | size, | ||
int * | w, | ||
int * | h, | ||
int * | n_mipmaps | ||
) |
Load a DDS (DXT1 and DXT3 formats) compressed texture
Returned data must be freed afterwards
Linux: S3TC (DDS files with DXT1/3 compression format) -> GL_EXT_texture_compression_s3tc DXT1: 8:1 compression ratio 4x4 pixels block -> 64 bits = 8 bytes DXT3: 4:1 compression ratio 4x4 pixels block -> 128 bits = 16 bytes (https://learn.microsoft.com/en-us/windows/win32/direct3ddds/dx-graphics-dds-pguide#dds-file-layout) DDS = DirectDrawSurface === DDS layout === uint32_t dds_magic; // -> 'DDS ' (0x20534444) DDS_Header header; void *data; void *data2; (No DDS_Header_dxt10 header10) sizeof(magic) + sizeof(DDS_Header) = 128 See: lg_dds_loader.h To create DDS DXT1/DXT3 files using nvidia tex tools: - without mipmpas nvcompress -bc1 -noalpha -nomips -production wallpaper1_1024x512.png wallpaper1_1024x512_dxt1.dds - without mipmpas nvcompress -bc2 -nomips -production wallpaper1_1024x512.png wallpaper1_1024x512_dxt3.dds - with mipmpas nvcompress -bc2 -production wallpaper1_1024x512.png wallpaper1_1024x512_w_mips_dxt3.dds (https://developer.nvidia.com/gpu-accelerated-texture-compression)
path | |
tc_format | Pointer to lg_tc_format which will store compressed texture format |
size | Pointer to size_t which will store compressed texture size (cumulative size, ie of all levels, but excluding magic and header) |
w | Pointer to int which will store width (of level 0) |
h | Pointer to int which will store height (of level 0) |
n_mipmaps | Pointer to int which will store number of generated mipmaps |