- major dependency reduction of the texture system.

This commit is contained in:
Christoph Oelckers 2020-04-11 19:00:07 +02:00
parent ab77416ddc
commit f8e9cb8fbc
103 changed files with 820 additions and 712 deletions

View file

@ -67,6 +67,7 @@
#include "earcut.hpp"
#include "c_buttons.h"
#include "d_buttons.h"
#include "texturemanager.h"
//=============================================================================

View file

@ -1,6 +1,7 @@
#pragma once
#include <stdint.h>
#include "zstring.h"
#include "palentry.h"
struct FScriptPosition;

View file

@ -67,6 +67,7 @@
#include "findfile.h"
#include "i_music.h"
#include "s_music.h"
#include "texturemanager.h"
extern FILE *Logfile;
extern bool insave;

View file

@ -66,6 +66,7 @@
#include "utf8.h"
#include "s_music.h"
#include "i_time.h"
#include "texturemanager.h"
#include "gi.h"

View file

@ -108,6 +108,8 @@
#include "d_buttons.h"
#include "i_interface.h"
#include "animations.h"
#include "texturemanager.h"
#include "formats/multipatchtexture.h"
EXTERN_CVAR(Bool, hud_althud)
EXTERN_CVAR(Int, vr_mode)
@ -2626,6 +2628,121 @@ static bool System_CaptureModeInGame()
}
static void PatchTextures()
{
// The Hexen scripts use BLANK as a blank texture, even though it's really not.
// I guess the Doom renderer must have clipped away the line at the bottom of
// the texture so it wasn't visible. Change its use type to a blank null texture to really make it blank.
if (gameinfo.gametype == GAME_Hexen)
{
FTextureID tex = TexMan.CheckForTexture("BLANK", ETextureType::Wall, false);
if (tex.Exists())
{
auto texture = TexMan.GetTexture(tex, false);
texture->SetUseType(ETextureType::Null);
}
}
// Hexen parallax skies use color 0 to indicate transparency on the front
// layer, so we must not remap color 0 on these textures. Unfortunately,
// the only way to identify these textures is to check the MAPINFO.
for (unsigned int i = 0; i < wadlevelinfos.Size(); ++i)
{
if (wadlevelinfos[i].flags & LEVEL_DOUBLESKY)
{
FTextureID picnum = TexMan.CheckForTexture(wadlevelinfos[i].SkyPic1, ETextureType::Wall, false);
if (picnum.isValid())
{
TexMan.GetTexture(picnum)->SetFrontSkyLayer();
}
}
}
}
//==========================================================================
//
// this gets called during texture creation to fix known problems
//
//==========================================================================
static void CheckForHacks(BuildInfo& buildinfo)
{
if (buildinfo.Parts.Size() == 0)
{
return;
}
// Heretic sky textures are marked as only 128 pixels tall,
// even though they are really 200 pixels tall.
if (gameinfo.gametype == GAME_Heretic &&
buildinfo.Name.Len() == 4 &&
buildinfo.Name[0] == 'S' &&
buildinfo.Name[1] == 'K' &&
buildinfo.Name[2] == 'Y' &&
buildinfo.Name[3] >= '1' &&
buildinfo.Name[3] <= '3' &&
buildinfo.Height == 128)
{
buildinfo.Height = 200;
buildinfo.tex->SetSize(buildinfo.tex->GetTexelWidth(), 200);
return;
}
// The Doom E1 sky has its patch's y offset at -8 instead of 0.
if (gameinfo.gametype == GAME_Doom &&
!(gameinfo.flags & GI_MAPxx) &&
buildinfo.Name.Len() == 4 &&
buildinfo.Parts.Size() == 1 &&
buildinfo.Height == 128 &&
buildinfo.Parts[0].OriginY == -8 &&
buildinfo.Name[0] == 'S' &&
buildinfo.Name[1] == 'K' &&
buildinfo.Name[2] == 'Y' &&
buildinfo.Name[3] == '1')
{
buildinfo.Parts[0].OriginY = 0;
return;
}
// BIGDOOR7 in Doom also has patches at y offset -4 instead of 0.
if (gameinfo.gametype == GAME_Doom &&
!(gameinfo.flags & GI_MAPxx) &&
buildinfo.Name.CompareNoCase("BIGDOOR7") == 0 &&
buildinfo.Parts.Size() == 2 &&
buildinfo.Height == 128 &&
buildinfo.Parts[0].OriginY == -4 &&
buildinfo.Parts[1].OriginY == -4)
{
buildinfo.Parts[0].OriginY = 0;
buildinfo.Parts[1].OriginY = 0;
return;
}
}
CUSTOM_CVAR(Bool, vid_nopalsubstitutions, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
{
// This is in case the sky texture has been substituted.
R_InitSkyMap();
}
//==========================================================================
//
// FTextureManager :: PalCheck taken out of the texture manager because it ties it to other subsystems
// todo: move elsewhere
//
//==========================================================================
int PalCheck(int tex)
{
// In any true color mode this shouldn't do anything.
if (vid_nopalsubstitutions || V_IsTrueColor()) return tex;
FTexture *ftex = TexMan.ByIndex(tex);
if (ftex != nullptr && ftex->GetPalVersion() != nullptr) return ftex->GetPalVersion()->GetID().GetIndex();
return tex;
}
//==========================================================================
//
// D_DoomMain
@ -2945,7 +3062,9 @@ static int D_DoomMain_Internal (void)
S_ParseMusInfo();
if (!batchrun) Printf ("Texman.Init: Init texture manager.\n");
TexMan.Init();
SpriteFrames.Clear();
TexMan.Init([]() { StartScreen->Progress(); }, CheckForHacks);
PatchTextures();
TexAnim.Init();
C_InitConback();

View file

@ -43,6 +43,7 @@
#include "v_text.h"
#include "c_functions.h"
#include "gstrings.h"
#include "texturemanager.h"
//==========================================================================
//

View file

@ -91,6 +91,7 @@
#include "i_time.h"
#include "p_maputl.h"
#include "s_music.h"
#include "texturemanager.h"
void STAT_StartNewGame(const char *lev);
void STAT_ChangeLevel(const char *newl, FLevelLocals *Level);

View file

@ -39,6 +39,7 @@
#include "sbar.h"
#include "r_utility.h"
#include "actorinlines.h"
#include "texturemanager.h"
#define ST_RAMPAGEDELAY (2*TICRATE)
#define ST_MUCHPAIN 20

View file

@ -49,6 +49,7 @@
#include "vm.h"
#include "i_system.h"
#include "utf8.h"
#include "texturemanager.h"
#define ARTIFLASH_OFFSET (statusBar->invBarOffset+6)
enum

View file

@ -59,6 +59,7 @@
#include "events.h"
#include "g_game.h"
#include "utf8.h"
#include "texturemanager.h"
#include "../version.h"

View file

@ -47,6 +47,7 @@
#include "serializer.h"
#include "g_levellocals.h"
#include "a_decalfx.h"
#include "texturemanager.h"
FDecalLib DecalLibrary;

View file

@ -58,6 +58,8 @@
#include "myiswalpha.h"
#include "textures/formats/fontchars.h"
#include "textures/formats/multipatchtexture.h"
#include "texturemanager.h"
#include "r_translate.h"
#include "fontinternals.h"

View file

@ -39,6 +39,8 @@
#include "filesystem.h"
#include "utf8.h"
#include "sc_man.h"
#include "texturemanager.h"
#include "r_translate.h"
#include "fontinternals.h"

View file

@ -40,6 +40,7 @@
#include "filesystem.h"
#include "utf8.h"
#include "textures/formats/fontchars.h"
#include "texturemanager.h"
#include "fontinternals.h"

View file

@ -37,6 +37,7 @@
#include "textures.h"
#include "v_font.h"
#include "filesystem.h"
#include "texturemanager.h"
class FSinglePicFont : public FFont
{

View file

@ -37,6 +37,7 @@
#include "textures.h"
#include "image.h"
#include "textures/formats/fontchars.h"
#include "texturemanager.h"
#include "fontinternals.h"

View file

@ -55,6 +55,7 @@
#include "image.h"
#include "utf8.h"
#include "textures/formats/fontchars.h"
#include "texturemanager.h"
#include "fontinternals.h"

View file

@ -52,6 +52,7 @@
#include "types.h"
#include "filesystem.h"
#include "g_levellocals.h"
#include "texturemanager.h"
extern void LoadActors ();
extern void InitBotStuff();

View file

@ -46,6 +46,7 @@
#include "p_local.h"
#include "actor.h"
#include "vm.h"
#include "texturemanager.h"
// MACROS ------------------------------------------------------------------

View file

@ -35,6 +35,7 @@
#include "m_bbox.h"
#include "dobjgc.h"
#include "r_data/r_translate.h"
#include "texmanip.h"
// Some more or less basic data types
// we depend on.

View file

@ -41,6 +41,7 @@
#include "sc_man.h"
#include "gi.h"
#include "animations.h"
#include "texturemanager.h"
static int SortSwitchDefs (const void *a, const void *b)

View file

@ -42,6 +42,7 @@
#include "filesystem.h"
#include "serializer.h"
#include "animations.h"
#include "texturemanager.h"
// MACROS ------------------------------------------------------------------

View file

@ -44,6 +44,8 @@
#include "resourcefile.h"
#include "image.h"
#include "animations.h"
#include "texturemanager.h"
#include "r_translate.h"
//==========================================================================

View file

@ -37,7 +37,6 @@
#include "files.h"
#include "filesystem.h"
#include "textures/textures.h"
#include "image.h"
//==========================================================================

View file

@ -35,7 +35,6 @@
#include "files.h"
#include "filesystem.h"
#include "textures/textures.h"
#include "imagehelpers.h"
#include "image.h"

View file

@ -3,6 +3,8 @@
#include "palettecontainer.h"
#include "textureid.h"
#include "vectors.h"
#include "bitmap.h"
#include "image.h"
class FImageTexture;
//==========================================================================
@ -121,6 +123,8 @@ class FMultipatchTextureBuilder
{
FTextureManager &TexMan;
TArray<BuildInfo> BuiltTextures;
void(*progressFunc)();
void(*checkForHacks)(BuildInfo&);
void MakeTexture(BuildInfo &buildinfo, ETextureType usetype);
@ -128,11 +132,10 @@ class FMultipatchTextureBuilder
void AddTexturesLump(const void *lumpdata, int lumpsize, int deflumpnum, int patcheslump, int firstdup, bool texture1);
void ParsePatch(FScanner &sc, BuildInfo &info, TexPart &part, TexInit &init);
void CheckForHacks(BuildInfo &buildinfo);
void ResolvePatches(BuildInfo &buildinfo);
public:
FMultipatchTextureBuilder(FTextureManager &texMan) : TexMan(texMan)
FMultipatchTextureBuilder(FTextureManager &texMan, void(*progressFunc_)(), void(*checkForHacks_)(BuildInfo &)) : TexMan(texMan), progressFunc(progressFunc_), checkForHacks(checkForHacks_)
{
}

View file

@ -40,7 +40,7 @@
#include "bitmap.h"
#include "imagehelpers.h"
#include "image.h"
#include "textures.h"
#include "printf.h"
//==========================================================================
//
@ -557,6 +557,7 @@ int FPNGTexture::CopyPixels(FBitmap *bmp, int conversion)
}
#include "textures.h"
//==========================================================================
//

View file

@ -36,7 +36,6 @@
#include "files.h"
#include "filesystem.h"
#include "bitmap.h"
#include "textures/textures.h"
#include "imagehelpers.h"
#include "image.h"

View file

@ -34,7 +34,6 @@
**
*/
#include "menu/menu.h"
#include "filesystem.h"
#include "bitmap.h"
#include "imagehelpers.h"
@ -132,6 +131,6 @@ private:
FTexture *CreateShaderTexture(bool vertical, bool reverse)
{
FStringf name("BarShader%c%c", vertical ? 'v' : 'h', reverse ? 'r' : 'f');
return new FImageTexture(new FBarShader(vertical, reverse), name.GetChars());
return CreateImageTexture(new FBarShader(vertical, reverse), name.GetChars());
}

View file

@ -35,7 +35,6 @@
*/
#include "c_cvars.h"
#include "v_video.h"
#include "hqnx/hqx.h"
#ifdef HAVE_MMX
#include "hqnx_asm/hqnx_asm.h"
@ -43,7 +42,9 @@
#include "xbr/xbrz.h"
#include "xbr/xbrz_old.h"
#include "parallel_for.h"
#include "hwrenderer/textures/hw_material.h"
#include "textures.h"
#include "texturemanager.h"
#include "printf.h"
EXTERN_CVAR(Int, gl_texture_hqresizemult)
CUSTOM_CVAR(Int, gl_texture_hqresizemode, 0, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINITCALL)

View file

@ -34,12 +34,12 @@
**
*/
#include "v_video.h"
#include "bitmap.h"
#include "image.h"
#include "filesystem.h"
#include "files.h"
#include "cmdlib.h"
#include "palettecontainer.h"
FMemArena FImageSource::ImageArena(32768);
TArray<FImageSource *>FImageSource::ImageForLump;
@ -283,7 +283,7 @@ FBitmap FImageSource::GetCachedBitmap(PalEntry *remap, int conversion, int *ptra
void FImageSource::CollectForPrecache(PrecacheInfo &info, bool requiretruecolor)
{
auto val = info.CheckKey(ImageID);
bool tc = requiretruecolor || V_IsTrueColor();
bool tc = requiretruecolor;
if (val)
{
val->first += tc;
@ -307,9 +307,9 @@ void FImageSource::EndPrecaching()
precacheDataRgba.Clear();
}
void FImageSource::RegisterForPrecache(FImageSource *img)
void FImageSource::RegisterForPrecache(FImageSource *img, bool requiretruecolor)
{
img->CollectForPrecache(precacheInfo);
img->CollectForPrecache(precacheInfo, requiretruecolor);
}
//==========================================================================

View file

@ -140,12 +140,12 @@ public:
return bUseGamePalette;
}
virtual void CollectForPrecache(PrecacheInfo &info, bool requiretruecolor = false);
virtual void CollectForPrecache(PrecacheInfo &info, bool requiretruecolor);
static void BeginPrecaching();
static void EndPrecaching();
static void RegisterForPrecache(FImageSource *img);
static void RegisterForPrecache(FImageSource *img, bool requiretruecolor);
};
class FTexture;
FTexture* CreateImageTexture(FImageSource* img) noexcept;
FTexture* CreateImageTexture(FImageSource* img, const char *name = nullptr) noexcept;

View file

@ -38,7 +38,6 @@
#include "filesystem.h"
#include "templates.h"
#include "bitmap.h"
#include "v_video.h"
#include "image.h"
#include "textures.h"
@ -91,8 +90,8 @@ TArray<uint8_t> FImageTexture::Get8BitPixels(bool alpha)
}
FTexture* CreateImageTexture(FImageSource* img) noexcept
FTexture* CreateImageTexture(FImageSource* img, const char *name) noexcept
{
return new FImageTexture(img);
return new FImageTexture(img, name);
}

View file

@ -38,22 +38,13 @@
#include "doomtype.h"
#include "files.h"
#include "filesystem.h"
#include "gi.h"
#include "st_start.h"
#include "sc_man.h"
#include "templates.h"
#include "r_data/r_translate.h"
#include "engineerrors.h"
#include "bitmap.h"
#include "colormatcher.h"
#include "v_palette.h"
#include "v_video.h"
#include "v_text.h"
#include "cmdlib.h"
#include "imagehelpers.h"
#include "textures.h"
#include "image.h"
#include "formats/multipatchtexture.h"
#include "engineerrors.h"
#include "texturemanager.h"
// On the Alpha, accessing the shorts directly if they aren't aligned on a
// 4-byte boundary causes unaligned access warnings. Why it does this at
@ -388,7 +379,7 @@ void FMultipatchTextureBuilder::AddTexturesLump(const void *lumpdata, int lumpsi
if (j + 1 == firstdup)
{
BuildTexture((const uint8_t *)maptex + offset, patchlookup.Data(), numpatches, isStrife, deflumpnum, (i == 1 && texture1) ? ETextureType::FirstDefined : ETextureType::Wall);
StartScreen->Progress();
progressFunc();
}
}
}
@ -772,66 +763,6 @@ void FMultipatchTextureBuilder::ParseTexture(FScanner &sc, ETextureType UseType)
//==========================================================================
//
// FMultiPatchTexture :: CheckForHacks
//
//==========================================================================
void FMultipatchTextureBuilder::CheckForHacks(BuildInfo &buildinfo)
{
if (buildinfo.Parts.Size() == 0)
{
return;
}
// Heretic sky textures are marked as only 128 pixels tall,
// even though they are really 200 pixels tall.
if (gameinfo.gametype == GAME_Heretic &&
buildinfo.Name.Len() == 4 &&
buildinfo.Name[0] == 'S' &&
buildinfo.Name[1] == 'K' &&
buildinfo.Name[2] == 'Y' &&
buildinfo.Name[3] >= '1' &&
buildinfo.Name[3] <= '3' &&
buildinfo.Height == 128)
{
buildinfo.Height = 200;
buildinfo.tex->SetSize(buildinfo.tex->Width, 200);
return;
}
// The Doom E1 sky has its patch's y offset at -8 instead of 0.
if (gameinfo.gametype == GAME_Doom &&
!(gameinfo.flags & GI_MAPxx) &&
buildinfo.Name.Len() == 4 &&
buildinfo.Parts.Size() == 1 &&
buildinfo.Height == 128 &&
buildinfo.Parts[0].OriginY == -8 &&
buildinfo.Name[0] == 'S' &&
buildinfo.Name[1] == 'K' &&
buildinfo.Name[2] == 'Y' &&
buildinfo.Name[3] == '1')
{
buildinfo.Parts[0].OriginY = 0;
return;
}
// BIGDOOR7 in Doom also has patches at y offset -4 instead of 0.
if (gameinfo.gametype == GAME_Doom &&
!(gameinfo.flags & GI_MAPxx) &&
buildinfo.Name.CompareNoCase("BIGDOOR7") == 0 &&
buildinfo.Parts.Size() == 2 &&
buildinfo.Height == 128 &&
buildinfo.Parts[0].OriginY == -4 &&
buildinfo.Parts[1].OriginY == -4)
{
buildinfo.Parts[0].OriginY = 0;
buildinfo.Parts[1].OriginY = 0;
return;
}
}
//==========================================================================
//
//
@ -911,7 +842,7 @@ void FMultipatchTextureBuilder::ResolvePatches(BuildInfo &buildinfo)
}
}
CheckForHacks(buildinfo);
checkForHacks(buildinfo);
}
void FMultipatchTextureBuilder::ResolveAllPatches()

