Untitled
unknown
plain_text
5 months ago
942 B
3
Indexable
static void Mod_LoadTextures(model_t *mod, dbspmodel_t *bmod) { dmiptexlump_t *lump = bmod->textures; const int MAX_CONCURRENT_TEXTURES = 32; // Adjust based on your needs if(bmod->texdatasize < 1 || !lump || lump->nummiptex < 1) { mod->textures = NULL; return; } // Allocate only for max concurrent instead of all textures mod->textures = Mem_Calloc(mod->mempool, MAX_CONCURRENT_TEXTURES * sizeof(texture_t *)); mod->numtextures = min(lump->nummiptex, MAX_CONCURRENT_TEXTURES); // Load textures with limit for(int i = 0; i < mod->numtextures; i++) { if(i >= MAX_CONCURRENT_TEXTURES) { // Free oldest texture if we hit the limit if(mod->textures[i % MAX_CONCURRENT_TEXTURES]) Mem_Free(mod->textures[i % MAX_CONCURRENT_TEXTURES]); } mod->textures[i % MAX_CONCURRENT_TEXTURES] = Mod_LoadTextureFromLump(mod, bmod, i); } }
Editor is loading...
Leave a Comment