1010
1111#include " csg.h"
1212#include " compatibility_mode.h"
13+ #include " imagelib.h"
1314#include < string>
1415#include < cstring>
1516#include < unordered_map>
@@ -130,10 +131,10 @@ bool TEX_CheckMiptex( const char *name )
130131 return true ;
131132 }
132133
133- // maybe it's tga path ?
134- Q_snprintf ( texname, sizeof ( texname ), " textures/%s.tga " , name );
134+ // maybe it has non-quake format and lies in textures folder ?
135+ Q_snprintf ( texname, sizeof ( texname ), " textures/%s" , name );
135136
136- if ( FS_FileExists ( texname, false ) )
137+ if ( COM_LoadImage ( texname, false , FS_LoadFile) )
137138 return true ;
138139
139140 return false ;
@@ -142,6 +143,7 @@ bool TEX_CheckMiptex( const char *name )
142143bool TEX_LoadMiptex ( const char *name, mipentry_t *tex )
143144{
144145 char texname[64 ];
146+ rgbdata_t *nonwadtex;
145147
146148 Q_snprintf ( texname, sizeof ( texname ), " %s.mip" , name );
147149 Q_strncpy ( tex->name , name, sizeof ( tex->name ));
@@ -163,27 +165,19 @@ bool TEX_LoadMiptex( const char *name, mipentry_t *tex )
163165 return true ;
164166 }
165167 }
166- #if 0 // this is no longer support by engine
167- // wadpath is not specified
168- if( FS_FileExists( texname, false ))
169- {
170- // texture is loaded, wad is used
171- tex->data = FS_LoadFile( texname, &tex->datasize, false );
172- tex->width = ((miptex_t *)tex->data)->width;
173- tex->height = ((miptex_t *)tex->data)->height;
174- tex->wadnum = -1; // wad where the tex is located
175- return true;
176- }
177- #endif
178- // maybe it's tga path?
179- Q_snprintf ( texname, sizeof ( texname ), " textures/%s.tga" , name );
180168
181- if ( FS_FileExists (texname, false ))
182- {
183- // texture is loaded, wad is not used
184- TEX_LoadTGA ( texname, tex );
169+ // maybe it has non-quake format and lies in textures folder?
170+ Q_snprintf (texname, sizeof (texname), " textures/%s " , name);
171+
172+ nonwadtex = COM_LoadImage ( texname, true , FS_LoadFile );
185173
186- // FIXME: add loader for dds
174+ if ( nonwadtex )
175+ {
176+ tex->datasize = nonwadtex->size ;
177+ tex->width = nonwadtex->width ;
178+ tex->height = nonwadtex->height ;
179+ tex->wadnum = -1 ; // wad is not used
180+ Msg (" %s width %d, height %d\n " , texname, tex->width , tex->height );
187181 return true ;
188182 }
189183
0 commit comments