void gld_Precache(void) { int i; byte *hitlist; int hit, hitcount = 0; GLTexture *gltexture; box_skybox_t *sb; unsigned int tics = SDL_GetTicks(); int usehires = (gl_texture_external_hires) || (gl_texture_internal_hires && r_have_internal_hires); if (doSkip || nodrawers) return; if (!usehires) { if (!precache) return; if (timingdemo) return; } gld_ProgressStart(); { size_t size = numflats > numsprites ? numflats : numsprites; hitlist = Z_Malloc((size_t)numtextures > size ? (size_t)numtextures : size,PU_LEVEL,0); } // Precache flats. memset(hitlist, 0, numflats); for (i = numsectors; --i >= 0; ) { int j,k; int floorpic = sectors[i].floorpic; int ceilingpic = sectors[i].ceilingpic; anim_t *flatanims[2] = { anim_flats[floorpic].anim, anim_flats[ceilingpic].anim }; hitlist[floorpic] = hitlist[ceilingpic] = 1; //e6y: animated flats for (k = 0; k < 2; k++) { if (flatanims[k] && !flatanims[k]->istexture) { for (j = flatanims[k]->basepic; j < flatanims[k]->basepic + flatanims[k]->numpics; j++) hitlist[j] = 1; } } } CalcHitsCount(hitlist, numflats, &hit, &hitcount); for (i = numflats; --i >= 0; ) if (hitlist[i]) { gld_ProgressUpdate("Loading Flats...", ++hit, hitcount); gltexture = gld_RegisterFlat(i,true); if (gltexture) { gld_BindFlat(gltexture, 0); } } // Precache textures. memset(hitlist, 0, numtextures); for (i = numsides; --i >= 0;) { int j, k; int bottomtexture, toptexture, midtexture; anim_t *textureanims[3]; if (sides[i].special == 271 || sides[i].special == 272) { sb = R_GetBoxSkybox(sides[i].skybox_index); if (sb) { int texture; int face = 0; while (face < 6 && sb->faces[face]) { texture = R_CheckTextureNumForName(sb->faces[face]); if (texture != -1) { hitlist[texture] = 1; } face++; } } } bottomtexture = sides[i].bottomtexture; toptexture = sides[i].toptexture; midtexture = sides[i].midtexture; textureanims[0] = anim_textures[bottomtexture].anim; textureanims[1] = anim_textures[toptexture].anim; textureanims[2] = anim_textures[midtexture].anim; hitlist[bottomtexture] = hitlist[toptexture] = hitlist[midtexture] = 1; //e6y: animated textures for (k = 0; k < 3; k++) { if (textureanims[k] && textureanims[k]->istexture) { for (j = textureanims[k]->basepic; j < textureanims[k]->basepic + textureanims[k]->numpics; j++) hitlist[j] = 1; } } //e6y: swithes { int GetPairForSwitchTexture(side_t *side); int pair = GetPairForSwitchTexture(&sides[i]); if (pair != -1) hitlist[pair] = 1; } } // Sky texture is always present. // Note that F_SKY1 is the name used to // indicate a sky floor/ceiling as a flat, // while the sky texture is stored like // a wall texture, with an episode dependend // name. if (hitlist) hitlist[skytexture] = usehires ? 1 : 0; sb = BoxSkybox_default; if (sb) { int texture; int face = 0; while (face < 6 && sb->faces[face]) { texture = R_CheckTextureNumForName(sb->faces[face]); if (texture != -1) { hitlist[texture] = 1; } face++; } } CalcHitsCount(hitlist, numtextures, &hit, &hitcount); for (i = numtextures; --i >= 0; ) if (hitlist[i]) { gld_ProgressUpdate("Loading Textures...", ++hit, hitcount); gltexture = gld_RegisterTexture(i, i != skytexture, false); if (gltexture) { gld_BindTexture(gltexture, 0); } } // Precache sprites. memset(hitlist, 0, numsprites); if (thinkercap.next) { thinker_t *th; for (th = thinkercap.next ; th != &thinkercap ; th=th->next) { if (th->function == P_MobjThinker) hitlist[((mobj_t *)th)->sprite] = 1; } } hit = 0; hitcount = 0; for (i = 0; i < numsprites; i++) { if (hitlist[i]) hitcount += 7 * sprites[i].numframes; } for (i=numsprites; --i >= 0;) if (hitlist[i]) { int j = sprites[i].numframes; while (--j >= 0) { short *sflump = sprites[i].spriteframes[j].lump; int k = 7; do { gld_ProgressUpdate("Loading Sprites...", ++hit, hitcount); gltexture = gld_RegisterPatch(firstspritelump + sflump[k], CR_LIMIT); if (gltexture) { gld_BindPatch(gltexture, CR_LIMIT); } } while (--k >= 0); } } Z_Free(hitlist); if (gl_texture_external_hires) { #ifdef HAVE_LIBSDL_IMAGE gld_PrecacheGUIPatches(); #endif } gld_ProgressEnd(); #ifdef USE_FBO_TECHNIQUE gld_InitFBO(); #endif // e6y: some statistics. make sense for hires { char map[8]; if (gamemode == commercial) sprintf(map, "MAP%02i", gamemap); else sprintf(map, "E%iM%i", gameepisode, gamemap); lprintf(LO_INFO, "gld_Precache: %s done in %d ms\n", map, SDL_GetTicks() - tics); } }
void gld_Precache(void) { register int i; register byte *hitlist; if (demoplayback) return; { size_t size = numflats > numsprites ? numflats : numsprites; hitlist = Z_Malloc((size_t)numtextures > size ? numtextures : size,PU_LEVEL,0); } // Precache flats. memset(hitlist, 0, numflats); for (i = numsectors; --i >= 0; ) hitlist[sectors[i].floorpic] = hitlist[sectors[i].ceilingpic] = 1; for (i = numflats; --i >= 0; ) if (hitlist[i]) gld_BindFlat(gld_RegisterFlat(i,true)); // Precache textures. memset(hitlist, 0, numtextures); for (i = numsides; --i >= 0;) hitlist[sides[i].bottomtexture] = hitlist[sides[i].toptexture] = hitlist[sides[i].midtexture] = 1; // Sky texture is always present. // Note that F_SKY1 is the name used to // indicate a sky floor/ceiling as a flat, // while the sky texture is stored like // a wall texture, with an episode dependend // name. hitlist[skytexture] = 0; for (i = numtextures; --i >= 0; ) if (hitlist[i]) gld_BindTexture(gld_RegisterTexture(i,true,false)); // Precache sprites. memset(hitlist, 0, numsprites); { thinker_t *th; for (th = thinkercap.next ; th != &thinkercap ; th=th->next) if (th->function == P_MobjThinker) hitlist[((mobj_t *)th)->sprite] = 1; } for (i=numsprites; --i >= 0;) if (hitlist[i]) { int j = sprites[i].numframes; while (--j >= 0) { short *sflump = sprites[i].spriteframes[j].lump; int k = 7; do gld_BindPatch(gld_RegisterPatch(firstspritelump + sflump[k],CR_DEFAULT),CR_DEFAULT); while (--k >= 0); } } Z_Free(hitlist); }