diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index 60227ccae..a658982bc 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -74,6 +74,7 @@ #include "gl/stereo3d/gl_stereo3d.h" #include "gl/stereo3d/scoped_view_shifter.h" #include "gl/textures/gl_material.h" +#include "gl/textures/gl_skyboxtexture.h" #include "gl/utility/gl_clock.h" #include "gl/utility/gl_convert.h" #include "gl/utility/gl_templates.h" @@ -978,6 +979,7 @@ struct FGLInterface : public FRenderer { bool UsesColormap() const; void PrecacheTexture(FTexture *tex, int cache); + void Precache(BYTE *texhitlist, TMap &actorhitlist); void RenderView(player_t *player); void WriteSavePic (player_t *player, FILE *file, int width, int height); void StateChanged(AActor *actor); @@ -1028,6 +1030,85 @@ void FGLInterface::PrecacheTexture(FTexture *tex, int cache) } } +void FGLInterface::Precache(BYTE *texhitlist, TMap &actorhitlist) +{ + BYTE *spritelist = new BYTE[sprites.Size()]; + TMap::Iterator it(actorhitlist); + TMap::Pair *pair; + + // this isn't done by the main code so it needs to be done here first: + // check skybox textures and mark the separate faces as used + for (int i = 0; igl_info.bSkybox) + { + FSkyBox *sb = static_cast(tex); + for (int i = 0; i<6; i++) + { + if (sb->faces[i]) + { + int index = sb->faces[i]->id.GetIndex(); + texhitlist[index] |= FTextureManager::HIT_Flat; + } + } + } + } + } + + + + + + memset(spritelist, 0, sprites.Size()); + + while (it.NextPair(pair)) + { + PClassActor *cls = pair->Key; + + for (int i = 0; i < cls->NumOwnedStates; i++) + { + spritelist[cls->OwnedStates[i].sprite] = true; + } + } + + // Precache textures (and sprites). + + for (int i = (int)(sprites.Size() - 1); i >= 0; i--) + { + if (spritelist[i]) + { + int j, k; + for (j = 0; j < sprites[i].numframes; j++) + { + const spriteframe_t *frame = &SpriteFrames[sprites[i].spriteframes + j]; + + for (k = 0; k < 16; k++) + { + FTextureID pic = frame->Texture[k]; + if (pic.isValid()) + { + texhitlist[pic.GetIndex()] = FTextureManager::HIT_Sprite; + } + } + } + } + } + delete[] spritelist; + + TexMan.precacheTime = I_FPSTime(); + + int cnt = TexMan.NumTextures(); + for (int i = cnt - 1; i >= 0; i--) + { + PrecacheTexture(TexMan.ByIndex(i), texhitlist[i]); + } +} + + //========================================================================== // // DFrameBuffer :: StateChanged diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 4a05c2d17..818084706 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -322,36 +322,6 @@ int OpenGLFrameBuffer::GetPageCount() } -void OpenGLFrameBuffer::GetHitlist(BYTE *hitlist) -{ - Super::GetHitlist(hitlist); - - // check skybox textures and mark the separate faces as used - for(int i=0;igl_info.bSkybox) - { - FSkyBox *sb = static_cast(tex); - for(int i=0;i<6;i++) - { - if (sb->faces[i]) - { - int index = sb->faces[i]->id.GetIndex(); - hitlist[index] |= FTextureManager::HIT_Flat; - } - } - } - } - } - - - // check model skins -} - //========================================================================== // // DFrameBuffer :: CreatePalette diff --git a/src/gl/system/gl_framebuffer.h b/src/gl/system/gl_framebuffer.h index 9c87e9dc8..ad25851af 100644 --- a/src/gl/system/gl_framebuffer.h +++ b/src/gl/system/gl_framebuffer.h @@ -46,7 +46,6 @@ public: void GetFlash(PalEntry &rgb, int &amount); int GetPageCount(); bool Begin2D(bool copy3d); - void GetHitlist(BYTE *hitlist); void GameRestart(); // Retrieves a buffer containing image data for a screenshot.