mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-14 17:10:53 +00:00
gl_texmgr.c (TexMgr_ReloadImage): reduced the hunk memory usage during
reloading of images from the bsp by not loading the whole file but by opening the file, fseek()ing and allocating only the necessary amount. This way, I can load and reload a save of ne_ruins with just the default 64 Mb of memory on x86 and with only 68.5 Mb of memory (-heapsize 70000) on x86_64. git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@633 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
63f50a3d7e
commit
b1d8f204e0
1 changed files with 14 additions and 3 deletions
|
@ -1235,10 +1235,21 @@ void TexMgr_ReloadImage (gltexture_t *glt, int shirt, int pants)
|
|||
if (glt->source_file[0] && glt->source_offset)
|
||||
{
|
||||
//lump inside file
|
||||
data = COM_LoadHunkFile (glt->source_file, NULL);
|
||||
if (!data)
|
||||
long size;
|
||||
FILE *f;
|
||||
COM_FOpenFile(glt->source_file, &f, NULL);
|
||||
if (!f)
|
||||
goto invalid;
|
||||
data += glt->source_offset;
|
||||
fseek (f, glt->source_offset, SEEK_CUR);
|
||||
size = (long) (glt->source_width * glt->source_height);
|
||||
/* should be SRC_INDEXED, but no harm being paranoid: */
|
||||
if (glt->source_format == SRC_RGBA)
|
||||
size *= 4;
|
||||
else if (glt->source_format == SRC_LIGHTMAP)
|
||||
size *= lightmap_bytes;
|
||||
data = Hunk_Alloc (size);
|
||||
fread (data, 1, size, f);
|
||||
fclose (f);
|
||||
}
|
||||
else if (glt->source_file[0] && !glt->source_offset)
|
||||
data = Image_LoadImage (glt->source_file, (int *)&glt->source_width, (int *)&glt->source_height); //simple file
|
||||
|
|
Loading…
Reference in a new issue