View file

@ -25,6 +25,7 @@
#include "textures.h"
#include "skyboxtexture.h"
#include "bitmap.h"
#include "texturemanager.h"

View file

@ -0,0 +1,75 @@
#pragma once
#include "palentry.h"
struct TextureManipulation
{
enum
{
BlendNone = 0,
BlendAlpha = 1,
BlendScreen = 2,
BlendOverlay = 3,
BlendHardLight = 4,
BlendMask = 7,
InvertBit = 8,
ActiveBit = 16, // Must be set for the shader to do something
};
PalEntry AddColor; // Alpha contains the blend flags
PalEntry ModulateColor; // Alpha may contain a multiplier to get higher values than 1.0 without promoting this to 4 full floats.
PalEntry BlendColor;
float DesaturationFactor;
bool CheckIfEnabled() // check if this manipulation is doing something. NoOps do not need to be preserved, unless they override older setttings.
{
if (AddColor != 0 || // this includes a check for the blend mode without which BlendColor is not active
ModulateColor != 0x01ffffff || // 1 in alpha must be the default for a no-op.
DesaturationFactor != 0)
{
AddColor.a |= ActiveBit; // mark as active for the shader's benefit.
return true;
}
return false;
}
void SetTextureModulateColor(int slot, PalEntry rgb)
{
rgb.a = ModulateColor.a;
ModulateColor = rgb;
}
void SetTextureModulateScaleFactor(int slot, int fac)
{
ModulateColor.a = (uint8_t)fac;
}
void SetTextureAdditiveColor(int slot, PalEntry rgb)
{
rgb.a = AddColor.a;
AddColor = rgb;
}
void SetTextureBlendColor(int slot, PalEntry rgb)
{
BlendColor = rgb;
}
void SetTextureDesaturationFactor(int slot, double fac)
{
DesaturationFactor = (float)fac;
}
void SetTextureBlendMode(int slot, int mode)
{
AddColor.a = (AddColor.a & ~TextureManipulation::BlendMask) | (mode & TextureManipulation::BlendMask);
}
void SetTextureInvert(bool on)
{
AddColor.a |= TextureManipulation::InvertBit;
AddColor.a &= ~TextureManipulation::InvertBit;
}
};

