From 465bcfd199ed7b45e693b58f4dcef7ed2485e736 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Jan 2008 10:23:18 +0000 Subject: [PATCH] - Added a PrecacheTexture virtual function to DFrameBuffer because it's the renderer which should decide how to precache a texture. SVN r723 (trunk) --- docs/rh-log.txt | 2 ++ src/r_data.cpp | 13 +------------ src/r_defs.h | 2 -- src/v_video.cpp | 21 +++++++++++++++++++++ src/v_video.h | 5 +++++ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 041bab805..d8784959e 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,4 +1,6 @@ January 27, 2008 (Changes by Graf Zahl) +- Added a PrecacheTexture virtual function to DFrameBuffer because it's the + renderer which should decide how to precache a texture. - Added SnowKate709's APROP_MaxHealth submission. - Fixed: FTexture::GetScaledWidth/Height always rounded down which could result in imprecisions (e.g. when scaling from 128 to 96.) diff --git a/src/r_data.cpp b/src/r_data.cpp index 74add5976..75a682058 100644 --- a/src/r_data.cpp +++ b/src/r_data.cpp @@ -485,18 +485,7 @@ void R_PrecacheLevel (void) for (i = TexMan.NumTextures() - 1; i >= 0; i--) { - FTexture *tex = TexMan[i]; - if (tex != NULL) - { - if (hitlist[i]) - { - tex->GetPixels (); - } - else - { - tex->Unload (); - } - } + screen->PrecacheTexture(TexMan[i], !!hitlist[i]); } delete[] hitlist; diff --git a/src/r_defs.h b/src/r_defs.h index a2f09710f..7902032f7 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -844,8 +844,6 @@ private: TArray Translation; WORD HashFirst[HASH_SIZE]; int DefaultTexture; - - friend void R_InitData (); }; extern FTextureManager TexMan; diff --git a/src/v_video.cpp b/src/v_video.cpp index ebb3282eb..34d7e03b4 100644 --- a/src/v_video.cpp +++ b/src/v_video.cpp @@ -1316,6 +1316,27 @@ void DFrameBuffer::CopyPixelData(BYTE * buffer, int texpitch, int texheight, int } } +//=========================================================================== +// +// Texture precaching +// +//=========================================================================== + +void DFrameBuffer::PrecacheTexture(FTexture *tex, bool cache) +{ + if (tex != NULL) + { + if (cache) + { + tex->GetPixels (); + } + else + { + tex->Unload (); + } + } +} + //=========================================================================== // // Render the view diff --git a/src/v_video.h b/src/v_video.h index efa0cf758..c1445c85c 100644 --- a/src/v_video.h +++ b/src/v_video.h @@ -49,6 +49,8 @@ extern int CleanWidth, CleanHeight, CleanXfac, CleanYfac; extern int DisplayWidth, DisplayHeight, DisplayBits; +bool V_DoModeSetup (int width, int height, int bits); + class FTexture; // TagItem definitions for DrawTexture. As far as I know, tag lists @@ -375,6 +377,9 @@ public: const BYTE *patch, int pix_width, int pix_height, int step_x, int step_y, PalEntry * palette); + // Precaches or unloads a texture + virtual void PrecacheTexture(FTexture *tex, bool cache); + // Screen wiping virtual bool WipeStartScreen(int type); virtual void WipeEndScreen();