- parched the texture precaching so that it compiles and works again. The real work will come later.

This commit is contained in:
Christoph Oelckers 2016-05-02 00:13:00 +02:00
parent b2e67c2c7e
commit f2f3fa6d09
3 changed files with 81 additions and 31 deletions

View file

@ -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<PClassActor*, bool> &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<PClassActor*, bool> &actorhitlist)
{
BYTE *spritelist = new BYTE[sprites.Size()];
TMap<PClassActor*, bool>::Iterator it(actorhitlist);
TMap<PClassActor*, bool>::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; i<TexMan.NumTextures(); i++)
{
// HIT_Wall must be checked for MBF-style sky transfers.
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
{
FTexture *tex = TexMan.ByIndex(i);
if (tex->gl_info.bSkybox)
{
FSkyBox *sb = static_cast<FSkyBox*>(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

View file

@ -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;i<TexMan.NumTextures(); i++)
{
// HIT_Wall must be checked for MBF-style sky transfers.
if (hitlist[i] & (FTextureManager::HIT_Sky|FTextureManager::HIT_Wall))
{
FTexture *tex = TexMan.ByIndex(i);
if (tex->gl_info.bSkybox)
{
FSkyBox *sb = static_cast<FSkyBox*>(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

View file

@ -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.