View file

@ -38,31 +38,25 @@
#include "files.h"
#include "filesystem.h"
#include "templates.h"
#include "r_data/r_translate.h"
#include "textures.h"
#include "bitmap.h"
#include "colormatcher.h"
#include "c_dispatch.h"
#include "v_video.h"
#include "m_fixed.h"
#include "hwrenderer/textures/hw_material.h"
#include "hwrenderer/textures/hw_ihwtexture.h"
#include "swrenderer/textures/r_swtexture.h"
#include "imagehelpers.h"
#include "image.h"
#include "formats/multipatchtexture.h"
#include "g_levellocals.h"
#include "texturemanager.h"
// Wrappers to keep the definitions of these classes out of here.
void DeleteMaterial(FMaterial* mat);
void DeleteSoftwareTexture(FSoftwareTexture *swtex);
FTexture *CreateBrightmapTexture(FImageSource*);
// Make sprite offset adjustment user-configurable per renderer.
int r_spriteadjustSW, r_spriteadjustHW;
CUSTOM_CVAR(Int, r_spriteadjust, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
r_spriteadjustHW = !!(self & 2);
r_spriteadjustSW = !!(self & 1);
TexMan.SpriteAdjustChanged();
}
//==========================================================================
//
@ -161,12 +155,12 @@ FTexture::~FTexture ()
for (int i = 0; i < 2; i++)
{
if (Material[i] != nullptr) delete Material[i];
if (Material[i] != nullptr) DeleteMaterial(Material[i]);
Material[i] = nullptr;
}
if (SoftwareTexture != nullptr)
{
delete SoftwareTexture;
DeleteSoftwareTexture(SoftwareTexture);
SoftwareTexture = nullptr;
}
}
@ -740,21 +734,6 @@ bool FTexture::GetTranslucency()
return !!bTranslucent;
}
//===========================================================================
//
// Sprite adjust has changed.
// This needs to alter the material's sprite rect.
//
//===========================================================================
void FTexture::SetSpriteAdjust()
{
for (auto mat : Material)
{
if (mat != nullptr) mat->SetSpriteRect();
}
}
//===========================================================================
//
// the default just returns an empty texture.
@ -768,24 +747,6 @@ TArray<uint8_t> FTexture::Get8BitPixels(bool alphatex)
return Pixels;
}
//==========================================================================
//
//
//
//==========================================================================
FWrapperTexture::FWrapperTexture(int w, int h, int bits)
{
Width = w;
Height = h;
Format = bits;
UseType = ETextureType::SWCanvas;
bNoCompress = true;
auto hwtex = screen->CreateHardwareTexture();
// todo: Initialize here.
SystemTextures.AddHardwareTexture(0, false, hwtex);
}
//===========================================================================
//
// Coordinate helper.

View file

