From 17ed7aaabda2bb1cd538949113efaef43e6f6d73 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 5 Jul 2011 10:02:38 +0000 Subject: [PATCH] - moved the code from r_data.cpp to some better fitting places and deleted this file and r_data.h because the remaining parts of it were just a random collection of unrelated functions. SVN r3248 (trunk) --- src/CMakeLists.txt | 1 - src/c_cmds.cpp | 1 + src/d_net.cpp | 1 + src/decallib.cpp | 1 + src/dobjgc.cpp | 2 +- src/fragglescript/t_fspic.cpp | 1 + src/fragglescript/t_load.cpp | 1 - src/g_game.cpp | 1 - src/g_level.cpp | 1 - src/g_shared/a_armor.cpp | 2 +- src/g_shared/a_lightning.cpp | 2 +- src/g_shared/a_secrettrigger.cpp | 1 - src/g_shared/shared_sbar.cpp | 1 + src/p_acs.h | 1 + src/p_conversation.cpp | 1 - src/p_conversation.h | 4 ++ src/p_sectors.cpp | 1 - src/p_setup.cpp | 2 +- src/p_slopes.cpp | 1 - src/p_spec.h | 1 + src/p_udmf.cpp | 2 +- src/p_usdf.cpp | 3 +- src/p_xlat.cpp | 1 - src/r_defs.h | 9 ---- src/r_draw.cpp | 12 +++++ src/r_draw.h | 2 +- src/r_interpolate.cpp | 1 - src/r_interpolate.h | 1 + src/r_local.h | 1 - src/r_main.cpp | 26 ++++++++- src/r_main.h | 22 +++++++- src/r_plane.h | 1 - src/r_polymost.cpp | 1 + src/r_sky.cpp | 1 - src/r_state.h | 3 +- src/resources/colormaps.cpp | 2 +- src/s_advsound.cpp | 2 +- src/textures/automaptexture.cpp | 2 +- src/textures/buildtexture.cpp | 1 + src/textures/canvastexture.cpp | 2 + src/textures/ddstexture.cpp | 2 + src/textures/emptytexture.cpp | 2 +- src/textures/flattexture.cpp | 2 +- src/textures/imgztexture.cpp | 2 +- src/textures/jpegtexture.cpp | 3 +- src/textures/multipatchtexture.cpp | 4 +- src/textures/patchtexture.cpp | 10 +++- src/textures/pcxtexture.cpp | 2 + src/textures/pngtexture.cpp | 1 + src/textures/rawpagetexture.cpp | 2 +- src/textures/texture.cpp | 39 +++++++++++++- src/textures/texturemanager.cpp | 36 ++++++++++++- src/textures/textures.h | 81 ++++++++++++++++++++++++++++ src/textures/tgatexture.cpp | 2 + src/textures/warptexture.cpp | 2 +- src/thingdef/thingdef_properties.cpp | 1 + src/v_font.cpp | 1 - src/win32/i_system.cpp | 2 +- zdoom.vcproj | 4 -- 59 files changed, 268 insertions(+), 52 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3efcb87eb9..64826e799e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -724,7 +724,6 @@ add_executable( zdoom WIN32 po_man.cpp r_3dfloors.cpp r_bsp.cpp - r_data.cpp r_draw.cpp r_drawt.cpp r_interpolate.cpp diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 48cb2f1037..6dc75dca9f 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -70,6 +70,7 @@ #include "d_net.h" #include "v_text.h" #include "p_lnspec.h" +#include "v_video.h" extern FILE *Logfile; extern bool insave; diff --git a/src/d_net.cpp b/src/d_net.cpp index 33a66c1b1a..a00400deab 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -58,6 +58,7 @@ #include "d_event.h" #include "m_argv.h" #include "p_lnspec.h" +#include "v_video.h" int P_StartScript (AActor *who, line_t *where, int script, char *map, bool backSide, int arg0, int arg1, int arg2, int always, bool wantResultCode, bool net); diff --git a/src/decallib.cpp b/src/decallib.cpp index 6bbf0f74da..3f8c5debbd 100644 --- a/src/decallib.cpp +++ b/src/decallib.cpp @@ -48,6 +48,7 @@ #include "gi.h" #include "g_level.h" #include "colormatcher.h" +#include "b_bot.h" FDecalLib DecalLibrary; diff --git a/src/dobjgc.cpp b/src/dobjgc.cpp index 6420970732..05d7f3e55d 100644 --- a/src/dobjgc.cpp +++ b/src/dobjgc.cpp @@ -61,7 +61,6 @@ #include "b_bot.h" #include "p_local.h" #include "g_game.h" -#include "r_data.h" #include "a_sharedglobal.h" #include "sbar.h" #include "stats.h" @@ -72,6 +71,7 @@ #include "doomstat.h" #include "m_argv.h" #include "po_man.h" +#include "v_video.h" #include "menu/menu.h" #include "intermission/intermission.h" diff --git a/src/fragglescript/t_fspic.cpp b/src/fragglescript/t_fspic.cpp index 8c6a8db3b8..d5e6e5aece 100644 --- a/src/fragglescript/t_fspic.cpp +++ b/src/fragglescript/t_fspic.cpp @@ -37,6 +37,7 @@ #include "p_local.h" #include "farchive.h" #include "sbar.h" +#include "v_video.h" diff --git a/src/fragglescript/t_load.cpp b/src/fragglescript/t_load.cpp index c374de7106..2d1e49fa51 100644 --- a/src/fragglescript/t_load.cpp +++ b/src/fragglescript/t_load.cpp @@ -38,7 +38,6 @@ #include "g_level.h" #include "sc_man.h" #include "s_sound.h" -#include "r_data.h" #include "r_sky.h" #include "t_script.h" #include "cmdlib.h" diff --git a/src/g_game.cpp b/src/g_game.cpp index 12c7af4409..6feb318f52 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -61,7 +61,6 @@ #include "p_local.h" #include "s_sound.h" #include "gstrings.h" -#include "r_data.h" #include "r_sky.h" #include "r_draw.h" #include "g_game.h" diff --git a/src/g_level.cpp b/src/g_level.cpp index 20611fc354..5167908af6 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -42,7 +42,6 @@ #include "m_random.h" #include "doomstat.h" #include "wi_stuff.h" -#include "r_data.h" #include "w_wad.h" #include "am_map.h" #include "c_dispatch.h" diff --git a/src/g_shared/a_armor.cpp b/src/g_shared/a_armor.cpp index 1475f86d24..62a9e5af75 100644 --- a/src/g_shared/a_armor.cpp +++ b/src/g_shared/a_armor.cpp @@ -2,10 +2,10 @@ #include "info.h" #include "gi.h" -#include "r_data.h" #include "a_pickups.h" #include "templates.h" #include "g_level.h" +#include "d_player.h" IMPLEMENT_CLASS (AArmor) diff --git a/src/g_shared/a_lightning.cpp b/src/g_shared/a_lightning.cpp index 8193b71b0e..98049bb3f2 100644 --- a/src/g_shared/a_lightning.cpp +++ b/src/g_shared/a_lightning.cpp @@ -1,13 +1,13 @@ #include "a_lightning.h" #include "p_lnspec.h" #include "statnums.h" -#include "r_data.h" #include "m_random.h" #include "templates.h" #include "s_sound.h" #include "p_acs.h" #include "r_sky.h" #include "g_level.h" +#include "r_state.h" static FRandom pr_lightning ("Lightning"); diff --git a/src/g_shared/a_secrettrigger.cpp b/src/g_shared/a_secrettrigger.cpp index 79f3bcd304..4484340db6 100644 --- a/src/g_shared/a_secrettrigger.cpp +++ b/src/g_shared/a_secrettrigger.cpp @@ -40,7 +40,6 @@ #include "d_player.h" #include "doomstat.h" #include "v_font.h" -#include "r_data.h" #include "p_spec.h" EXTERN_CVAR(String, secretmessage) diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index b1dff41b9f..0a0817a3f4 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -51,6 +51,7 @@ #include "d_net.h" #include "colormatcher.h" #include "v_palette.h" +#include "d_player.h" #include "../version.h" diff --git a/src/p_acs.h b/src/p_acs.h index d1c49c8f04..fb53dd414c 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -38,6 +38,7 @@ #include "dobject.h" #include "dthinker.h" #include "doomtype.h" +#include "farchive.h" #define LOCAL_SIZE 20 #define NUM_MAPVARS 128 diff --git a/src/p_conversation.cpp b/src/p_conversation.cpp index 64708aa98f..9ed876226e 100644 --- a/src/p_conversation.cpp +++ b/src/p_conversation.cpp @@ -35,7 +35,6 @@ #include #include "actor.h" -#include "r_data.h" #include "r_main.h" #include "p_conversation.h" #include "w_wad.h" diff --git a/src/p_conversation.h b/src/p_conversation.h index d4fa600098..14ec89e53d 100644 --- a/src/p_conversation.h +++ b/src/p_conversation.h @@ -3,9 +3,13 @@ #include +#include "s_sound.h" +#include "textures/textures.h" + struct FStrifeDialogueReply; class FTexture; struct FBrokenLines; +struct PClass; struct FStrifeDialogueItemCheck { diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index cff2329282..c2cdc5a28b 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -21,7 +21,6 @@ // //----------------------------------------------------------------------------- -#include "r_data.h" #include "p_spec.h" #include "c_cvars.h" #include "doomstat.h" diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 149b7a5199..3854671995 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3936,7 +3936,7 @@ void P_SetupLevel (char *lumpname, int position) // preload graphics and sounds if (precache) { - R_PrecacheLevel (); + TexMan.PrecacheLevel (); S_PrecacheLevel (); } times[17].Unclock(); diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index 7cf6c5fbed..5ac7cf704b 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -34,7 +34,6 @@ #include "doomtype.h" #include "p_local.h" -#include "r_data.h" #include "cmdlib.h" #include "p_lnspec.h" diff --git a/src/p_spec.h b/src/p_spec.h index 8656e42473..2db74fcd9f 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -27,6 +27,7 @@ #include "dsectoreffect.h" #include "doomdata.h" +#include "r_state.h" class FScanner; struct level_info_t; diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index e856265daf..1ad67850eb 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -33,7 +33,6 @@ ** */ -#include "r_data.h" #include "p_setup.h" #include "p_lnspec.h" #include "templates.h" @@ -43,6 +42,7 @@ #include "g_level.h" #include "v_palette.h" #include "p_udmf.h" +#include "r_state.h" #include "resources/colormaps.h" //=========================================================================== diff --git a/src/p_usdf.cpp b/src/p_usdf.cpp index b831b4140f..d25cc86057 100644 --- a/src/p_usdf.cpp +++ b/src/p_usdf.cpp @@ -32,7 +32,6 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#include "r_data.h" #include "p_setup.h" #include "p_lnspec.h" #include "templates.h" @@ -40,6 +39,8 @@ #include "p_conversation.h" #include "p_udmf.h" #include "doomerrors.h" +#include "cmdlib.h" +#include "actor.h" #define Zd 1 #define St 2 diff --git a/src/p_xlat.cpp b/src/p_xlat.cpp index 9e87d13baa..e61dcd52f0 100644 --- a/src/p_xlat.cpp +++ b/src/p_xlat.cpp @@ -36,7 +36,6 @@ #include "g_level.h" #include "p_lnspec.h" #include "doomdata.h" -#include "r_data.h" #include "m_swap.h" #include "p_spec.h" #include "p_local.h" diff --git a/src/r_defs.h b/src/r_defs.h index 6d17b222cb..8f59f3b1b3 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1031,15 +1031,6 @@ struct FMiniBSP -// posts are runs of non masked source pixels -struct column_t -{ - BYTE topdelta; // -1 is the last post in a column - BYTE length; // length data bytes follows -}; - - - // // OTHER TYPES // diff --git a/src/r_draw.cpp b/src/r_draw.cpp index 918a7bcdb4..3103772e78 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -2043,6 +2043,18 @@ void R_DrawBorder (int x1, int y1, int x2, int y2) } } +//========================================================================== +// +// R_GetColumn +// +//========================================================================== + +const BYTE *R_GetColumn (FTexture *tex, int col) +{ + return tex->GetColumn (col, NULL); +} + + /* ================== = diff --git a/src/r_draw.h b/src/r_draw.h index 0f678776dd..8ff62d3414 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -23,7 +23,7 @@ #ifndef __R_DRAW__ #define __R_DRAW__ -#include "r_data.h" +#include "r_defs.h" extern "C" int ylookup[MAXHEIGHT]; diff --git a/src/r_interpolate.cpp b/src/r_interpolate.cpp index f145347a5b..9bdaeb2136 100644 --- a/src/r_interpolate.cpp +++ b/src/r_interpolate.cpp @@ -33,7 +33,6 @@ ** */ -#include "r_data.h" #include "p_3dmidtex.h" #include "stats.h" #include "r_interpolate.h" diff --git a/src/r_interpolate.h b/src/r_interpolate.h index 9334827e83..bbd2438d87 100644 --- a/src/r_interpolate.h +++ b/src/r_interpolate.h @@ -1,6 +1,7 @@ #ifndef R_INTERPOLATE_H #define R_INTERPOLATE_H +#include "dobject.h" //========================================================================== // // diff --git a/src/r_local.h b/src/r_local.h index c666b1de4c..08ba838029 100644 --- a/src/r_local.h +++ b/src/r_local.h @@ -30,7 +30,6 @@ #include "doomdef.h" // Include the refresh/render data structs. -#include "r_data.h" // // Separate header file for each module. diff --git a/src/r_main.cpp b/src/r_main.cpp index 6e0927bb83..dda822fa2d 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -52,6 +52,8 @@ #include "r_3dfloors.h" #include "v_palette.h" #include "po_man.h" +#include "st_start.h" +#include "v_font.h" #include "resources/colormaps.h" // MACROS ------------------------------------------------------------------ @@ -810,7 +812,12 @@ void R_Init () { atterm (R_Shutdown); - R_InitData (); + StartScreen->Progress(); + V_InitFonts(); + StartScreen->Progress(); + R_InitColormaps (); + StartScreen->Progress(); + R_InitPointToAngle (); R_InitTables (); // viewwidth / viewheight are set by the defaults @@ -845,7 +852,22 @@ static void R_Shutdown () R_DeinitParticles(); R_DeinitTranslationTables(); R_DeinitPlanes(); - R_DeinitData(); + R_DeinitColormaps (); + FCanvasTextureInfo::EmptyList(); + + // Free openings + if (openings != NULL) + { + M_Free (openings); + openings = NULL; + } + + // Free drawsegs + if (drawsegs != NULL) + { + M_Free (drawsegs); + drawsegs = NULL; + } } //========================================================================== diff --git a/src/r_main.h b/src/r_main.h index e52f901df1..2259b0db9a 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -28,9 +28,9 @@ #define NUMCOLORMAPS 32 #include "d_player.h" -#include "r_data.h" #include "r_state.h" #include "v_palette.h" +#include "resources/colormaps.h" // @@ -214,4 +214,24 @@ extern angle_t stacked_angle; extern void R_CopyStackedViewParameters(); +// This list keeps track of the cameras that draw into canvas textures. +struct FCanvasTextureInfo +{ + FCanvasTextureInfo *Next; + TObjPtr Viewpoint; + FCanvasTexture *Texture; + FTextureID PicNum; + int FOV; + + static void Add (AActor *viewpoint, FTextureID picnum, int fov); + static void UpdateAll (); + static void EmptyList (); + static void Serialize (FArchive &arc); + static void Mark(); + +private: + static FCanvasTextureInfo *List; +}; + + #endif // __R_MAIN_H__ diff --git a/src/r_plane.h b/src/r_plane.h index f0eb22f026..6bcb36a193 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -24,7 +24,6 @@ #define __R_PLANE_H__ #include -#include "r_data.h" class ASkyViewpoint; diff --git a/src/r_polymost.cpp b/src/r_polymost.cpp index 6832bddbea..3d4ea52322 100644 --- a/src/r_polymost.cpp +++ b/src/r_polymost.cpp @@ -81,6 +81,7 @@ Low priority: #include "r_bsp.h" #include "v_palette.h" #include "v_font.h" +#include "v_video.h" #include "resources/colormaps.h" EXTERN_CVAR (Int, r_polymost) diff --git a/src/r_sky.cpp b/src/r_sky.cpp index e9c319de1c..8ff2d6c62d 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -28,7 +28,6 @@ // Needed for FRACUNIT. #include "m_fixed.h" -#include "r_data.h" #include "c_cvars.h" #include "g_level.h" #include "r_sky.h" diff --git a/src/r_state.h b/src/r_state.h index 80c11641d8..4736e2327d 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -25,7 +25,6 @@ // Need data structure definitions. #include "d_player.h" -#include "r_data.h" // // Refresh internal data structures, @@ -130,4 +129,6 @@ extern sector_t* viewsector; // [RH] keep track of sector viewing from extern angle_t xtoviewangle[MAXWIDTH+1]; extern int FieldOfView; +int R_FindSkin (const char *name, int pclass); // [RH] Find a skin + #endif // __R_STATE_H__ diff --git a/src/resources/colormaps.cpp b/src/resources/colormaps.cpp index 7b36e387da..c0ce25c256 100644 --- a/src/resources/colormaps.cpp +++ b/src/resources/colormaps.cpp @@ -43,7 +43,6 @@ #include "r_local.h" #include "r_sky.h" #include "c_dispatch.h" -#include "r_data.h" #include "sc_man.h" #include "v_text.h" #include "st_start.h" @@ -53,6 +52,7 @@ #include "v_palette.h" #include "colormatcher.h" #include "colormaps.h" +#include "v_video.h" static bool R_CheckForFixedLights(const BYTE *colormaps); diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index 5f3a3e2e6b..250ebbf961 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -46,10 +46,10 @@ #include "gi.h" #include "doomstat.h" #include "i_sound.h" -#include "r_data.h" #include "m_random.h" #include "d_netinf.h" #include "i_system.h" +#include "d_player.h" // MACROS ------------------------------------------------------------------ diff --git a/src/textures/automaptexture.cpp b/src/textures/automaptexture.cpp index 9a2b29df10..1bfec41c3a 100644 --- a/src/textures/automaptexture.cpp +++ b/src/textures/automaptexture.cpp @@ -37,8 +37,8 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/buildtexture.cpp b/src/textures/buildtexture.cpp index 836cc2daa7..0b3db702ad 100644 --- a/src/textures/buildtexture.cpp +++ b/src/textures/buildtexture.cpp @@ -40,6 +40,7 @@ #include "templates.h" #include "cmdlib.h" #include "st_start.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/canvastexture.cpp b/src/textures/canvastexture.cpp index 278145b04b..c62a8ef026 100644 --- a/src/textures/canvastexture.cpp +++ b/src/textures/canvastexture.cpp @@ -37,6 +37,8 @@ #include "files.h" #include "r_local.h" #include "v_palette.h" +#include "v_video.h" +#include "textures/textures.h" extern float LastFOV; diff --git a/src/textures/ddstexture.cpp b/src/textures/ddstexture.cpp index f26180f029..437fb28d50 100644 --- a/src/textures/ddstexture.cpp +++ b/src/textures/ddstexture.cpp @@ -54,6 +54,8 @@ #include "w_wad.h" #include "templates.h" #include "bitmap.h" +#include "v_video.h" +#include "textures/textures.h" // Since we want this to compile under Linux too, we need to define this // stuff ourselves instead of including a DirectX header. diff --git a/src/textures/emptytexture.cpp b/src/textures/emptytexture.cpp index 205c6940dd..d0637c9a59 100644 --- a/src/textures/emptytexture.cpp +++ b/src/textures/emptytexture.cpp @@ -36,8 +36,8 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/flattexture.cpp b/src/textures/flattexture.cpp index 400d3a02f7..4e6a499fc0 100644 --- a/src/textures/flattexture.cpp +++ b/src/textures/flattexture.cpp @@ -35,9 +35,9 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" #include "v_palette.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/imgztexture.cpp b/src/textures/imgztexture.cpp index 1d79e25957..36f954b95e 100644 --- a/src/textures/imgztexture.cpp +++ b/src/textures/imgztexture.cpp @@ -35,8 +35,8 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" +#include "textures/textures.h" //========================================================================== diff --git a/src/textures/jpegtexture.cpp b/src/textures/jpegtexture.cpp index 7a45e6001f..f8e732d458 100644 --- a/src/textures/jpegtexture.cpp +++ b/src/textures/jpegtexture.cpp @@ -35,11 +35,12 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "r_jpeg.h" #include "w_wad.h" #include "v_text.h" #include "bitmap.h" +#include "v_video.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 725490127d..d75dc6b0e6 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -36,7 +36,6 @@ #include #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" #include "i_system.h" #include "gi.h" @@ -47,6 +46,9 @@ #include "bitmap.h" #include "colormatcher.h" #include "v_palette.h" +#include "v_video.h" +#include "m_fixed.h" +#include "textures/textures.h" #include "resources/colormaps.h" // On the Alpha, accessing the shorts directly if they aren't aligned on a diff --git a/src/textures/patchtexture.cpp b/src/textures/patchtexture.cpp index 12ef31bcb5..eb9487bc28 100644 --- a/src/textures/patchtexture.cpp +++ b/src/textures/patchtexture.cpp @@ -35,10 +35,18 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" #include "templates.h" #include "v_palette.h" +#include "textures/textures.h" + + +// posts are runs of non masked source pixels +struct column_t +{ + BYTE topdelta; // -1 is the last post in a column + BYTE length; // length data bytes follows +}; //========================================================================== diff --git a/src/textures/pcxtexture.cpp b/src/textures/pcxtexture.cpp index a3b72c4881..cc2b3a2265 100644 --- a/src/textures/pcxtexture.cpp +++ b/src/textures/pcxtexture.cpp @@ -41,6 +41,8 @@ #include "templates.h" #include "bitmap.h" #include "colormatcher.h" +#include "v_video.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/pngtexture.cpp b/src/textures/pngtexture.cpp index 4e30802c42..54a0a0cd94 100644 --- a/src/textures/pngtexture.cpp +++ b/src/textures/pngtexture.cpp @@ -41,6 +41,7 @@ #include "m_png.h" #include "bitmap.h" #include "v_palette.h" +#include "textures/textures.h" //========================================================================== // diff --git a/src/textures/rawpagetexture.cpp b/src/textures/rawpagetexture.cpp index 47fcd70fff..ac237d0bd7 100644 --- a/src/textures/rawpagetexture.cpp +++ b/src/textures/rawpagetexture.cpp @@ -35,9 +35,9 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "w_wad.h" #include "v_palette.h" +#include "textures/textures.h" //========================================================================== diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index 433e9f03b0..fa2c564dd6 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -36,12 +36,15 @@ #include "doomtype.h" #include "files.h" #include "w_wad.h" -#include "r_data.h" #include "templates.h" #include "i_system.h" #include "r_translate.h" #include "bitmap.h" #include "colormatcher.h" +#include "c_dispatch.h" +#include "v_video.h" +#include "m_fixed.h" +#include "textures/textures.h" typedef bool (*CheckFunc)(FileReader & file); typedef FTexture * (*CreateFunc)(FileReader & file, int lumpnum); @@ -596,3 +599,37 @@ const BYTE *FDummyTexture::GetPixels () return NULL; } +//========================================================================== +// +// Debug stuff +// +//========================================================================== + +#ifdef _DEBUG +// Prints the spans generated for a texture. Only needed for debugging. +CCMD (printspans) +{ + if (argv.argc() != 2) + return; + + FTextureID picnum = TexMan.CheckForTexture (argv[1], FTexture::TEX_Any); + if (!picnum.Exists()) + { + Printf ("Unknown texture %s\n", argv[1]); + return; + } + FTexture *tex = TexMan[picnum]; + for (int x = 0; x < tex->GetWidth(); ++x) + { + const FTexture::Span *spans; + Printf ("%4d:", x); + tex->GetColumn (x, &spans); + while (spans->Length != 0) + { + Printf (" (%4d,%4d)", spans->TopOffset, spans->TopOffset+spans->Length-1); + spans++; + } + Printf ("\n"); + } +} +#endif diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index eb1a967f81..daf47e221a 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -35,8 +35,8 @@ */ #include "doomtype.h" +#include "doomstat.h" #include "w_wad.h" -#include "r_data.h" #include "templates.h" #include "i_system.h" #include "r_translate.h" @@ -47,6 +47,10 @@ #include "st_start.h" #include "cmdlib.h" #include "g_level.h" +#include "m_fixed.h" +#include "farchive.h" +#include "v_video.h" +#include "textures/textures.h" FTextureManager TexMan; @@ -1143,6 +1147,36 @@ int FTextureManager::CountLumpTextures (int lumpnum) return 0; } +//=========================================================================== +// +// R_PrecacheLevel +// +// Preloads all relevant graphics for the level. +// +//=========================================================================== + +void FTextureManager::PrecacheLevel (void) +{ + BYTE *hitlist; + int cnt = NumTextures(); + + if (demoplayback) + return; + + hitlist = new BYTE[cnt]; + memset (hitlist, 0, cnt); + + screen->GetHitlist(hitlist); + for (int i = cnt - 1; i >= 0; i--) + { + screen->PrecacheTexture(ByIndex(i), hitlist[i]); + } + + delete[] hitlist; +} + + + //========================================================================== // diff --git a/src/textures/textures.h b/src/textures/textures.h index f49b174192..1c40ea6424 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -392,6 +392,7 @@ public: void UnloadAll (); int NumTextures () const { return (int)Textures.Size(); } + void PrecacheLevel (void); void WriteTexture (FArchive &arc, int picnum); int ReadTexture (FArchive &arc); @@ -457,6 +458,86 @@ private: TArray BuildTileFiles; }; +// A texture that doesn't really exist +class FDummyTexture : public FTexture +{ +public: + FDummyTexture (); + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + void SetSize (int width, int height); +}; + +// A texture that returns a wiggly version of another texture. +class FWarpTexture : public FTexture +{ +public: + FWarpTexture (FTexture *source); + ~FWarpTexture (); + + virtual int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate=0, FCopyInfo *inf = NULL); + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + bool CheckModified (); + + float GetSpeed() const { return Speed; } + int GetSourceLump() { return SourcePic->GetSourceLump(); } + void SetSpeed(float fac) { Speed = fac; } + FTexture *GetRedirect(bool wantwarped); + + DWORD GenTime; +protected: + FTexture *SourcePic; + BYTE *Pixels; + Span **Spans; + float Speed; + + virtual void MakeTexture (DWORD time); +}; + +// [GRB] Eternity-like warping +class FWarp2Texture : public FWarpTexture +{ +public: + FWarp2Texture (FTexture *source); + +protected: + void MakeTexture (DWORD time); +}; + +// A texture that can be drawn to. +class DSimpleCanvas; +class AActor; +class FArchive; + +class FCanvasTexture : public FTexture +{ +public: + FCanvasTexture (const char *name, int width, int height); + ~FCanvasTexture (); + + const BYTE *GetColumn (unsigned int column, const Span **spans_out); + const BYTE *GetPixels (); + void Unload (); + bool CheckModified (); + void RenderView (AActor *viewpoint, int fov); + void NeedUpdate() { bNeedsUpdate=true; } + +protected: + DSimpleCanvas *Canvas; + BYTE *Pixels; + Span DummySpans[2]; + BYTE bNeedsUpdate:1; + BYTE bDidUpdate:1; + BYTE bFirstUpdate:1; + + void MakeTexture (); + + friend struct FCanvasTextureInfo; +}; + extern FTextureManager TexMan; #endif diff --git a/src/textures/tgatexture.cpp b/src/textures/tgatexture.cpp index 3e30a13d15..d44cf5e1be 100644 --- a/src/textures/tgatexture.cpp +++ b/src/textures/tgatexture.cpp @@ -40,6 +40,8 @@ #include "templates.h" #include "bitmap.h" #include "colormatcher.h" +#include "v_video.h" +#include "textures/textures.h" //========================================================================== diff --git a/src/textures/warptexture.cpp b/src/textures/warptexture.cpp index 360d1d38a1..0e6ff925cc 100644 --- a/src/textures/warptexture.cpp +++ b/src/textures/warptexture.cpp @@ -35,9 +35,9 @@ #include "doomtype.h" #include "files.h" -#include "r_data.h" #include "r_main.h" #include "templates.h" +#include "textures/textures.h" FWarpTexture::FWarpTexture (FTexture *source) diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 925c2a6c3f..487a5fddaf 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -68,6 +68,7 @@ #include "a_morph.h" #include "colormatcher.h" #include "teaminfo.h" +#include "v_video.h" #include "resources/colormaps.h" diff --git a/src/v_font.cpp b/src/v_font.cpp index eb26f0c6cf..410e6515a6 100644 --- a/src/v_font.cpp +++ b/src/v_font.cpp @@ -85,7 +85,6 @@ The FON2 header is followed by variable length data: #include "v_font.h" #include "v_video.h" #include "w_wad.h" -#include "r_data.h" #include "i_system.h" #include "gi.h" #include "cmdlib.h" diff --git a/src/win32/i_system.cpp b/src/win32/i_system.cpp index aa5945011a..7d3dde74aa 100644 --- a/src/win32/i_system.cpp +++ b/src/win32/i_system.cpp @@ -83,8 +83,8 @@ #include "doomstat.h" #include "v_palette.h" #include "stats.h" -#include "r_data.h" #include "textures/bitmap.h" +#include "textures/textures.h" // MACROS ------------------------------------------------------------------ diff --git a/zdoom.vcproj b/zdoom.vcproj index 0885a56044..faa520ba87 100644 --- a/zdoom.vcproj +++ b/zdoom.vcproj @@ -2323,10 +2323,6 @@ RelativePath=".\src\r_bsp.cpp" > - -