@@ -531,8 +531,8 @@ void R_ImageList_f( void ) {
531531 sizeSuffix = "Gb" ;
532532 }
533533
534- // ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName);
535- ri .Printf (PRINT_ALL , "%4i: %4ix%4i %s %4i%s %s %f %f\n" , i , image -> uploadWidth , image -> uploadHeight , format , displaySize , sizeSuffix , image -> imgName , image -> loadTime , image -> procTime );
534+ ri .Printf (PRINT_ALL , "%4i: %4ix%4i %s %4i%s %s\n" , i , image -> uploadWidth , image -> uploadHeight , format , displaySize , sizeSuffix , image -> imgName );
535+ // ri.Printf(PRINT_ALL, "%4i: %4ix%4i %s %4i%s %s %f %f\n", i, image->uploadWidth, image->uploadHeight, format, displaySize, sizeSuffix, image->imgName, image->loadTime, image->procTime);
536536
537537 estTotalSize += estSize ;
538538 estTotalTimeLoaded += image -> loadTime + image -> procTime ;
@@ -2131,6 +2131,10 @@ Finds or loads the given image.
21312131Returns NULL if it fails, not a default image.
21322132==============
21332133*/
2134+ #ifdef BROKEN_DDS
2135+ // DDS/DXT
2136+ image_t * R_LoadDDSImage (const char * name , int bits , filterType_t filterType , wrapType_t wrapType );
2137+ #endif
21342138image_t * R_FindImageFile ( const char * name , imgType_t type , imgFlags_t flags )
21352139{
21362140 image_t * image ;
@@ -2140,7 +2144,9 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
21402144 long hash ;
21412145 float oldtime ;
21422146 float loadtime ;
2143-
2147+ #ifdef BROKEN_DDS
2148+ char ddsName [1024 ];
2149+ #endif
21442150 if (!name ) {
21452151 return NULL ;
21462152 }
@@ -2162,6 +2168,31 @@ image_t *R_FindImageFile( const char *name, imgType_t type, imgFlags_t flags )
21622168 return image ;
21632169 }
21642170 }
2171+ #ifdef BROKEN_DDS
2172+ // leilei - DDS - do it here, so we can have a hardware compressed texture instead. The normal means of texture loading expects pixels to be returned which we won't do.
2173+ if (textureCompressionSupport && r_loadDDS -> integer )
2174+ {
2175+ int bits ; // no bits
2176+ int whatclamp ;
2177+ Q_strncpyz (ddsName , name , sizeof (ddsName ));
2178+ COM_StripExtension (ddsName , ddsName , sizeof (ddsName ));
2179+ Q_strcat (ddsName , sizeof (ddsName ), ".dds" );
2180+
2181+ // if (glWrapClampMode == GL_CLAMP_TO_EDGE)
2182+ // whatclamp = WT_CLAMP;
2183+ // else
2184+ // whatclamp = WT_REPEAT;
2185+ // try to load a customized .dds texture
2186+
2187+ image = R_LoadDDSImage (ddsName , bits , 0 , whatclamp );
2188+ if (image != NULL )
2189+ {
2190+ // ri.Printf(PRINT_ALL, "found custom .dds '%s'\n", ddsName);
2191+ return image ;
2192+ }
2193+ }
2194+
2195+ #endif
21652196
21662197 // leilei - Detail texture hack
21672198 // to kill artifacts of shimmer of pattern of terrible
@@ -2953,3 +2984,44 @@ void R_SkinList_f( void ) {
29532984 ri .Printf (PRINT_ALL , "------------------\n" );
29542985}
29552986
2987+ #ifdef BROKEN_DDS
2988+ // leilei - for DDS loading, which relies on this function...
2989+ /*
2990+ ================
2991+ R_AllocImage
2992+ ================
2993+ */
2994+ image_t * R_AllocImage (const char * name , qboolean linkIntoHashTable )
2995+ {
2996+ image_t * image ;
2997+ long hash ;
2998+ char buffer [1024 ];
2999+
3000+ // if(strlen(name) >= MAX_QPATH)
3001+ if (strlen (name ) >= 1024 )
3002+ {
3003+ ri .Error (ERR_DROP , "R_AllocImage: \"%s\" image name is too long\n" , name );
3004+ return NULL ;
3005+ }
3006+
3007+ image = ri .Hunk_Alloc (sizeof (image_t ), h_low );
3008+ Com_Memset (image , 0 , sizeof (image_t ));
3009+
3010+
3011+ qglGenTextures (1 , & image -> texnum );
3012+
3013+ //Com_AddToGrowList(&tr.images, image);
3014+
3015+ Q_strncpyz (image -> imgName , name , sizeof (image -> imgName ));
3016+
3017+ if (linkIntoHashTable )
3018+ {
3019+ Q_strncpyz (buffer , name , sizeof (buffer ));
3020+ hash = generateHashValue (buffer );
3021+ image -> next = hashTable [hash ];
3022+ hashTable [hash ] = image ;
3023+ }
3024+
3025+ return image ;
3026+ }
3027+ #endif
0 commit comments