@ -38,32 +38,16 @@
#include "doomstat.h"
#include "filesystem.h"
#include "templates.h"
#include "i_system.h"
#include "gstrings.h"
#include "r_data/r_translate.h"
#include "r_data/sprites.h"
#include "textures.h"
#include "texturemanager.h"
#include "c_dispatch.h"
#include "v_text.h"
#include "sc_man.h"
#include "gi.h"
#include "st_start.h"
#include "cmdlib.h"
#include "g_level.h"
#include "v_video.h"
#include "r_sky.h"
#include "vm.h"
#include "image.h"
#include "formats/multipatchtexture.h"
#include "swrenderer/textures/r_swtexture.h"
FTextureManager TexMan;
CUSTOM_CVAR(Bool, vid_nopalsubstitutions, false, CVAR_ARCHIVE|CVAR_NOINITCALL)
{
// This is in case the sky texture has been substituted.
R_InitSkyMap ();
}
//==========================================================================
//
@ -126,6 +110,7 @@ void FTextureManager::DeleteAll()
// main reason to call this outside of the destruction code.
//
//==========================================================================
void DeleteSoftwareTexture(FSoftwareTexture* swtex);
void FTextureManager::FlushAll()
{
@ -134,7 +119,7 @@ void FTextureManager::FlushAll()
for (int j = 0; j < 2; j++)
{
Textures[i].Texture->SystemTextures.Clean(true, true);
delete Textures[i].Texture->SoftwareTexture;
DeleteSoftwareTexture(Textures[i].Texture->SoftwareTexture);
Textures[i].Texture->SoftwareTexture = nullptr;
}
}
@ -262,20 +247,6 @@ FTextureID FTextureManager::CheckForTexture (const char *name, ETextureType uset
return FTextureID(-1);
}
static int CheckForTexture(const FString &name, int type, int flags)
{
return TexMan.CheckForTexture(name, static_cast<ETextureType>(type), flags).GetIndex();
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture)
{
PARAM_PROLOGUE;
PARAM_STRING(name);
PARAM_INT(type);
PARAM_INT(flags);
ACTION_RETURN_INT(CheckForTexture(name, type, flags));
}
//==========================================================================
//
// FTextureManager :: ListTextures
@ -365,38 +336,14 @@ FTexture *FTextureManager::FindTexture(const char *texname, ETextureType usetype
return GetTexture(texnum.GetIndex());
}
//==========================================================================
//
// Defines how graphics substitution is handled.
// 0: Never replace a text-containing graphic with a font-based text.
// 1: Always replace, regardless of any missing information. Useful for testing the substitution without providing full data.
// 2: Only replace for non-default texts, i.e. if some language redefines the string's content, use it instead of the graphic. Never replace a localized graphic.
// 3: Only replace if the string is not the default and the graphic comes from the IWAD. Never replace a localized graphic.
// 4: Like 1, but lets localized graphics pass.
//
// The default is 3, which only replaces known content with non-default texts.
//
//==========================================================================
CUSTOM_CVAR(Int, cl_gfxlocalization, 3, CVAR_ARCHIVE)
{
if (self < 0 || self > 4) self = 0;
}
//==========================================================================
//
// FTextureManager :: OkForLocalization
//
//==========================================================================
bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitute)
bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitute, int locmode)
{
if (!texnum.isValid()) return false;
// First the unconditional settings, 0='never' and 1='always'.
if (cl_gfxlocalization == 1 || gameinfo.forcetextinmenus) return false;
if (cl_gfxlocalization == 0 || gameinfo.forcenogfxsubstitution) return true;
uint32_t langtable = 0;
if (*substitute == '$') substitute = GStrings.GetString(substitute+1, &langtable);
else return true; // String literals from the source data should never override graphics from the same definition.
@ -407,11 +354,11 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut
if (localizedTex != texnum.GetIndex()) return true; // Do not substitute a localized variant of the graphics patch.
// For mode 4 we are done now.
if (cl_gfxlocalization == 4) return false;
if (locmode == 4) return false;
// Mode 2 and 3 must reject any text replacement from the default language tables.
if ((langtable & MAKE_ID(255,0,0,0)) == MAKE_ID('*', 0, 0, 0)) return true; // Do not substitute if the string comes from the default table.
if (cl_gfxlocalization == 2) return false;
if (locmode == 2) return false;
// Mode 3 must also reject substitutions for non-IWAD content.
int file = fileSystem.GetFileContainer(Textures[texnum.GetIndex()].Texture->SourceLump);
@ -420,19 +367,6 @@ bool FTextureManager::OkForLocalization(FTextureID texnum, const char *substitut
return false;
}
static int OkForLocalization(int index, const FString &substitute)
{
return TexMan.OkForLocalization(FSetTextureID(index), substitute);
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, OkForLocalization, OkForLocalization)
{
PARAM_PROLOGUE;
PARAM_INT(name);
PARAM_STRING(subst)
ACTION_RETURN_INT(OkForLocalization(name, subst));
}
//==========================================================================
//
// FTextureManager :: AddTexture
@ -576,7 +510,7 @@ void FTextureManager::AddGroup(int wadnum, int ns, ETextureType usetype)
{
CreateTexture (firsttx, usetype);
}
StartScreen->Progress();
progressFunc();
}
else if (ns == ns_flats && fileSystem.GetFileFlags(firsttx) & LUMPF_MAYBEFLAT)
{
@ -584,7 +518,7 @@ void FTextureManager::AddGroup(int wadnum, int ns, ETextureType usetype)
{
CreateTexture (firsttx, usetype);
}
StartScreen->Progress();
progressFunc();
}
}
}
@ -648,7 +582,7 @@ void FTextureManager::AddHiresTextures (int wadnum)
}
}
}
StartScreen->Progress();
progressFunc();
}
}
}
@ -855,7 +789,7 @@ void FTextureManager::AddPatches (int lumpnum)
{
CreateTexture (fileSystem.CheckNumForName (name, ns_patches), ETextureType::WallPatch);
}
StartScreen->Progress();
progressFunc();
}
}
@ -1149,10 +1083,10 @@ void FTextureManager::AddLocalizedVariants()
FTexture *CreateShaderTexture(bool, bool);
void InitBuildTiles();
void FTextureManager::Init()
void FTextureManager::Init(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo&))
{
progressFunc = progressFunc_;
DeleteAll();
SpriteFrames.Clear();
//if (BuildTileFiles.Size() == 0) CountBuildTiles ();
// Texture 0 is a dummy texture used to indicate "no texture"
@ -1167,7 +1101,7 @@ void FTextureManager::Init()
int wadcnt = fileSystem.GetNumWads();
FMultipatchTextureBuilder build(*this);
FMultipatchTextureBuilder build(*this, progressFunc_, checkForHacks);
for(int i = 0; i< wadcnt; i++)
{
@ -1183,34 +1117,6 @@ void FTextureManager::Init()
DefaultTexture = CheckForTexture ("-NOFLAT-", ETextureType::Override, 0);
// The Hexen scripts use BLANK as a blank texture, even though it's really not.
// I guess the Doom renderer must have clipped away the line at the bottom of
// the texture so it wasn't visible. Change its use type to a blank null texture to really make it blank.
if (gameinfo.gametype == GAME_Hexen)
{
FTextureID tex = CheckForTexture ("BLANK", ETextureType::Wall, false);
if (tex.Exists())
{
auto texture = GetTexture(tex, false);
texture->UseType = ETextureType::Null;
}
}
// Hexen parallax skies use color 0 to indicate transparency on the front
// layer, so we must not remap color 0 on these textures. Unfortunately,
// the only way to identify these textures is to check the MAPINFO.
for (unsigned int i = 0; i < wadlevelinfos.Size(); ++i)
{
if (wadlevelinfos[i].flags & LEVEL_DOUBLESKY)
{
FTextureID picnum = CheckForTexture (wadlevelinfos[i].SkyPic1, ETextureType::Wall, false);
if (picnum.isValid())
{
Textures[picnum.GetIndex()].Texture->SetFrontSkyLayer ();
}
}
}
InitPalettedVersions();
AdjustSpriteOffsets();
// Add auto materials to each texture after everything has been set up.
@ -1222,7 +1128,6 @@ void FTextureManager::Init()
Textures[i].Texture->AddAutoMaterials();
}
glLight = TexMan.CheckForTexture("glstuff/gllight.png", ETextureType::MiscPatch);
glPart2 = TexMan.CheckForTexture("glstuff/glpart2.png", ETextureType::MiscPatch);
glPart = TexMan.CheckForTexture("glstuff/glpart.png", ETextureType::MiscPatch);
mirrorTexture = TexMan.CheckForTexture("glstuff/mirror.png", ETextureType::MiscPatch);
@ -1269,22 +1174,7 @@ void FTextureManager::InitPalettedVersions()
//==========================================================================
//
// FTextureManager :: PalCheck
//
//==========================================================================
int FTextureManager::PalCheck(int tex)
{
// In any true color mode this shouldn't do anything.
if (vid_nopalsubstitutions || V_IsTrueColor()) return tex;
auto ftex = Textures[tex].Texture;
if (ftex != nullptr && ftex->PalVersion != nullptr) return ftex->PalVersion->id.GetIndex();
return tex;
}
//==========================================================================
//
// FTextureManager :: PalCheck
//
//==========================================================================
EXTERN_CVAR(String, language)
@ -1481,24 +1371,6 @@ void FTextureManager::AdjustSpriteOffsets()
}
}
//-----------------------------------------------------------------------------
//
//
//
//-----------------------------------------------------------------------------
void FTextureManager::SpriteAdjustChanged()
{
for (auto &texi : Textures)
{
auto tex = texi.Texture;
if (tex->GetLeftOffset(0) != tex->GetLeftOffset(1) || tex->GetTopOffset(0) != tex->GetTopOffset(1))
{
tex->SetSpriteAdjust();
}
}
}
//==========================================================================
//
@ -1522,146 +1394,6 @@ void FTextureManager::SetTranslation(FTextureID fromtexnum, FTextureID totexnum)
//==========================================================================
//
//
//
//==========================================================================
DEFINE_ACTION_FUNCTION(_TexMan, GetName)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
auto tex = TexMan.ByIndex(texid);
FString retval;
if (tex != nullptr)
{
if (tex->GetName().IsNotEmpty()) retval = tex->GetName();
else
{
// Textures for full path names do not have their own name, they merely link to the source lump.
auto lump = tex->GetSourceLump();
if (fileSystem.GetLinkedTexture(lump) == tex)
retval = fileSystem.GetFileFullName(lump);
}
}
ACTION_RETURN_STRING(retval);
}
//==========================================================================
//
//
//
//==========================================================================
static int GetTextureSize(int texid, int *py)
{
auto tex = TexMan.ByIndex(texid);
int x, y;
if (tex != nullptr)
{
x = tex->GetDisplayWidth();
y = tex->GetDisplayHeight();
}
else x = y = -1;
if (py) *py = y;
return x;
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
int x, y;
x = GetTextureSize(texid, &y);
if (numret > 0) ret[0].SetInt(x);
if (numret > 1) ret[1].SetInt(y);
return MIN(numret, 2);
}
//==========================================================================
//
//
//
//==========================================================================
static void GetScaledSize(int texid, DVector2 *pvec)
{
auto tex = TexMan.ByIndex(texid);
double x, y;
if (tex != nullptr)
{
x = tex->GetDisplayWidthDouble();
y = tex->GetDisplayHeightDouble();
}
else x = y = -1;
if (pvec)
{
pvec->X = x;
pvec->Y = y;
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledSize, GetScaledSize)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
DVector2 vec;
GetScaledSize(texid, &vec);
ACTION_RETURN_VEC2(vec);
}
//==========================================================================
//
//
//
//==========================================================================
static void GetScaledOffset(int texid, DVector2 *pvec)
{
auto tex = TexMan.ByIndex(texid);
double x, y;
if (tex != nullptr)
{
x = tex->GetDisplayLeftOffsetDouble();
y = tex->GetDisplayTopOffsetDouble();
}
else x = y = -1;
if (pvec)
{
pvec->X = x;
pvec->Y = y;
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledOffset, GetScaledOffset)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
DVector2 vec;
GetScaledOffset(texid, &vec);
ACTION_RETURN_VEC2(vec);
}
//==========================================================================
//
//
//
//==========================================================================
static int CheckRealHeight(int texid)
{
auto tex = TexMan.ByIndex(texid);
if (tex != nullptr) return tex->CheckRealHeight();
else return -1;
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
ACTION_RETURN_INT(CheckRealHeight(texid));
}
//==========================================================================
//
// FTextureID::operator+

View file

