diff --git a/radiant/image.cpp b/radiant/image.cpp index 491cd8c9..f50a6a8e 100644 --- a/radiant/image.cpp +++ b/radiant/image.cpp @@ -50,7 +50,19 @@ Image* QERApp_LoadImage( void* environment, const char* name ){ StringOutputStream fullname( 256 ); fullname << m_name << '.' << name; ArchiveFile* file = GlobalFileSystem().openFile( fullname.c_str() ); + + // also look for .dds image in dds/ prefix like Doom3 or DarkPlaces + if ( file == 0 && !string_compare( name, "dds" ) ) + { + fullname.clear(); + fullname << name << '/' << m_name << '.' << name; + file = GlobalFileSystem().openFile( fullname.c_str() ); + } + if ( file != 0 ) { + // tell user which image file is found for the given texture path + globalOutputStream() << "Found image file: " << makeQuoted( fullname.c_str() ) << "\n"; + m_image = table.loadImage( *file ); file->release(); } diff --git a/radiant/texwindow.cpp b/radiant/texwindow.cpp index 9d08664d..95af3cb5 100644 --- a/radiant/texwindow.cpp +++ b/radiant/texwindow.cpp @@ -674,6 +674,14 @@ class TextureCategoryLoadShader }; void TextureDirectory_loadTexture( const char* directory, const char* texture ){ + // Doom3-like dds/ prefix (used by DarkPlaces). + // When we list dds/textures/ folder, + // store the texture names without dds/ prefix. + if ( !strncmp( "dds/", directory, 4 ) ) + { + directory = &directory[ 4 ]; + } + const auto name = StringOutputStream( 256 )( directory, PathExtensionless( texture ) ); if ( texture_name_ignore( name.c_str() ) ) { @@ -712,6 +720,9 @@ void TextureBrowser_ShowDirectory( const char* directory ){ globalOutputStream() << "Loading " << makeQuoted( directory ) << " wad file.\n"; LoadShaderVisitor visitor; archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "textures/" ); + + // Doom3-like dds/ prefix (used by DarkPlaces). + archive->forEachFile( Archive::VisitorFunc( visitor, Archive::eFiles, 0 ), "dds/textures/" ); } else{ globalErrorStream() << "Attempted to load " << makeQuoted( directory ) << " wad file.\n"; @@ -732,6 +743,12 @@ void TextureBrowser_ShowDirectory( const char* directory ){ dirstring << "textures/" << directory; Radiant_getImageModules().foreachModule( LoadTexturesByTypeVisitor( dirstring.c_str() ) ); + + // Doom3-like dds/ prefix (used by DarkPlaces). + dirstring.clear(); + dirstring << "dds/textures/" << directory; + + Radiant_getImageModules().foreachModule( LoadTexturesByTypeVisitor( dirstring.c_str() ) ); } } diff --git a/tools/quake3/q3map2/image.cpp b/tools/quake3/q3map2/image.cpp index a21388f3..6ba0fafe 100644 --- a/tools/quake3/q3map2/image.cpp +++ b/tools/quake3/q3map2/image.cpp @@ -305,20 +305,13 @@ const image_t *ImageLoad( const char *name ){ else if( path_set_extension( filename, ".dds" ); buffer = vfsLoadFile( filename ) ) { LoadDDSBuffer( buffer.data(), buffer.size(), &pixels, &width, &height ); - /* debug code */ - #if 0 - { - ddsPF_t pf; - DDSGetInfo( (ddsBuffer_t*) buffer, nullptr, nullptr, &pf ); - Sys_Printf( "pf = %d\n", pf ); - if ( width > 0 ) { - path_set_extension( filename, "_converted.tga" ); - WriteTGA( "C:\\games\\quake3\\baseq3\\textures\\rad\\dds_converted.tga", pixels, width, height ); - } - } - #endif } - else if( path_set_extension( filename, ".ktx" ); buffer = vfsLoadFile( filename ) ) + else if( sprintf( filename, "dds/%s.dds", name ); buffer = vfsLoadFile( filename ) ) + { + /* also look for .dds image in dds/ prefix like Doom3 or DarkPlaces */ + LoadDDSBuffer( buffer.data(), buffer.size(), &pixels, &width, &height ); + } + else if( sprintf( filename, "%s.ktx", name ); buffer = vfsLoadFile( filename ) ) { LoadKTXBufferFirstImage( buffer.data(), buffer.size(), &pixels, &width, &height ); } @@ -330,6 +323,9 @@ const image_t *ImageLoad( const char *name ){ return nullptr; } + /* tell user which image file is found for the given texture path */ + Sys_FPrintf( SYS_VRB, "Loaded image: \"%s\"\n", name ); + /* everybody's in the place, create new image */ image_t& image = *images.emplace_after( images.cbegin(), name, filename, width, height, pixels );