Skip to content

Commit f0bee38

Browse files
APAmk2SNMetamorph
authored andcommitted
utils: pxcsg: replaced built-in TGA loader with imagelib
1 parent df20731 commit f0bee38

File tree

4 files changed

+22
-85
lines changed

4 files changed

+22
-85
lines changed

utils/pxcsg/CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ list(APPEND DIR_SOURCES
1818
"../common/wadfile.cpp"
1919
"../common/zone.cpp"
2020
"../common/crashhandler.cpp"
21+
"${CMAKE_SOURCE_DIR}/public/crclib.cpp"
2122
"brush.cpp"
2223
"csg4.cpp"
2324
"map.cpp"
2425
"patch.cpp"
2526
"qcsg.cpp"
2627
"textures.cpp"
27-
"utils.cpp"
2828
)
2929

3030
# add version info
@@ -109,6 +109,11 @@ else()
109109
)
110110
endif()
111111

112+
# link dependency libraries
113+
target_link_libraries(${PROJECT_NAME} PRIVATE
114+
imagelib
115+
)
116+
112117
set_target_properties(${PROJECT_NAME} PROPERTIES
113118
POSITION_INDEPENDENT_CODE 1)
114119

utils/pxcsg/csg.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,6 @@ typedef struct
231231
bool MakeBrushFor3Points(mapent_t *mapent, side_t *mainSide, short entindex, trivert_t *a, trivert_t *b, trivert_t *c);
232232
bool MakeBrushFor4Points(mapent_t *mapent, side_t *mainSide, short entindex, trivert_t *a, trivert_t *b, trivert_t *c, trivert_t *d);
233233

234-
//=============================================================================
235-
// utils.c
236-
237-
void TEX_LoadTGA( const char *texname, mipentry_t *tex );
238-
239234
// map.c
240235

241236
void LoadMapFile( const char *filename );

utils/pxcsg/textures.cpp

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
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 )
142143
bool 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

utils/pxcsg/utils.cpp

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)