@ -0,0 +1,186 @@
#pragma once
#include <stdint.h>
#include "tarray.h"
#include "textureid.h"
#include "basics.h"
#include "texmanip.h"
#include "name.h"
class FxAddSub;
class FTexture;
struct BuildInfo;
int PalCheck(int tex);
// Texture manager
class FTextureManager
{
void (*progressFunc)();
friend class FxAddSub; // needs access to do a bounds check on the texture ID.
public:
FTextureManager ();
~FTextureManager ();
private:
int ResolveLocalizedTexture(int texnum);
FTexture *InternalGetTexture(int texnum, bool animate, bool localize, bool palettesubst)
{
if ((unsigned)texnum >= Textures.Size()) return nullptr;
if (animate) texnum = Translation[texnum];
if (localize && Textures[texnum].HasLocalization) texnum = ResolveLocalizedTexture(texnum);
if (palettesubst) texnum = PalCheck(texnum);
return Textures[texnum].Texture;
}
public:
// This only gets used in UI code so we do not need PALVERS handling.
FTexture *GetTextureByName(const char *name, bool animate = false)
{
FTextureID texnum = GetTextureID (name, ETextureType::MiscPatch);
return InternalGetTexture(texnum.GetIndex(), animate, true, false);
}
FTexture *GetTexture(FTextureID texnum, bool animate = false)
{
return InternalGetTexture(texnum.GetIndex(), animate, true, false);
}
// This is the only access function that should be used inside the software renderer.
FTexture *GetPalettedTexture(FTextureID texnum, bool animate)
{
return InternalGetTexture(texnum.GetIndex(), animate, true, true);
}
FTexture *ByIndex(int i, bool animate = false)
{
return InternalGetTexture(i, animate, true, false);
}
FTexture *FindTexture(const char *texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny);
bool OkForLocalization(FTextureID texnum, const char *substitute, int locnum);
void FlushAll();
enum
{
TEXMAN_TryAny = 1,
TEXMAN_Overridable = 2,
TEXMAN_ReturnFirst = 4,
TEXMAN_AllowSkins = 8,
TEXMAN_ShortNameOnly = 16,
TEXMAN_DontCreate = 32,
TEXMAN_Localize = 64
};
enum
{
HIT_Wall = 1,
HIT_Flat = 2,
HIT_Sky = 4,
HIT_Sprite = 8,
HIT_Columnmode = HIT_Wall|HIT_Sky|HIT_Sprite
};
FTextureID CheckForTexture (const char *name, ETextureType usetype, BITFIELD flags=TEXMAN_TryAny);
FTextureID GetTextureID (const char *name, ETextureType usetype, BITFIELD flags=0);
int ListTextures (const char *name, TArray<FTextureID> &list, bool listall = false);
void AddGroup(int wadnum, int ns, ETextureType usetype);
void AddPatches (int lumpnum);
void AddHiresTextures (int wadnum);
void LoadTextureDefs(int wadnum, const char *lumpname, FMultipatchTextureBuilder &build);
void ParseColorization(FScanner& sc);
void ParseTextureDef(int remapLump, FMultipatchTextureBuilder &build);
void SortTexturesByType(int start, int end);
bool AreTexturesCompatible (FTextureID picnum1, FTextureID picnum2);
void AddLocalizedVariants();
FTextureID CreateTexture (int lumpnum, ETextureType usetype=ETextureType::Any); // Also calls AddTexture
FTextureID AddTexture (FTexture *texture);
FTextureID GetDefaultTexture() const { return DefaultTexture; }
void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build);
void AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build);
void Init(void (*progressFunc_)(), void (*checkForHacks)(BuildInfo &));
void DeleteAll();
void ReplaceTexture (FTextureID picnum, FTexture *newtexture, bool free);
int NumTextures () const { return (int)Textures.Size(); }
int GuesstimateNumTextures ();
TextureManipulation* GetTextureManipulation(FName name)
{
return tmanips.CheckKey(name);
}
void InsertTextureManipulation(FName cname, TextureManipulation tm)
{
tmanips.Insert(cname, tm);
}
void RemoveTextureManipulation(FName cname)
{
tmanips.Remove(cname);
}
private:
// texture counting
int CountTexturesX ();
int CountLumpTextures (int lumpnum);
void AdjustSpriteOffsets();
// Build tiles
//int CountBuildTiles ();
public:
TArray<uint8_t>& GetNewBuildTileData()
{
BuildTileData.Reserve(1);
return BuildTileData.Last();
}
FTexture* Texture(FTextureID id) { return Textures[id.GetIndex()].Texture; }
void SetTranslation(FTextureID fromtexnum, FTextureID totexnum);
private:
void InitPalettedVersions();
// Switches
struct TextureHash
{
FTexture *Texture;
int HashNext;
bool HasLocalization;
};
enum { HASH_END = -1, HASH_SIZE = 1027 };
TArray<TextureHash> Textures;
TMap<uint64_t, int> LocalizedTextures;
int HashFirst[HASH_SIZE];
FTextureID DefaultTexture;
TArray<int> FirstTextureForFile;
TArray<TArray<uint8_t> > BuildTileData;
TArray<int> Translation;
TMap<FName, TextureManipulation> tmanips;
public:
short sintable[2048]; // for texture warping
enum
{
SINMASK = 2047
};
FTextureID glPart2;
FTextureID glPart;
FTextureID mirrorTexture;
};
extern FTextureManager TexMan;

View file

@ -35,15 +35,19 @@
#ifndef __TEXTURES_H
#define __TEXTURES_H
#include "doomtype.h"
#include "basics.h"
#include "vectors.h"
#include "v_palette.h"
#include "r_data/v_colortables.h"
#include "colormatcher.h"
#include "r_data/renderstyle.h"
#include "r_data/r_translate.h"
#include "hwrenderer/textures/hw_texcontainer.h"
#include "textureid.h"
#include <vector>
#include "hwrenderer/textures/hw_texcontainer.h"
/*
#include "v_palette.h"
#include "r_data/v_colortables.h"
#include "r_data/r_translate.h"
*/
// 15 because 0th texture is our texture
#define MAX_CUSTOM_HW_SHADER_TEXTURES 15
@ -134,14 +138,6 @@ public:
FNullTextureID() : FTextureID(0) {}
};
//
// Animating textures and planes
//
// [RH] Expanded to work with a Hexen ANIMDEFS lump
//
// All FTextures present their data to the world in 8-bit format, but if
// the source data is something else, this is it.
enum FTextureFormat : uint32_t
{
TEX_Pal,
@ -256,6 +252,8 @@ public:
int GetTexelWidth() { return Width; }
int GetTexelHeight() { return Height; }
int GetTexelLeftOffset(int adjusted) { return _LeftOffset[adjusted]; }
int GetTexelTopOffset(int adjusted) { return _TopOffset[adjusted]; }
bool isValid() const { return UseType != ETextureType::Null; }
@ -310,6 +308,13 @@ public:
Scale = BaseTexture->Scale;
}
// This is only used for the null texture and for Heretic's skies.
void SetSize(int w, int h)
{
Width = w;
Height = h;
}
// Returns the whole texture, stored in column-major order
virtual TArray<uint8_t> Get8BitPixels(bool alphatex);
@ -388,13 +393,6 @@ protected:
float shaderspeed = 1.f;
int shaderindex = 0;
// This is only used for the null texture and for Heretic's skies.
void SetSize(int w, int h)
{
Width = w;
Height = h;
}
int GetScaledWidth () { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); }
int GetScaledHeight () { int foo = int((Height * 2) / Scale.Y); return (foo >> 1) + (foo & 1); }
double GetScaledWidthDouble () { return Width / Scale.X; }
@ -432,6 +430,14 @@ protected:
public:
FTextureBuffer CreateTexBuffer(int translation, int flags = 0);
bool GetTranslucency();
FMaterial* GetMaterial(int num)
{
return Material[num];
}
FTexture* GetPalVersion()
{
return PalVersion;
}
private:
int CheckDDPK3();
@ -446,195 +452,17 @@ public:
void CheckTrans(unsigned char * buffer, int size, int trans);
bool ProcessData(unsigned char * buffer, int w, int h, bool ispatch);
int CheckRealHeight();
void SetSpriteAdjust();
friend class FTextureManager;
};
class FxAddSub;
// Texture manager
class FTextureManager
{
friend class FxAddSub; // needs access to do a bounds check on the texture ID.
public:
FTextureManager ();
~FTextureManager ();
private:
int ResolveLocalizedTexture(int texnum);
int PalCheck(int tex);
FTexture *InternalGetTexture(int texnum, bool animate, bool localize, bool palettesubst)
{
if ((unsigned)texnum >= Textures.Size()) return nullptr;
if (animate) texnum = Translation[texnum];
if (localize && Textures[texnum].HasLocalization) texnum = ResolveLocalizedTexture(texnum);
if (palettesubst) texnum = PalCheck(texnum);
return Textures[texnum].Texture;
}
public:
// This only gets used in UI code so we do not need PALVERS handling.
FTexture *GetTextureByName(const char *name, bool animate = false)
{
FTextureID texnum = GetTextureID (name, ETextureType::MiscPatch);
return InternalGetTexture(texnum.GetIndex(), animate, true, false);
}
FTexture *GetTexture(FTextureID texnum, bool animate = false)
{
return InternalGetTexture(texnum.GetIndex(), animate, true, false);
}
// This is the only access function that should be used inside the software renderer.
FTexture *GetPalettedTexture(FTextureID texnum, bool animate)
{
return InternalGetTexture(texnum.GetIndex(), animate, true, true);
}
FTexture *ByIndex(int i, bool animate = false)
{
return InternalGetTexture(i, animate, true, false);
}
FTexture *FindTexture(const char *texname, ETextureType usetype = ETextureType::MiscPatch, BITFIELD flags = TEXMAN_TryAny);
bool OkForLocalization(FTextureID texnum, const char *substitute);
void FlushAll();
enum
{
TEXMAN_TryAny = 1,
TEXMAN_Overridable = 2,
TEXMAN_ReturnFirst = 4,
TEXMAN_AllowSkins = 8,
TEXMAN_ShortNameOnly = 16,
TEXMAN_DontCreate = 32,
TEXMAN_Localize = 64
};
enum
{
HIT_Wall = 1,
HIT_Flat = 2,
HIT_Sky = 4,
HIT_Sprite = 8,
HIT_Columnmode = HIT_Wall|HIT_Sky|HIT_Sprite
};
FTextureID CheckForTexture (const char *name, ETextureType usetype, BITFIELD flags=TEXMAN_TryAny);
FTextureID GetTextureID (const char *name, ETextureType usetype, BITFIELD flags=0);
int ListTextures (const char *name, TArray<FTextureID> &list, bool listall = false);
void AddGroup(int wadnum, int ns, ETextureType usetype);
void AddPatches (int lumpnum);
void AddHiresTextures (int wadnum);
void LoadTextureDefs(int wadnum, const char *lumpname, FMultipatchTextureBuilder &build);
void ParseColorization(FScanner& sc);
void ParseTextureDef(int remapLump, FMultipatchTextureBuilder &build);
void SortTexturesByType(int start, int end);
bool AreTexturesCompatible (FTextureID picnum1, FTextureID picnum2);
void AddLocalizedVariants();
FTextureID CreateTexture (int lumpnum, ETextureType usetype=ETextureType::Any); // Also calls AddTexture
FTextureID AddTexture (FTexture *texture);
FTextureID GetDefaultTexture() const { return DefaultTexture; }
void LoadTextureX(int wadnum, FMultipatchTextureBuilder &build);
void AddTexturesForWad(int wadnum, FMultipatchTextureBuilder &build);
void Init();
void DeleteAll();
void SpriteAdjustChanged();
void ReplaceTexture (FTextureID picnum, FTexture *newtexture, bool free);
int NumTextures () const { return (int)Textures.Size(); }
int GuesstimateNumTextures ();
TextureManipulation* GetTextureManipulation(FName name)
{
return tmanips.CheckKey(name);
}
void InsertTextureManipulation(FName cname, TextureManipulation tm)
{
tmanips.Insert(cname, tm);
}
void RemoveTextureManipulation(FName cname)
{
tmanips.Remove(cname);
}
private:
// texture counting
int CountTexturesX ();
int CountLumpTextures (int lumpnum);
void AdjustSpriteOffsets();
// Build tiles
//int CountBuildTiles ();
public:
TArray<uint8_t>& GetNewBuildTileData()
{
BuildTileData.Reserve(1);
return BuildTileData.Last();
}
FTexture* Texture(FTextureID id) { return Textures[id.GetIndex()].Texture; }
void SetTranslation(FTextureID fromtexnum, FTextureID totexnum);
private:
void InitPalettedVersions();
// Switches
struct TextureHash
{
FTexture *Texture;
int HashNext;
bool HasLocalization;
};
enum { HASH_END = -1, HASH_SIZE = 1027 };
TArray<TextureHash> Textures;
TMap<uint64_t, int> LocalizedTextures;
int HashFirst[HASH_SIZE];
FTextureID DefaultTexture;
TArray<int> FirstTextureForFile;
TArray<TArray<uint8_t> > BuildTileData;
TArray<int> Translation;
TMap<FName, TextureManipulation> tmanips;
public:
short sintable[2048]; // for texture warping
enum
{
SINMASK = 2047
};
FTextureID glLight;
FTextureID glPart2;
FTextureID glPart;
FTextureID mirrorTexture;
};
// A texture that can be drawn to.
class DCanvas;
class AActor;
class FCanvasTexture : public FTexture
{
public:
FCanvasTexture(const char *name, int width, int height)
FCanvasTexture(const char* name, int width, int height)
{
Name = name;
Width = width;
@ -660,6 +488,7 @@ public:
friend struct FCanvasTextureInfo;
};
// A wrapper around a hardware texture, to allow using it in the 2D drawing interface.
class FWrapperTexture : public FTexture
{
@ -694,9 +523,6 @@ public:
};
extern FTextureManager TexMan;
struct FTexCoordInfo
{
int mRenderWidth;
@ -715,7 +541,6 @@ struct FTexCoordInfo
};
#endif

View file

@ -51,6 +51,7 @@
#include "g_levellocals.h"
#include "g_game.h"
#include "sbar.h"
#include "texturemanager.h"
// MACROS ------------------------------------------------------------------

View file

@ -52,6 +52,7 @@
#include "utf8.h"
#include "templates.h"
#include "s_music.h"
#include "texturemanager.h"
FIntermissionDescriptorList IntermissionDescriptors;

View file

@ -80,6 +80,7 @@
#include "hwrenderer/data/flatvertices.h"
#include "xlat/xlat.h"
#include "vm.h"
#include "texturemanager.h"
enum
{

View file

@ -51,6 +51,7 @@
#include "vm.h"
#include "xlat/xlat.h"
#include "maploader.h"
#include "texturemanager.h"
//===========================================================================
//

View file

@ -55,6 +55,7 @@
#include "i_system.h"
#include "c_buttons.h"
#include "scripting/types.h"
#include "texturemanager.h"
int DMenu::InMenu;
static ScaleOverrider *CurrentScaleOverrider;
@ -127,6 +128,8 @@ void D_ToggleHud();
#define KEY_REPEAT_DELAY (TICRATE*5/12)
#define KEY_REPEAT_RATE (3)
bool OkForLocalization(FTextureID texnum, const char* substitute);
//============================================================================
//
//
@ -442,7 +445,7 @@ void M_SetMenu(FName menu, int param)
// This assumes that replacing one graphic will replace all of them.
// So this only checks the "New game" entry for localization capability.
FTextureID texid = TexMan.CheckForTexture("M_NGAME", ETextureType::MiscPatch);
if (!TexMan.OkForLocalization(texid, "$MNU_NEWGAME"))
if (!OkForLocalization(texid, "$MNU_NEWGAME"))
{
menu = NAME_MainmenuTextOnly;
}

View file

@ -51,6 +51,7 @@
#include "teaminfo.h"
#include "r_data/sprites.h"
#include <zmusic.h>
#include "texturemanager.h"
void ClearSaveGames();
@ -67,6 +68,37 @@ PClass *DefaultOptionMenuClass;
void I_BuildALDeviceList(FOptionValues *opt);
void I_BuildALResamplersList(FOptionValues *opt);
//==========================================================================
//
// Defines how graphics substitution is handled.
// 0: Never replace a text-containing graphic with a font-based text.
// 1: Always replace, regardless of any missing information. Useful for testing the substitution without providing full data.
// 2: Only replace for non-default texts, i.e. if some language redefines the string's content, use it instead of the graphic. Never replace a localized graphic.
// 3: Only replace if the string is not the default and the graphic comes from the IWAD. Never replace a localized graphic.
// 4: Like 1, but lets localized graphics pass.
//
// The default is 3, which only replaces known content with non-default texts.
//
//==========================================================================
CUSTOM_CVAR(Int, cl_gfxlocalization, 3, CVAR_ARCHIVE)
{
if (self < 0 || self > 4) self = 0;
}
bool OkForLocalization(FTextureID texnum, const char* substitute)
{
if (!texnum.isValid()) return false;
// First the unconditional settings, 0='never' and 1='always'.
if (cl_gfxlocalization == 1 || gameinfo.forcetextinmenus) return false;
if (cl_gfxlocalization == 0 || gameinfo.forcenogfxsubstitution) return true;
return TexMan.OkForLocalization(texnum, substitute, cl_gfxlocalization);
}
DEFINE_GLOBAL_NAMED(OptionSettings, OptionMenuSettings)
DEFINE_ACTION_FUNCTION(FOptionValues, GetCount)
@ -1141,7 +1173,7 @@ void M_StartupEpisodeMenu(FGameStartup *gs)
if (AllEpisodes[i].mPicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
if (AllEpisodes[i].mEpisodeName.IsEmpty() || TexMan.OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
continue; // We do not measure patch based entries. They are assumed to fit
}
const char *c = AllEpisodes[i].mEpisodeName;
@ -1157,7 +1189,7 @@ void M_StartupEpisodeMenu(FGameStartup *gs)
if (AllEpisodes[i].mPicName.IsNotEmpty())
{
FTextureID tex = GetMenuTexture(AllEpisodes[i].mPicName);
if (AllEpisodes[i].mEpisodeName.IsEmpty() || TexMan.OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
if (AllEpisodes[i].mEpisodeName.IsEmpty() || OkForLocalization(tex, AllEpisodes[i].mEpisodeName))
it = CreateListMenuItemPatch(posx, posy, ld->mLinespacing, AllEpisodes[i].mShortcut, tex, NAME_Skillmenu, i);
}
if (it == nullptr)
@ -1753,7 +1785,7 @@ void M_StartupSkillMenu(FGameStartup *gs)
if (skill.PicName.Len() != 0 && pItemText == nullptr)
{
FTextureID tex = GetMenuTexture(skill.PicName);
if (skill.MenuName.IsEmpty() || TexMan.OkForLocalization(tex, skill.MenuName))
if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName))
continue;
}
const char *c = pItemText ? pItemText->GetChars() : skill.MenuName.GetChars();
@ -1782,7 +1814,7 @@ void M_StartupSkillMenu(FGameStartup *gs)
if (skill.PicName.Len() != 0 && pItemText == nullptr)
{
FTextureID tex = GetMenuTexture(skill.PicName);
if (skill.MenuName.IsEmpty() || TexMan.OkForLocalization(tex, skill.MenuName))
if (skill.MenuName.IsEmpty() || OkForLocalization(tex, skill.MenuName))
li = CreateListMenuItemPatch(posx, y, ld->mLinespacing, skill.Shortcut, tex, action, SkillIndices[i]);
}
if (li == nullptr)

View file

@ -77,6 +77,7 @@
#include "fragglescript/t_script.h"
#include "s_music.h"
#include "animations.h"
#include "texturemanager.h"
extern AActor *SpawnMapThing (int index, FMapThing *mthing, int position);

View file

@ -44,6 +44,7 @@
#include "doomdata.h"
#include "g_levellocals.h"
#include "vm.h"
#include "texturemanager.h"
EXTERN_CVAR (Bool, cl_spreaddecals)
EXTERN_CVAR (Int, cl_maxdecals)

View file

@ -52,6 +52,7 @@
#include "vm.h"
#include "a_lights.h"
#include "s_music.h"
#include "texturemanager.h"
static FRandom pr_script("FScript");

View file

@ -35,6 +35,7 @@
#include "xlat/xlat.h"
#include "maploader/maploader.h"
#include "s_music.h"
#include "texturemanager.h"
class FScriptLoader
{

View file

@ -39,6 +39,7 @@
#include "p_spec.h"
#include "g_levellocals.h"
#include "animations.h"
#include "texturemanager.h"
//============================================================================
//

View file

@ -43,6 +43,7 @@
#include "p_spec.h"
#include "g_levellocals.h"
#include "actor.h"
#include "texturemanager.h"
//============================================================================

View file

@ -76,6 +76,7 @@
#include "scriptutil.h"
#include "s_music.h"
#include "v_video.h"
#include "texturemanager.h"
// P-codes for ACS scripts
enum

View file

@ -70,6 +70,7 @@
#include "r_sky.h"
#include "g_levellocals.h"
#include "vm.h"
#include "texturemanager.h"
//==========================================================================
//

View file

@ -43,6 +43,7 @@
#include "r_sky.h"
#include "colormaps.h"
#include "templates.h"
#include "c_cvars.h"
CUSTOM_CVAR(Bool, cl_customizeinvulmap, false, CVAR_ARCHIVE|CVAR_NOINITCALL)
{

View file

@ -47,6 +47,7 @@
#include "textures/skyboxtexture.h"
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
#include "hwrenderer/textures/hw_material.h"
#include "texturemanager.h"
void AddLightDefaults(FLightDefaults *defaults, double attnFactor);
void AddLightAssociation(const char *actor, const char *frame, const char *light);

View file

@ -42,6 +42,7 @@
#include "r_data/models/models_ue1.h"
#include "r_data/models/models_obj.h"
#include "i_time.h"
#include "texturemanager.h"
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data

View file

@ -28,6 +28,7 @@
#include "filesystem.h"
#include "r_data/models/models.h"
#include "texturemanager.h"
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data

View file

@ -23,6 +23,7 @@
#include "filesystem.h"
#include "cmdlib.h"
#include "r_data/models/models.h"
#include "texturemanager.h"
#define MAX_QPATH 64

View file

@ -21,6 +21,7 @@
#include "filesystem.h"
#include "r_data/models/models_obj.h"
#include "texturemanager.h"
/**
* Load an OBJ model

View file

@ -23,6 +23,7 @@
#include "filesystem.h"
#include "cmdlib.h"
#include "r_data/models/models_ue1.h"
#include "texturemanager.h"
float unpackuvert( uint32_t n, int c )
{

View file

@ -33,6 +33,7 @@
#include "g_levellocals.h"
#include "models.h"
#include "image.h"
#include "texturemanager.h"
#ifdef _MSC_VER
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data

View file

@ -38,6 +38,7 @@
#include "r_canvastexture.h"
#include "g_levellocals.h"
#include "serializer.h"
#include "texturemanager.h"
//==========================================================================
//

View file

@ -46,77 +46,6 @@ int R_FindCustomTranslation(FName name);
void R_ParseTrnslate();
void StaticSerializeTranslations(FSerializer& arc);
struct TextureManipulation
{
enum
{
BlendNone = 0,
BlendAlpha = 1,
BlendScreen = 2,
BlendOverlay = 3,
BlendHardLight = 4,
BlendMask = 7,
InvertBit = 8,
ActiveBit = 16, // Must be set for the shader to do something
};
PalEntry AddColor; // Alpha contains the blend flags
PalEntry ModulateColor; // Alpha may contain a multiplier to get higher values than 1.0 without promoting this to 4 full floats.
PalEntry BlendColor;
float DesaturationFactor;
bool CheckIfEnabled() // check if this manipulation is doing something. NoOps do not need to be preserved, unless they override older setttings.
{
if (AddColor != 0 || // this includes a check for the blend mode without which BlendColor is not active
ModulateColor != 0x01ffffff || // 1 in alpha must be the default for a no-op.
DesaturationFactor != 0)
{
AddColor.a |= ActiveBit; // mark as active for the shader's benefit.
return true;
}
return false;
}
void SetTextureModulateColor(int slot, PalEntry rgb)
{
rgb.a = ModulateColor.a;
ModulateColor = rgb;
}
void SetTextureModulateScaleFactor(int slot, int fac)
{
ModulateColor.a = (uint8_t)fac;
}
void SetTextureAdditiveColor(int slot, PalEntry rgb)
{
rgb.a = AddColor.a;
AddColor = rgb;
}
void SetTextureBlendColor(int slot, PalEntry rgb)
{
BlendColor = rgb;
}
void SetTextureDesaturationFactor(int slot, double fac)
{
DesaturationFactor = (float)fac;
}
void SetTextureBlendMode(int slot, int mode)
{
AddColor.a = (AddColor.a & ~TextureManipulation::BlendMask) | (mode & TextureManipulation::BlendMask);
}
void SetTextureInvert(bool on)
{
AddColor.a |= TextureManipulation::InvertBit;
AddColor.a &= ~TextureManipulation::InvertBit;
}
};
#endif // __R_TRANSLATE_H

View file

@ -33,6 +33,7 @@
#include "r_data/sprites.h"
#include "r_data/voxels.h"
#include "vm.h"
#include "texturemanager.h"
void InitModels();

View file

@ -49,6 +49,7 @@
#include "g_levellocals.h"
#include "vm.h"
#include "hwrenderer/utility/hw_cvars.h"
#include "texturemanager.h"
CVAR(Float, underwater_fade_scalar, 1.0f, CVAR_ARCHIVE) // [Nash] user-settable underwater blend intensity

View file

@ -59,6 +59,7 @@
#include "r_data/models/models.h"
#include "gl/renderer/gl_postprocessstate.h"
#include "gl/system/gl_buffers.h"
#include "texturemanager.h"
EXTERN_CVAR(Int, screenblocks)
EXTERN_CVAR(Bool, cl_capfps)

View file

@ -25,6 +25,7 @@
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
#include "hwrenderer/postprocessing/hw_postprocessshader.h"
#include <random>
#include "texturemanager.h"
Postprocess hw_postprocess;

View file

@ -33,6 +33,7 @@
#include "po_man.h"
#include "m_fixed.h"
#include "ctpl.h"
#include "texturemanager.h"
#include "hwrenderer/scene/hw_fakeflat.h"
#include "hwrenderer/scene/hw_clipper.h"
#include "hwrenderer/scene/hw_drawstructs.h"

View file

@ -37,6 +37,7 @@
#include "hwrenderer/utility/hw_clock.h"
#include "hwrenderer/data/flatvertices.h"
#include "hw_renderstate.h"
#include "texturemanager.h"
//==========================================================================
//

View file

@ -35,6 +35,7 @@
#include "hw_drawinfo.h"
#include "hwrenderer/utility/hw_cvars.h"
#include "r_utility.h"
#include "texturemanager.h"
static sector_t **fakesectorbuffer;

View file

@ -30,6 +30,7 @@
#include "r_sky.h"
#include "g_levellocals.h"
#include "a_dynlight.h"
#include "texturemanager.h"
#include "hw_drawinfo.h"
#include "hw_drawstructs.h"

View file

@ -27,6 +27,7 @@
#include "doomdata.h"
#include "g_levellocals.h"
#include "p_lnspec.h"
#include "texturemanager.h"
#include "hwrenderer/scene/hw_drawinfo.h"
#include "hwrenderer/scene/hw_drawstructs.h"
#include "hwrenderer/scene/hw_portal.h"

View file

@ -41,6 +41,7 @@
#include "matrix.h"
#include "r_data/models/models.h"
#include "vectors.h"
#include "texturemanager.h"
#include "hwrenderer/models/hw_models.h"
#include "hwrenderer/scene/hw_drawstructs.h"

View file

@ -30,6 +30,7 @@
#include "doomdata.h"
#include "g_levellocals.h"
#include "actorinlines.h"
#include "texturemanager.h"
#include "hwrenderer/dynlights/hw_dynlightdata.h"
#include "hwrenderer/textures/hw_material.h"
#include "hwrenderer/utility/hw_cvars.h"

View file

@ -34,6 +34,7 @@
#include "r_data/models/models.h"
#include "hw_weapon.h"
#include "hw_fakeflat.h"
#include "texturemanager.h"
#include "hwrenderer/models/hw_models.h"
#include "hwrenderer/dynlights/hw_dynlightdata.h"

View file

@ -29,6 +29,7 @@
#include "v_video.h"
#include "hw_ihwtexture.h"
#include "hw_material.h"
#include "texturemanager.h"
//===========================================================================
//
@ -493,3 +494,54 @@ FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translat
{
return ValidateTexture(TexMan.GetTexture(no, translate), expand, create);
}
//-----------------------------------------------------------------------------
//
// Make sprite offset adjustment user-configurable per renderer.
//
//-----------------------------------------------------------------------------
extern int r_spriteadjustSW, r_spriteadjustHW;
CUSTOM_CVAR(Int, r_spriteadjust, 2, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
{
r_spriteadjustHW = !!(self & 2);
r_spriteadjustSW = !!(self & 1);
for (int i = 0; i < TexMan.NumTextures(); i++)
{
auto tex = TexMan.GetTexture(FSetTextureID(i));
if (tex->GetTexelLeftOffset(0) != tex->GetTexelLeftOffset(1) || tex->GetTexelTopOffset(0) != tex->GetTexelTopOffset(1))
{
for (int i = 0; i < 2; i++)
{
auto mat = tex->GetMaterial(i);
if (mat != nullptr) mat->SetSpriteRect();
}
}
}
}
//==========================================================================
//
// this must be copied back to textures.cpp later.
//
//==========================================================================
FWrapperTexture::FWrapperTexture(int w, int h, int bits)
{
Width = w;
Height = h;
Format = bits;
UseType = ETextureType::SWCanvas;
bNoCompress = true;
auto hwtex = screen->CreateHardwareTexture();
// todo: Initialize here.
SystemTextures.AddHardwareTexture(0, false, hwtex);
}
void DeleteMaterial(FMaterial* mat)
{
delete mat;
}

View file

@ -7,8 +7,6 @@
#include "r_defs.h"
EXTERN_CVAR(Bool, gl_precache)
struct FRemapTable;
class FTextureShader;
class IHardwareTexture;

View file

@ -36,7 +36,9 @@
#include "image.h"
#include "v_video.h"
#include "v_font.h"
#include "texturemanager.h"
EXTERN_CVAR(Bool, gl_precache)
//==========================================================================
//
@ -238,14 +240,14 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
{
if (tex->GetImage() && tex->SystemTextures.GetHardwareTexture(0, false) == nullptr)
{
FImageSource::RegisterForPrecache(tex->GetImage());
FImageSource::RegisterForPrecache(tex->GetImage(), V_IsTrueColor());
}
}
// Only register untranslated sprites. Translated ones are very unlikely to require data that can be reused.
if (spritehitlist[i] != nullptr && (*spritehitlist[i]).CheckKey(0))
{
FImageSource::RegisterForPrecache(tex->GetImage());
FImageSource::RegisterForPrecache(tex->GetImage(), V_IsTrueColor());
}
}
}

View file

@ -2,6 +2,7 @@
#include "tarray.h"
#include "hwrenderer/textures/hw_ihwtexture.h"
#include "palettecontainer.h"
struct FTextureBuffer;
class IHardwareTexture;

View file

@ -27,6 +27,7 @@
#include "hw_cvars.h"
#include "hwrenderer/textures/hw_material.h"
#include "menu/menu.h"
#include "texturemanager.h"

View file

@ -38,6 +38,7 @@
#include "r_utility.h"
#include "v_text.h"
#include "g_levellocals.h"
#include "texturemanager.h"
//
// sky mapping

View file

@ -42,6 +42,7 @@
#include "v_palette.h"
#include "r_utility.h"
#include "r_data/colormaps.h"
#include "texturemanager.h"
#include "swrenderer/r_memory.h"
#include "swrenderer/scene/r_opaque_pass.h"
#include "swrenderer/scene/r_3dfloors.h"

View file

@ -38,6 +38,7 @@
#include "po_man.h"
#include "r_data/colormaps.h"
#include "d_net.h"
#include "texturemanager.h"
#include "swrenderer/r_memory.h"
#include "swrenderer/r_renderthread.h"
#include "swrenderer/drawers/r_draw.h"

View file

@ -35,6 +35,7 @@
#include "cmdlib.h"
#include "d_net.h"
#include "g_level.h"
#include "texturemanager.h"
#include "swrenderer/scene/r_opaque_pass.h"
#include "r_skyplane.h"
#include "swrenderer/scene/r_3dfloors.h"

View file

@ -37,6 +37,7 @@
#include "d_net.h"
#include "g_level.h"
#include "a_dynlight.h"
#include "texturemanager.h"
#include "swrenderer/r_memory.h"
#include "swrenderer/r_renderthread.h"
#include "swrenderer/scene/r_opaque_pass.h"

View file

@ -52,6 +52,7 @@
#include "g_levellocals.h"
#include "image.h"
#include "imagehelpers.h"
#include "texturemanager.h"
// [BB] Use ZDoom's freelook limit for the sotfware renderer.
// Note: ZDoom's limit is chosen such that the sky is rendered properly.
@ -95,7 +96,7 @@ void FSoftwareRenderer::PreparePrecache(FTexture *ttex, int cache)
}
else if (cache != 0)
{
FImageSource::RegisterForPrecache(ttex->GetImage());
FImageSource::RegisterForPrecache(ttex->GetImage(), V_IsTrueColor());
}
}
}

View file

@ -35,6 +35,7 @@
#include "swrenderer/scene/r_light.h"
#include "image.h"
#include "engineerrors.h"
#include "texturemanager.h"
// [RH] Base blending values (for e.g. underwater)
int BaseBlendR, BaseBlendG, BaseBlendB;

View file

@ -37,6 +37,7 @@
#include "engineerrors.h"
#include "p_lnspec.h"
#include "p_setup.h"
#include "texturemanager.h"
#include "swrenderer/drawers/r_draw.h"
#include "swrenderer/plane/r_visibleplane.h"

View file

@ -598,3 +598,8 @@ void FSoftwareTexture::FreeAllSpans()
}
}
void DeleteSoftwareTexture(FSoftwareTexture* swtex)
{
delete swtex;
}

View file

@ -32,7 +32,8 @@
**
*/
#include "textures/textures.h"
#include "textures.h"
#include "texturemanager.h"
template<class TYPE>
void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmul, int ymul, uint64_t time, float Speed, int warptype)

View file

@ -41,6 +41,7 @@
#include "swrenderer/drawers/r_draw.h"
#include "v_palette.h"
#include "r_data/colormaps.h"
#include "texturemanager.h"
#include "swrenderer/line/r_wallsetup.h"
#include "swrenderer/line/r_walldraw.h"
#include "swrenderer/segments/r_drawsegment.h"

View file

@ -29,6 +29,7 @@
#include "r_data/r_vanillatrans.h"
#include "actorinlines.h"
#include "i_time.h"
#include "texturemanager.h"
#include "swrenderer/r_memory.h"
#include "swrenderer/r_swcolormaps.h"
#include "swrenderer/viewport/r_viewport.h"

View file

@ -56,6 +56,7 @@
#include "p_local.h"
#include "p_maputl.h"
#include "r_voxel.h"
#include "texturemanager.h"
#include "swrenderer/segments/r_drawsegment.h"
#include "swrenderer/scene/r_portal.h"
#include "swrenderer/scene/r_scene.h"

View file

@ -50,6 +50,7 @@
#include "g_levellocals.h"
#include "v_video.h"
#include "utf8.h"
#include "texturemanager.h"
extern FRandom pr_exrandom;
FMemArena FxAlloc(65536);

View file

@ -48,6 +48,7 @@
#include "scopebarrier.h"
#include "types.h"
#include "vmintern.h"
#include "c_cvars.h"
#define CHECKRESOLVED() if (isresolved) return this; isresolved=true;

View file

@ -56,6 +56,7 @@
#include "types.h"
#include "a_dynlight.h"
#include "v_video.h"
#include "texturemanager.h"
//==========================================================================
//

View file

@ -3,6 +3,7 @@
#include "v_video.h"
#include "s_sound.h"
#include "r_state.h"
#include "texturemanager.h"
void JitCompiler::EmitMOVE()
{

View file

@ -38,6 +38,7 @@
#include "stats.h"
#include "vmintern.h"
#include "types.h"
#include "texturemanager.h"
extern cycle_t VMCycles[10];
extern int VMCalls[10];

View file

@ -57,6 +57,7 @@
#include "c_bind.h"
#include "c_dispatch.h"
#include "s_music.h"
#include "texturemanager.h"
DVector2 AM_GetPosition();
int Net_GetLatency(int *ld, int *ad);
@ -1912,6 +1913,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ReplaceTextures, ReplaceTextures)
return 0;
}
//=====================================================================================
//
// textures
//
//=====================================================================================
void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov);
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
@ -1924,6 +1931,177 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
return 0;
}
static int CheckForTexture(const FString& name, int type, int flags)
{
return TexMan.CheckForTexture(name, static_cast<ETextureType>(type), flags).GetIndex();
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckForTexture, CheckForTexture)
{
PARAM_PROLOGUE;
PARAM_STRING(name);
PARAM_INT(type);
PARAM_INT(flags);
ACTION_RETURN_INT(CheckForTexture(name, type, flags));
}
//==========================================================================
//
//
//
//==========================================================================
DEFINE_ACTION_FUNCTION(_TexMan, GetName)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
auto tex = TexMan.ByIndex(texid);
FString retval;
if (tex != nullptr)
{
if (tex->GetName().IsNotEmpty()) retval = tex->GetName();
else
{
// Textures for full path names do not have their own name, they merely link to the source lump.
auto lump = tex->GetSourceLump();
if (fileSystem.GetLinkedTexture(lump) == tex)
retval = fileSystem.GetFileFullName(lump);
}
}
ACTION_RETURN_STRING(retval);
}
//==========================================================================
//
//
//
//==========================================================================
static int GetTextureSize(int texid, int* py)
{
auto tex = TexMan.ByIndex(texid);
int x, y;
if (tex != nullptr)
{
x = tex->GetDisplayWidth();
y = tex->GetDisplayHeight();
}
else x = y = -1;
if (py) *py = y;
return x;
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
int x, y;
x = GetTextureSize(texid, &y);
if (numret > 0) ret[0].SetInt(x);
if (numret > 1) ret[1].SetInt(y);
return MIN(numret, 2);
}
//==========================================================================
//
//
//
//==========================================================================
static void GetScaledSize(int texid, DVector2* pvec)
{
auto tex = TexMan.ByIndex(texid);
double x, y;
if (tex != nullptr)
{
x = tex->GetDisplayWidthDouble();
y = tex->GetDisplayHeightDouble();
}
else x = y = -1;
if (pvec)
{
pvec->X = x;
pvec->Y = y;
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledSize, GetScaledSize)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
DVector2 vec;
GetScaledSize(texid, &vec);
ACTION_RETURN_VEC2(vec);
}
//==========================================================================
//
//
//
//==========================================================================
static void GetScaledOffset(int texid, DVector2* pvec)
{
auto tex = TexMan.ByIndex(texid);
double x, y;
if (tex != nullptr)
{
x = tex->GetDisplayLeftOffsetDouble();
y = tex->GetDisplayTopOffsetDouble();
}
else x = y = -1;
if (pvec)
{
pvec->X = x;
pvec->Y = y;
}
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetScaledOffset, GetScaledOffset)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
DVector2 vec;
GetScaledOffset(texid, &vec);
ACTION_RETURN_VEC2(vec);
}
//==========================================================================
//
//
//
//==========================================================================
static int CheckRealHeight(int texid)
{
auto tex = TexMan.ByIndex(texid);
if (tex != nullptr) return tex->CheckRealHeight();
else return -1;
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, CheckRealHeight, CheckRealHeight)
{
PARAM_PROLOGUE;
PARAM_INT(texid);
ACTION_RETURN_INT(CheckRealHeight(texid));
}
bool OkForLocalization(FTextureID texnum, const char* substitute);
static int OkForLocalization_(int index, const FString& substitute)
{
return OkForLocalization(FSetTextureID(index), substitute);
}
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, OkForLocalization, OkForLocalization_)
{
PARAM_PROLOGUE;
PARAM_INT(name);
PARAM_STRING(subst)
ACTION_RETURN_INT(OkForLocalization_(name, subst));
}
//=====================================================================================
//
@ -3447,7 +3625,6 @@ DEFINE_ACTION_FUNCTION(DObject, S_ChangeMusic)
}
//==========================================================================
//
//

Some files were not shown because too many files have changed in this diff Show more