mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-31 04:50:48 +00:00
Merge branch 'Texture_Cleanup'
# Conflicts: # src/textures/formats/multipatchtexture.cpp
This commit is contained in:
commit
1422a95aa8
188 changed files with 5938 additions and 5423 deletions
|
@ -681,6 +681,7 @@ file( GLOB HEADER_FILES
|
|||
sound/wildmidi/*.h
|
||||
xlat/*.h
|
||||
swrenderer/*.h
|
||||
swrenderer/textures/*.h
|
||||
swrenderer/drawers/*.h
|
||||
swrenderer/scene/*.h
|
||||
swrenderer/segments/*.h
|
||||
|
@ -1097,7 +1098,10 @@ set (PCH_SOURCES
|
|||
textures/anim_switches.cpp
|
||||
textures/bitmap.cpp
|
||||
textures/texture.cpp
|
||||
textures/image.cpp
|
||||
textures/imagetexture.cpp
|
||||
textures/texturemanager.cpp
|
||||
textures/multipatchtexturebuilder.cpp
|
||||
textures/skyboxtexture.cpp
|
||||
textures/formats/automaptexture.cpp
|
||||
textures/formats/brightmaptexture.cpp
|
||||
|
@ -1105,6 +1109,7 @@ set (PCH_SOURCES
|
|||
textures/formats/canvastexture.cpp
|
||||
textures/formats/ddstexture.cpp
|
||||
textures/formats/flattexture.cpp
|
||||
textures/formats/fontchars.cpp
|
||||
textures/formats/imgztexture.cpp
|
||||
textures/formats/jpegtexture.cpp
|
||||
textures/formats/md5check.cpp
|
||||
|
@ -1116,8 +1121,6 @@ set (PCH_SOURCES
|
|||
textures/formats/emptytexture.cpp
|
||||
textures/formats/shadertexture.cpp
|
||||
textures/formats/tgatexture.cpp
|
||||
textures/formats/worldtexture.cpp
|
||||
textures/formats/warptexture.cpp
|
||||
textures/hires/hqresize.cpp
|
||||
textures/hires/hirestex.cpp
|
||||
xlat/parse_xlat.cpp
|
||||
|
@ -1141,6 +1144,7 @@ set (PCH_SOURCES
|
|||
r_data/voxels.cpp
|
||||
r_data/renderinfo.cpp
|
||||
r_data/renderstyle.cpp
|
||||
r_data/r_canvastexture.cpp
|
||||
r_data/r_interpolate.cpp
|
||||
r_data/r_vanillatrans.cpp
|
||||
r_data/r_sections.cpp
|
||||
|
@ -1244,6 +1248,9 @@ set (PCH_SOURCES
|
|||
sound/wildmidi/reverb.cpp
|
||||
sound/wildmidi/wildmidi_lib.cpp
|
||||
sound/wildmidi/wm_error.cpp
|
||||
swrenderer/textures/r_swtexture.cpp
|
||||
swrenderer/textures/warptexture.cpp
|
||||
swrenderer/textures/swcanvastexture.cpp
|
||||
events.cpp
|
||||
)
|
||||
|
||||
|
|
|
@ -1194,12 +1194,12 @@ static void AM_ScrollParchment (double dmapx, double dmapy)
|
|||
|
||||
if (mapback.isValid())
|
||||
{
|
||||
FTexture *backtex = TexMan[mapback];
|
||||
FTexture *backtex = TexMan.GetTexture(mapback);
|
||||
|
||||
if (backtex != NULL)
|
||||
{
|
||||
int pwidth = backtex->GetWidth();
|
||||
int pheight = backtex->GetHeight();
|
||||
int pwidth = backtex->GetDisplayWidth();
|
||||
int pheight = backtex->GetDisplayHeight();
|
||||
|
||||
while(mapxstart > 0)
|
||||
mapxstart -= pwidth;
|
||||
|
@ -1689,11 +1689,11 @@ void AM_clearFB (const AMColor &color)
|
|||
}
|
||||
else
|
||||
{
|
||||
FTexture *backtex = TexMan[mapback];
|
||||
FTexture *backtex = TexMan.GetTexture(mapback);
|
||||
if (backtex != NULL)
|
||||
{
|
||||
int pwidth = backtex->GetWidth();
|
||||
int pheight = backtex->GetHeight();
|
||||
int pwidth = backtex->GetDisplayWidth();
|
||||
int pheight = backtex->GetDisplayHeight();
|
||||
int x, y;
|
||||
|
||||
//blit the automap background to the screen.
|
||||
|
@ -2212,8 +2212,7 @@ void AM_drawSubsectors()
|
|||
}
|
||||
|
||||
// Draw the polygon.
|
||||
FTexture *pic = TexMan(maptex);
|
||||
if (pic != nullptr && pic->UseType != ETextureType::Null)
|
||||
if (maptex.isValid())
|
||||
{
|
||||
// Hole filling "subsectors" are not necessarily convex so they require real triangulation.
|
||||
// These things are extremely rare so performance is secondary here.
|
||||
|
@ -2235,7 +2234,7 @@ void AM_drawSubsectors()
|
|||
}
|
||||
else indices.clear();
|
||||
|
||||
screen->FillSimplePoly(TexMan(maptex),
|
||||
screen->FillSimplePoly(TexMan.GetTexture(maptex, true),
|
||||
&points[0], points.Size(),
|
||||
originx, originy,
|
||||
scale / scalex,
|
||||
|
@ -3020,7 +3019,7 @@ void AM_drawThings ()
|
|||
rotation = int((angle.Normalized360() * (16. / 360.)).Degrees);
|
||||
|
||||
const FTextureID textureID = frame->Texture[show > 2 ? rotation : 0];
|
||||
texture = TexMan(textureID);
|
||||
texture = TexMan.GetTexture(textureID, true);
|
||||
}
|
||||
|
||||
if (texture == NULL) goto drawTriangle; // fall back to standard display if no sprite can be found.
|
||||
|
@ -3116,7 +3115,7 @@ void AM_drawThings ()
|
|||
static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
|
||||
INTBOOL flip, double xscale, double yscale, int translation, double alpha, uint32_t fillcolor, FRenderStyle renderstyle)
|
||||
{
|
||||
if (tex == NULL || tex->UseType == ETextureType::Null)
|
||||
if (tex == NULL || !tex->isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -3125,8 +3124,8 @@ static void DrawMarker (FTexture *tex, double x, double y, int yadjust,
|
|||
AM_rotatePoint (&x, &y);
|
||||
}
|
||||
screen->DrawTexture (tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y,
|
||||
DTA_DestWidthF, tex->GetScaledWidthDouble() * CleanXfac * xscale,
|
||||
DTA_DestHeightF, tex->GetScaledHeightDouble() * CleanYfac * yscale,
|
||||
DTA_DestWidthF, tex->GetDisplayWidthDouble() * CleanXfac * xscale,
|
||||
DTA_DestHeightF, tex->GetDisplayHeightDouble() * CleanYfac * yscale,
|
||||
DTA_ClipTop, f_y,
|
||||
DTA_ClipBottom, f_y + f_h,
|
||||
DTA_ClipLeft, f_x,
|
||||
|
@ -3151,7 +3150,7 @@ void AM_drawMarks ()
|
|||
{
|
||||
if (markpoints[i].x != -1)
|
||||
{
|
||||
DrawMarker (TexMan(marknums[i]), markpoints[i].x, markpoints[i].y, -3, 0,
|
||||
DrawMarker (TexMan.GetTexture(marknums[i], true), markpoints[i].x, markpoints[i].y, -3, 0,
|
||||
1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]);
|
||||
}
|
||||
}
|
||||
|
@ -3184,13 +3183,13 @@ void AM_drawAuthorMarkers ()
|
|||
|
||||
if (mark->picnum.isValid())
|
||||
{
|
||||
tex = TexMan(mark->picnum);
|
||||
if (tex->Rotations != 0xFFFF)
|
||||
tex = TexMan.GetTexture(mark->picnum, true);
|
||||
if (tex->GetRotations() != 0xFFFF)
|
||||
{
|
||||
spriteframe_t *sprframe = &SpriteFrames[tex->Rotations];
|
||||
spriteframe_t *sprframe = &SpriteFrames[tex->GetRotations()];
|
||||
picnum = sprframe->Texture[0];
|
||||
flip = sprframe->Flip & 1;
|
||||
tex = TexMan[picnum];
|
||||
tex = TexMan.GetTexture(picnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -3205,7 +3204,7 @@ void AM_drawAuthorMarkers ()
|
|||
spriteframe_t *sprframe = &SpriteFrames[sprdef->spriteframes + mark->frame];
|
||||
picnum = sprframe->Texture[0];
|
||||
flip = sprframe->Flip & 1;
|
||||
tex = TexMan[picnum];
|
||||
tex = TexMan.GetTexture(picnum);
|
||||
}
|
||||
}
|
||||
FActorIterator it (mark->args[0]);
|
||||
|
|
|
@ -1052,7 +1052,7 @@ CCMD(changesky)
|
|||
sky1name = argv[1];
|
||||
if (sky1name[0] != 0)
|
||||
{
|
||||
FTextureID newsky = TexMan.GetTexture(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
FTextureID newsky = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
if (newsky.Exists())
|
||||
{
|
||||
sky1texture = level.skytexture1 = newsky;
|
||||
|
|
|
@ -555,7 +555,7 @@ void C_InitConback()
|
|||
|
||||
if (!conback.isValid())
|
||||
{
|
||||
conback = TexMan.GetTexture (gameinfo.TitlePage, ETextureType::MiscPatch);
|
||||
conback = TexMan.GetTextureID (gameinfo.TitlePage, ETextureType::MiscPatch);
|
||||
conshade = MAKEARGB(175,0,0,0);
|
||||
conline = true;
|
||||
}
|
||||
|
@ -1083,7 +1083,7 @@ void C_DrawConsole ()
|
|||
else if (ConBottom)
|
||||
{
|
||||
int visheight;
|
||||
FTexture *conpic = TexMan[conback];
|
||||
FTexture *conpic = TexMan.GetTexture(conback);
|
||||
|
||||
visheight = ConBottom;
|
||||
|
||||
|
|
|
@ -223,8 +223,7 @@ DEFINE_FIELD_X(DehInfo, DehInfo, BlueAC)
|
|||
|
||||
TArray<PClassActor *> TouchedActors;
|
||||
|
||||
char *UnchangedSpriteNames;
|
||||
int NumUnchangedSprites;
|
||||
TArray<uint32_t> UnchangedSpriteNames;
|
||||
bool changedStates;
|
||||
|
||||
// Sprite<->Class map for DehackedPickup::DetermineType
|
||||
|
@ -395,17 +394,10 @@ static bool HandleKey (const struct Key *keys, void *structure, const char *key,
|
|||
|
||||
static int FindSprite (const char *sprname)
|
||||
{
|
||||
int i;
|
||||
uint32_t nameint = *((uint32_t *)sprname);
|
||||
|
||||
for (i = 0; i < NumUnchangedSprites; ++i)
|
||||
{
|
||||
if (*((uint32_t *)&UnchangedSpriteNames[i*4]) == nameint)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
uint32_t nameint;
|
||||
memcpy(&nameint, sprname, 4);
|
||||
auto f = UnchangedSpriteNames.Find(nameint);
|
||||
return f == UnchangedSpriteNames.Size() ? -1 : f;
|
||||
}
|
||||
|
||||
static FState *FindState (int statenum)
|
||||
|
@ -2665,31 +2657,16 @@ static void UnloadDehSupp ()
|
|||
// that was altered by the first. So we need to keep the
|
||||
// StateMap around until all patches have been applied.
|
||||
DehUseCount = 0;
|
||||
Actions.Clear();
|
||||
Actions.ShrinkToFit();
|
||||
OrgHeights.Clear();
|
||||
OrgHeights.ShrinkToFit();
|
||||
CodePConv.Clear();
|
||||
CodePConv.ShrinkToFit();
|
||||
OrgSprNames.Clear();
|
||||
OrgSprNames.ShrinkToFit();
|
||||
SoundMap.Clear();
|
||||
SoundMap.ShrinkToFit();
|
||||
InfoNames.Clear();
|
||||
InfoNames.ShrinkToFit();
|
||||
BitNames.Clear();
|
||||
BitNames.ShrinkToFit();
|
||||
StyleNames.Clear();
|
||||
StyleNames.ShrinkToFit();
|
||||
AmmoNames.Clear();
|
||||
AmmoNames.ShrinkToFit();
|
||||
|
||||
if (UnchangedSpriteNames != NULL)
|
||||
{
|
||||
delete[] UnchangedSpriteNames;
|
||||
UnchangedSpriteNames = NULL;
|
||||
NumUnchangedSprites = 0;
|
||||
}
|
||||
Actions.Reset();
|
||||
OrgHeights.Reset();
|
||||
CodePConv.Reset();
|
||||
OrgSprNames.Reset();
|
||||
SoundMap.Reset();
|
||||
InfoNames.Reset();
|
||||
BitNames.Reset();
|
||||
StyleNames.Reset();
|
||||
AmmoNames.Reset();
|
||||
UnchangedSpriteNames.Reset();
|
||||
if (EnglishStrings != NULL)
|
||||
{
|
||||
delete EnglishStrings;
|
||||
|
@ -2717,7 +2694,6 @@ static bool LoadDehSupp ()
|
|||
return false;
|
||||
}
|
||||
bool gotnames = false;
|
||||
int i;
|
||||
|
||||
|
||||
if (++DehUseCount > 1)
|
||||
|
@ -2731,14 +2707,11 @@ static bool LoadDehSupp ()
|
|||
EnglishStrings->LoadStrings (true);
|
||||
}
|
||||
|
||||
if (UnchangedSpriteNames == NULL)
|
||||
|
||||
UnchangedSpriteNames.Resize(sprites.Size());
|
||||
for (unsigned i = 0; i < UnchangedSpriteNames.Size(); ++i)
|
||||
{
|
||||
UnchangedSpriteNames = new char[sprites.Size()*4];
|
||||
NumUnchangedSprites = sprites.Size();
|
||||
for (i = 0; i < NumUnchangedSprites; ++i)
|
||||
{
|
||||
memcpy (UnchangedSpriteNames+i*4, &sprites[i].name, 4);
|
||||
}
|
||||
memcpy (&UnchangedSpriteNames[i], &sprites[i].name, 4);
|
||||
}
|
||||
|
||||
FScanner sc;
|
||||
|
|
|
@ -184,18 +184,19 @@ CVAR (Int, snd_drawoutput, 0, 0);
|
|||
CUSTOM_CVAR (String, vid_cursor, "None", CVAR_ARCHIVE | CVAR_NOINITCALL)
|
||||
{
|
||||
bool res = false;
|
||||
|
||||
|
||||
if (!stricmp(self, "None" ) && gameinfo.CursorPic.IsNotEmpty())
|
||||
{
|
||||
res = I_SetCursor(TexMan[gameinfo.CursorPic]);
|
||||
res = I_SetCursor(TexMan.GetTextureByName(gameinfo.CursorPic));
|
||||
}
|
||||
else
|
||||
{
|
||||
res = I_SetCursor(TexMan[self]);
|
||||
res = I_SetCursor(TexMan.GetTextureByName(self));
|
||||
}
|
||||
if (!res)
|
||||
{
|
||||
I_SetCursor(TexMan["cursor"]);
|
||||
I_SetCursor(TexMan.GetTextureByName("cursor"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -834,16 +835,16 @@ void D_Display ()
|
|||
int x;
|
||||
FString pstring = "By ";
|
||||
|
||||
tex = TexMan(gameinfo.PauseSign);
|
||||
x = (SCREENWIDTH - tex->GetScaledWidth() * CleanXfac)/2 +
|
||||
tex->GetScaledLeftOffset(0) * CleanXfac;
|
||||
tex = TexMan.GetTextureByName(gameinfo.PauseSign, true);
|
||||
x = (SCREENWIDTH - tex->GetDisplayWidth() * CleanXfac)/2 +
|
||||
tex->GetDisplayLeftOffset() * CleanXfac;
|
||||
screen->DrawTexture (tex, x, 4, DTA_CleanNoMove, true, TAG_DONE);
|
||||
if (paused && multiplayer)
|
||||
{
|
||||
pstring += players[paused - 1].userinfo.GetName();
|
||||
screen->DrawText(SmallFont, CR_RED,
|
||||
(screen->GetWidth() - SmallFont->StringWidth(pstring)*CleanXfac) / 2,
|
||||
(tex->GetScaledHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE);
|
||||
(tex->GetDisplayHeight() * CleanYfac) + 4, pstring, DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -855,8 +856,8 @@ void D_Display ()
|
|||
D_DrawIcon = NULL;
|
||||
if (picnum.isValid())
|
||||
{
|
||||
FTexture *tex = TexMan[picnum];
|
||||
screen->DrawTexture (tex, 160 - tex->GetScaledWidth()/2, 100 - tex->GetScaledHeight()/2,
|
||||
FTexture *tex = TexMan.GetTexture(picnum);
|
||||
screen->DrawTexture (tex, 160 - tex->GetDisplayWidth()/2, 100 - tex->GetDisplayHeight()/2,
|
||||
DTA_320x200, true, TAG_DONE);
|
||||
}
|
||||
NoWipe = 10;
|
||||
|
@ -1051,7 +1052,7 @@ void D_PageDrawer (void)
|
|||
screen->Clear(0, 0, SCREENWIDTH, SCREENHEIGHT, 0, 0);
|
||||
if (Page.Exists())
|
||||
{
|
||||
screen->DrawTexture (TexMan(Page), 0, 0,
|
||||
screen->DrawTexture (TexMan.GetTexture(Page, true), 0, 0,
|
||||
DTA_Fullscreen, true,
|
||||
DTA_Masked, false,
|
||||
DTA_BilinearFilter, true,
|
||||
|
@ -1241,7 +1242,7 @@ void D_DoAdvanceDemo (void)
|
|||
case 3:
|
||||
if (gameinfo.advisoryTime)
|
||||
{
|
||||
Advisory = TexMan["ADVISOR"];
|
||||
Advisory = TexMan.GetTextureByName("ADVISOR");
|
||||
demosequence = 1;
|
||||
pagetic = (int)(gameinfo.advisoryTime * TICRATE);
|
||||
break;
|
||||
|
@ -2708,7 +2709,7 @@ void D_DoomMain (void)
|
|||
DestroyCVarsFlagged(CVAR_MOD); // Delete any cvar left by mods
|
||||
FS_Close(); // destroy the global FraggleScript.
|
||||
DeinitMenus();
|
||||
LightDefaults.Clear(); // this can leak heap memory if it isn't cleared.
|
||||
LightDefaults.DeleteAndClear(); // this can leak heap memory if it isn't cleared.
|
||||
|
||||
// delete DoomStartupInfo data
|
||||
DoomStartupInfo.Name = (const char*)0;
|
||||
|
|
|
@ -322,7 +322,6 @@ static void MarkRoot()
|
|||
M_MarkMenus();
|
||||
Mark(DIntermissionController::CurrentIntermission);
|
||||
DThinker::MarkRoots();
|
||||
FCanvasTextureInfo::Mark();
|
||||
Mark(E_FirstEventHandler);
|
||||
Mark(E_LastEventHandler);
|
||||
level.Mark();
|
||||
|
|
|
@ -41,10 +41,13 @@ public:
|
|||
Height = h;
|
||||
}
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) override
|
||||
FBitmap GetBgraBitmap(PalEntry*, int *trans) override
|
||||
{
|
||||
bmp->CopyPixelDataRGB(x, y, (uint8_t*)WorkBuffer.Data(), Width, Height, 4, Width*4, rotate, CF_RGBA, inf);
|
||||
return 0;
|
||||
FBitmap bmp;
|
||||
bmp.Create(Width, Height);
|
||||
bmp.CopyPixelDataRGB(0, 0, (uint8_t*)WorkBuffer.Data(), Width, Height, 4, Width*4, 0, CF_RGBA, nullptr);
|
||||
if (trans) *trans = 0;
|
||||
return bmp;
|
||||
}
|
||||
|
||||
uint32_t *GetBuffer()
|
||||
|
@ -304,8 +307,8 @@ bool Wiper_Melt::Run(int ticks)
|
|||
// Only draw for the final tick.
|
||||
// No need for optimization. Wipes won't ever be drawn with anything else.
|
||||
|
||||
int w = startScreen->GetWidth();
|
||||
int h = startScreen->GetHeight();
|
||||
int w = startScreen->GetDisplayWidth();
|
||||
int h = startScreen->GetDisplayHeight();
|
||||
dpt.x = i * w / WIDTH;
|
||||
dpt.y = MAX(0, y[i] * h / HEIGHT);
|
||||
rect.left = dpt.x;
|
||||
|
@ -369,9 +372,8 @@ bool Wiper_Burn::Run(int ticks)
|
|||
Density = wipe_CalcBurn(BurnArray, WIDTH, HEIGHT, Density);
|
||||
done = (Density < 0);
|
||||
}
|
||||
|
||||
auto mat = FMaterial::ValidateTexture(BurnTexture, false);
|
||||
mat->Clean(true);
|
||||
|
||||
BurnTexture->SystemTextures.Clean(true, true);
|
||||
const uint8_t *src = BurnArray;
|
||||
uint32_t *dest = (uint32_t *)BurnTexture->GetBuffer();
|
||||
for (int y = HEIGHT; y != 0; --y)
|
||||
|
|
|
@ -1892,7 +1892,7 @@ void FParser::SF_FloorTexture(void)
|
|||
if(t_argc > 1)
|
||||
{
|
||||
int i = -1;
|
||||
FTextureID picnum = TexMan.GetTexture(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
|
@ -1903,8 +1903,8 @@ void FParser::SF_FloorTexture(void)
|
|||
}
|
||||
|
||||
t_return.type = svt_string;
|
||||
FTexture * tex = TexMan[sector->GetTexture(sector_t::floor)];
|
||||
t_return.string = tex? tex->Name : "";
|
||||
FTexture * tex = TexMan.GetTexture(sector->GetTexture(sector_t::floor));
|
||||
t_return.string = tex? tex->GetName() : "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1982,7 +1982,7 @@ void FParser::SF_CeilingTexture(void)
|
|||
if(t_argc > 1)
|
||||
{
|
||||
int i = -1;
|
||||
FTextureID picnum = TexMan.GetTexture(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
// set all sectors with tag
|
||||
FSSectorTagIterator itr(tagnum);
|
||||
|
@ -1993,8 +1993,8 @@ void FParser::SF_CeilingTexture(void)
|
|||
}
|
||||
|
||||
t_return.type = svt_string;
|
||||
FTexture * tex = TexMan[sector->GetTexture(sector_t::ceiling)];
|
||||
t_return.string = tex? tex->Name : "";
|
||||
FTexture * tex = TexMan.GetTexture(sector->GetTexture(sector_t::ceiling));
|
||||
t_return.string = tex? tex->GetName() : "";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2235,7 +2235,7 @@ void FParser::SF_SetLineTexture(void)
|
|||
position=3-position;
|
||||
|
||||
texture = stringvalue(t_argv[3]);
|
||||
texturenum = TexMan.GetTexture(texture, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
texturenum = TexMan.GetTextureID(texture, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
FLineIdIterator itr(tag);
|
||||
while ((i = itr.Next()) >= 0)
|
||||
|
@ -2252,7 +2252,7 @@ void FParser::SF_SetLineTexture(void)
|
|||
}
|
||||
else // and an improved legacy version
|
||||
{
|
||||
FTextureID picnum = TexMan.GetTexture(t_argv[1].string, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
FTextureID picnum = TexMan.GetTextureID(t_argv[1].string, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
side = !!intvalue(t_argv[2]);
|
||||
int sections = intvalue(t_argv[3]);
|
||||
|
||||
|
@ -2453,7 +2453,7 @@ void FParser::SF_PlayerKeys(void)
|
|||
else
|
||||
{
|
||||
givetake = intvalue(t_argv[2]);
|
||||
ScriptUtil::Exec(givetake?NAME_GiveInventory : NAME_TakeInventory, players[playernum].mo, keyname.GetIndex(), 1);
|
||||
ScriptUtil::Exec(givetake?NAME_GiveInventory : NAME_TakeInventory, ScriptUtil::Pointer, players[playernum].mo, ScriptUtil::Int, keyname.GetIndex(), ScriptUtil::Int, 1, ScriptUtil::End);
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = 0;
|
||||
}
|
||||
|
@ -2648,7 +2648,7 @@ void FParser::SF_GiveInventory(void)
|
|||
|
||||
if(t_argc == 2) count=1;
|
||||
else count=intvalue(t_argv[2]);
|
||||
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, players[playernum].mo, FName(stringvalue(t_argv[1])).GetIndex(), count);
|
||||
ScriptUtil::Exec(NAME_GiveInventory, ScriptUtil::Pointer, players[playernum].mo, ScriptUtil::Int, FName(stringvalue(t_argv[1])).GetIndex(), ScriptUtil::Int, count, ScriptUtil::End);
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = 0;
|
||||
}
|
||||
|
@ -2671,7 +2671,7 @@ void FParser::SF_TakeInventory(void)
|
|||
|
||||
if(t_argc == 2) count=32767;
|
||||
else count=intvalue(t_argv[2]);
|
||||
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, players[playernum].mo, FName(stringvalue(t_argv[1])).GetIndex(), count);
|
||||
ScriptUtil::Exec(NAME_TakeInventory, ScriptUtil::Pointer, players[playernum].mo, ScriptUtil::Int, FName(stringvalue(t_argv[1])).GetIndex(), ScriptUtil::Int, count, ScriptUtil::End);
|
||||
t_return.type = svt_int;
|
||||
t_return.value.i = 0;
|
||||
}
|
||||
|
|
|
@ -189,7 +189,7 @@ void FScriptLoader::ParseInfoCmd(char *line, FString &scriptsrc)
|
|||
sc.MustGetStringName("=");
|
||||
sc.MustGetString();
|
||||
|
||||
sky2texture = sky1texture = level.skytexture1 = level.skytexture2 = TexMan.GetTexture (sc.String, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
sky2texture = sky1texture = level.skytexture1 = level.skytexture2 = TexMan.GetTextureID (sc.String, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
R_InitSkyMap ();
|
||||
}
|
||||
else if (sc.Compare("interpic"))
|
||||
|
|
|
@ -969,7 +969,7 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame)
|
|||
// a flat. The data is in the WAD only because
|
||||
// we look for an actual index, instead of simply
|
||||
// setting one.
|
||||
skyflatnum = TexMan.GetTexture (gameinfo.SkyFlatName, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
skyflatnum = TexMan.GetTextureID (gameinfo.SkyFlatName, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
// DOOM determines the sky texture to be used
|
||||
// depending on the current episode and the game version.
|
||||
|
@ -1456,8 +1456,8 @@ void G_InitLevelLocals ()
|
|||
level.info = info;
|
||||
level.skyspeed1 = info->skyspeed1;
|
||||
level.skyspeed2 = info->skyspeed2;
|
||||
level.skytexture1 = TexMan.GetTexture(info->SkyPic1, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
level.skytexture2 = TexMan.GetTexture(info->SkyPic2, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
level.skytexture1 = TexMan.GetTextureID(info->SkyPic1, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
level.skytexture2 = TexMan.GetTextureID(info->SkyPic2, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_ReturnFirst);
|
||||
level.fadeto = info->fadeto;
|
||||
level.cdtrack = info->cdtrack;
|
||||
level.cdid = info->cdid;
|
||||
|
@ -1960,6 +1960,7 @@ void FLevelLocals::Tick ()
|
|||
|
||||
void FLevelLocals::Mark()
|
||||
{
|
||||
canvasTextureInfo.Mark();
|
||||
for (auto &s : sectorPortals)
|
||||
{
|
||||
GC::Mark(s.mSkybox);
|
||||
|
|
|
@ -247,6 +247,7 @@ enum ELevelFlags : unsigned int
|
|||
LEVEL3_NOCOLOREDSPRITELIGHTING = 0x00000010, // draw sprites only with color-less light
|
||||
LEVEL3_EXITNORMALUSED = 0x00000020,
|
||||
LEVEL3_EXITSECRETUSED = 0x00000040,
|
||||
LEVEL3_FORCEWORLDPANNING = 0x00000080, // Forces the world panning flag for all textures, even those without it explicitly set.
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "p_local.h"
|
||||
#include "p_destructible.h"
|
||||
#include "r_data/r_sections.h"
|
||||
#include "r_data/r_canvastexture.h"
|
||||
|
||||
struct FLevelLocals
|
||||
{
|
||||
|
@ -103,6 +104,7 @@ struct FLevelLocals
|
|||
TArray<FSectorPortalGroup *> portalGroups;
|
||||
TArray<FLinePortalSpan> linePortalSpans;
|
||||
FSectionContainer sections;
|
||||
FCanvasTextureInfo canvasTextureInfo;
|
||||
|
||||
int NumMapSections;
|
||||
|
||||
|
|
|
@ -1553,6 +1553,7 @@ MapFlagHandlers[] =
|
|||
{ "forcefakecontrast", MITYPE_SETFLAG3, LEVEL3_FORCEFAKECONTRAST, 0 },
|
||||
{ "nolightfade", MITYPE_SETFLAG3, LEVEL3_NOLIGHTFADE, 0 },
|
||||
{ "nocoloredspritelighting", MITYPE_SETFLAG3, LEVEL3_NOCOLOREDSPRITELIGHTING, 0 },
|
||||
{ "forceworldpanning", MITYPE_SETFLAG3, LEVEL3_FORCEWORLDPANNING, 0 },
|
||||
{ "nobotnodes", MITYPE_IGNORE, 0, 0 }, // Skulltag option: nobotnodes
|
||||
{ "compat_shorttex", MITYPE_COMPATFLAG, COMPATF_SHORTTEX, 0 },
|
||||
{ "compat_stairs", MITYPE_COMPATFLAG, COMPATF_STAIRINDEX, 0 },
|
||||
|
|
|
@ -262,9 +262,9 @@ FTextureID DBaseDecal::StickToWall (side_t *wall, double x, double y, F3DFloor *
|
|||
else return FNullTextureID();
|
||||
CalcFracPos (wall, x, y);
|
||||
|
||||
FTexture *texture = TexMan[tex];
|
||||
FTexture *texture = TexMan.GetTexture(tex);
|
||||
|
||||
if (texture == NULL || texture->bNoDecals)
|
||||
if (texture == NULL || texture->allowNoDecals())
|
||||
{
|
||||
return FNullTextureID();
|
||||
}
|
||||
|
@ -492,15 +492,15 @@ void DBaseDecal::Spread (const FDecalTemplate *tpl, side_t *wall, double x, doub
|
|||
GetWallStuff (wall, v1, ldx, ldy);
|
||||
rorg = Length (x - v1->fX(), y - v1->fY());
|
||||
|
||||
if ((tex = TexMan[PicNum]) == NULL)
|
||||
if ((tex = TexMan.GetTexture(PicNum)) == NULL)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int dwidth = tex->GetWidth ();
|
||||
int dwidth = tex->GetDisplayWidth ();
|
||||
|
||||
DecalWidth = dwidth * ScaleX;
|
||||
DecalLeft = tex->GetLeftOffset(0) * ScaleX;
|
||||
DecalLeft = tex->GetDisplayLeftOffset() * ScaleX;
|
||||
DecalRight = DecalWidth - DecalLeft;
|
||||
SpreadSource = this;
|
||||
SpreadTemplate = tpl;
|
||||
|
|
|
@ -937,7 +937,7 @@ CCMD(listlights)
|
|||
if (dl->target)
|
||||
{
|
||||
FTextureID spr = sprites[dl->target->sprite].GetSpriteFrame(dl->target->frame, 0, 0., nullptr);
|
||||
Printf(", frame = %s ", TexMan[spr]->Name.GetChars());
|
||||
Printf(", frame = %s ", TexMan.GetTexture(spr)->GetName().GetChars());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
}
|
||||
|
||||
protected:
|
||||
FName m_Name;
|
||||
FName m_Name = NAME_None;
|
||||
int m_Args[5] = { 0,0,0,0,0 };
|
||||
double m_Param = 0;
|
||||
DVector3 m_Pos = { 0,0,0 };
|
||||
|
|
|
@ -96,7 +96,7 @@ FTexture *FMugShotFrame::GetTexture(const char *default_face, const char *skin_f
|
|||
}
|
||||
sprite.UnlockBuffer();
|
||||
}
|
||||
return TexMan[TexMan.CheckForTexture(sprite, ETextureType::Any, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_AllowSkins)];
|
||||
return TexMan.GetTexture(TexMan.CheckForTexture(sprite, ETextureType::Any, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_AllowSkins));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -1188,12 +1188,11 @@ public:
|
|||
|
||||
if((offsetflags & SBarInfoCommand::CENTER) == SBarInfoCommand::CENTER)
|
||||
{
|
||||
if (forceWidth < 0) dx -= (texture->GetScaledWidthDouble()/2.0)-texture->GetScaledLeftOffsetDouble(0);
|
||||
else dx -= forceWidth*(0.5-(texture->GetScaledLeftOffsetDouble(0)/texture->GetScaledWidthDouble()));
|
||||
//Unoptimalized ^^formula is dx -= forceWidth/2.0-(texture->GetScaledLeftOffsetDouble()*forceWidth/texture->GetScaledWidthDouble());
|
||||
if (forceWidth < 0) dx -= (texture->GetDisplayWidthDouble()/2.0)-texture->GetDisplayLeftOffsetDouble();
|
||||
else dx -= forceWidth*(0.5-(texture->GetDisplayLeftOffsetDouble()/texture->GetDisplayWidthDouble()));
|
||||
|
||||
if (forceHeight < 0) dy -= (texture->GetScaledHeightDouble()/2.0)-texture->GetScaledTopOffsetDouble(0);
|
||||
else dy -= forceHeight*(0.5-(texture->GetScaledTopOffsetDouble(0)/texture->GetScaledHeightDouble()));
|
||||
if (forceHeight < 0) dy -= (texture->GetDisplayHeightDouble()/2.0)-texture->GetDisplayTopOffsetDouble();
|
||||
else dy -= forceHeight*(0.5-(texture->GetDisplayTopOffsetDouble()/texture->GetDisplayHeightDouble()));
|
||||
}
|
||||
|
||||
dx += xOffset;
|
||||
|
@ -1202,12 +1201,12 @@ public:
|
|||
if(!fullScreenOffsets)
|
||||
{
|
||||
double tmp = 0;
|
||||
w = forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth;
|
||||
h = forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight;
|
||||
double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetScaledLeftOffsetDouble(0);
|
||||
double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetScaledTopOffsetDouble(0);
|
||||
double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetScaledLeftOffsetDouble(0);
|
||||
double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetScaledTopOffsetDouble(0);
|
||||
w = forceWidth < 0 ? texture->GetDisplayWidthDouble() : forceWidth;
|
||||
h = forceHeight < 0 ? texture->GetDisplayHeightDouble() : forceHeight;
|
||||
double dcx = clip[0] == 0 ? 0 : dx + clip[0] - texture->GetDisplayLeftOffsetDouble();
|
||||
double dcy = clip[1] == 0 ? 0 : dy + clip[1] - texture->GetDisplayTopOffsetDouble();
|
||||
double dcr = clip[2] == 0 ? INT_MAX : dx + w - clip[2] - texture->GetDisplayLeftOffsetDouble();
|
||||
double dcb = clip[3] == 0 ? INT_MAX : dy + h - clip[3] - texture->GetDisplayTopOffsetDouble();
|
||||
|
||||
if(clip[0] != 0 || clip[1] != 0)
|
||||
{
|
||||
|
@ -1271,8 +1270,8 @@ public:
|
|||
bool xright = *x < 0 && !x.RelCenter();
|
||||
bool ybot = *y < 0 && !y.RelCenter();
|
||||
|
||||
w = (forceWidth < 0 ? texture->GetScaledWidthDouble() : forceWidth);
|
||||
h = (forceHeight < 0 ? texture->GetScaledHeightDouble() : forceHeight);
|
||||
w = (forceWidth < 0 ? texture->GetDisplayWidthDouble() : forceWidth);
|
||||
h = (forceHeight < 0 ? texture->GetDisplayHeightDouble() : forceHeight);
|
||||
if(vid_fps && rx < 0 && ry >= 0)
|
||||
ry += 10;
|
||||
|
||||
|
@ -1289,10 +1288,10 @@ public:
|
|||
// Check for clipping
|
||||
if(clip[0] != 0 || clip[1] != 0 || clip[2] != 0 || clip[3] != 0)
|
||||
{
|
||||
rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetScaledLeftOffsetDouble(0))*Scale.X);
|
||||
rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetScaledTopOffsetDouble(0))*Scale.Y);
|
||||
rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetScaledLeftOffsetDouble(0))*Scale.X);
|
||||
rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetScaledTopOffsetDouble(0))*Scale.Y);
|
||||
rcx = clip[0] == 0 ? 0 : rx+((clip[0] - texture->GetDisplayLeftOffsetDouble())*Scale.X);
|
||||
rcy = clip[1] == 0 ? 0 : ry+((clip[1] - texture->GetDisplayTopOffsetDouble())*Scale.Y);
|
||||
rcr = clip[2] == 0 ? INT_MAX : rx+w-((clip[2] + texture->GetDisplayLeftOffsetDouble())*Scale.X);
|
||||
rcb = clip[3] == 0 ? INT_MAX : ry+h-((clip[3] + texture->GetDisplayTopOffsetDouble())*Scale.Y);
|
||||
}
|
||||
|
||||
if(clearDontDraw)
|
||||
|
@ -1380,7 +1379,8 @@ public:
|
|||
width = font->GetCharWidth((unsigned char) *str);
|
||||
else
|
||||
width = font->GetCharWidth((unsigned char) script->spacingCharacter);
|
||||
FTexture* c = font->GetChar((unsigned char) *str, &width);
|
||||
bool redirected = false;
|
||||
FTexture* c = font->GetChar((unsigned char) *str, fontcolor, &width);
|
||||
if(c == NULL) //missing character.
|
||||
{
|
||||
str++;
|
||||
|
@ -1389,13 +1389,13 @@ public:
|
|||
int character = (unsigned char)*str;
|
||||
|
||||
if (script->spacingCharacter == '\0') //If we are monospaced lets use the offset
|
||||
ax += (c->GetLeftOffset(0) + 1); //ignore x offsets since we adapt to character size
|
||||
ax += (c->GetDisplayLeftOffset() + 1); //ignore x offsets since we adapt to character size
|
||||
|
||||
double rx, ry, rw, rh;
|
||||
rx = ax + xOffset;
|
||||
ry = ay + yOffset;
|
||||
rw = c->GetScaledWidthDouble();
|
||||
rh = c->GetScaledHeightDouble();
|
||||
rw = c->GetDisplayWidthDouble();
|
||||
rh = c->GetDisplayHeightDouble();
|
||||
|
||||
if(script->spacingCharacter != '\0')
|
||||
{
|
||||
|
@ -1453,7 +1453,7 @@ public:
|
|||
DTA_Alpha, Alpha,
|
||||
TAG_DONE);
|
||||
if (script->spacingCharacter == '\0')
|
||||
ax += width + spacing - (c->GetLeftOffset(0) + 1);
|
||||
ax += width + spacing - (c->GetDisplayLeftOffsetDouble() + 1);
|
||||
else //width gets changed at the call to GetChar()
|
||||
ax += font->GetCharWidth((unsigned char) script->spacingCharacter) + spacing;
|
||||
str++;
|
||||
|
|
|
@ -69,8 +69,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
{
|
||||
double scale1, scale2;
|
||||
scale1 = scale2 = 1.0f;
|
||||
double texwidth = (int) (texture->GetScaledWidthDouble()*spawnScaleX);
|
||||
double texheight = (int) (texture->GetScaledHeightDouble()*spawnScaleY);
|
||||
double texwidth = (int) (texture->GetDisplayWidthDouble()*spawnScaleX);
|
||||
double texheight = (int) (texture->GetDisplayHeightDouble()*spawnScaleY);
|
||||
|
||||
if (w != -1 && (w<texwidth || (flags & DI_FORCESCALE)))
|
||||
{
|
||||
|
@ -93,8 +93,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
}
|
||||
else if (applyscale)
|
||||
{
|
||||
w=(int) (texture->GetScaledWidthDouble()*spawnScaleX);
|
||||
h=(int) (texture->GetScaledHeightDouble()*spawnScaleY);
|
||||
w=(int) (texture->GetDisplayWidthDouble()*spawnScaleX);
|
||||
h=(int) (texture->GetDisplayHeightDouble()*spawnScaleY);
|
||||
}
|
||||
statusBar->DrawGraphic(texture, imgx, imgy, block->XOffset(), block->YOffset(), frameAlpha, block->FullScreenOffsets(),
|
||||
translatable, false, offset, false, w, h);
|
||||
|
@ -241,7 +241,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
applyscale = false;
|
||||
}
|
||||
if(type == PLAYERICON)
|
||||
texture = TexMan(statusBar->CPlayer->mo->ScoreIcon);
|
||||
texture = TexMan.GetTexture(statusBar->CPlayer->mo->ScoreIcon, true);
|
||||
else if(type == AMMO1)
|
||||
{
|
||||
auto ammo = statusBar->ammo1;
|
||||
|
@ -270,7 +270,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
{
|
||||
auto item = statusBar->CPlayer->mo->FindInventory(NAME_Sigil);
|
||||
if (item != NULL)
|
||||
texture = TexMan(item->TextureIDVar(NAME_Icon));
|
||||
texture = TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true);
|
||||
}
|
||||
else if(type == HEXENARMOR_ARMOR || type == HEXENARMOR_SHIELD || type == HEXENARMOR_HELM || type == HEXENARMOR_AMULET)
|
||||
{
|
||||
|
@ -292,15 +292,15 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
}
|
||||
}
|
||||
else if(type == INVENTORYICON)
|
||||
texture = TexMan(sprite);
|
||||
texture = TexMan.GetTexture(sprite, true);
|
||||
else if(type == SELECTEDINVENTORYICON && statusBar->CPlayer->mo->InvSel != NULL)
|
||||
texture = TexMan(statusBar->CPlayer->mo->InvSel->TextureIDVar(NAME_Icon));
|
||||
texture = TexMan.GetTexture(statusBar->CPlayer->mo->InvSel->TextureIDVar(NAME_Icon), true);
|
||||
else if(image >= 0)
|
||||
texture = statusBar->Images[image];
|
||||
|
||||
if (flags & DI_ALTERNATEONFAIL)
|
||||
{
|
||||
SetTruth(texture == NULL || texture->UseType == ETextureType::Null, block, statusBar);
|
||||
SetTruth(texture == NULL || !texture->isValid(), block, statusBar);
|
||||
}
|
||||
}
|
||||
protected:
|
||||
|
@ -316,7 +316,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl
|
|||
spawnScaleY = item->Scale.Y;
|
||||
}
|
||||
|
||||
texture = TexMan(icon);
|
||||
texture = TexMan.GetTexture(icon, true);
|
||||
}
|
||||
|
||||
enum ImageType
|
||||
|
@ -2131,7 +2131,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
|||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgARTIBOX], rx, ry, block->XOffset(), block->YOffset(), bgalpha, block->FullScreenOffsets());
|
||||
|
||||
if(style != STYLE_Strife) //Strife draws the cursor before the icons
|
||||
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), rx - (style == STYLE_HexenStrict ? 2 : 0), ry - (style == STYLE_HexenStrict ? 1 : 0), block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||
if(item == statusBar->CPlayer->mo->InvSel)
|
||||
{
|
||||
if(style == STYLE_Heretic)
|
||||
|
@ -2146,7 +2146,7 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
|||
statusBar->DrawGraphic(statusBar->Images[statusBar->invBarOffset + imgSELECTBOX], rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
}
|
||||
if(style == STYLE_Strife)
|
||||
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), rx, ry, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, item->IntVar(NAME_Amount) <= 0);
|
||||
if(counters != NULL && (alwaysShowCounter || item->IntVar(NAME_Amount) != 1))
|
||||
{
|
||||
counters[i]->valueArgument = item->IntVar(NAME_Amount);
|
||||
|
@ -2266,11 +2266,11 @@ class CommandDrawInventoryBar : public SBarInfoCommand
|
|||
int spacing;
|
||||
if (!vertical)
|
||||
{
|
||||
spacing = box->GetScaledWidth();
|
||||
spacing = box->GetDisplayWidth();
|
||||
}
|
||||
else
|
||||
{
|
||||
spacing = box->GetScaledHeight();
|
||||
spacing = box->GetDisplayHeight();
|
||||
}
|
||||
return spacing + ((style != STYLE_Strife) ? 1 : -1);
|
||||
}
|
||||
|
@ -2369,22 +2369,22 @@ class CommandDrawKeyBar : public SBarInfoCommand
|
|||
{
|
||||
if(!vertical)
|
||||
{
|
||||
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
rowWidth = rowIconSize == -1 ? TexMan(item->TextureIDVar(NAME_Icon))->GetScaledHeight()+2 : rowIconSize;
|
||||
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), x+slotOffset, y+rowOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
rowWidth = rowIconSize == -1 ? TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayHeight()+2 : rowIconSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
statusBar->DrawGraphic(TexMan(item->TextureIDVar(NAME_Icon)), x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
rowWidth = rowIconSize == -1 ? TexMan(item->TextureIDVar(NAME_Icon))->GetScaledWidth()+2 : rowIconSize;
|
||||
statusBar->DrawGraphic(TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true), x+rowOffset, y+slotOffset, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
rowWidth = rowIconSize == -1 ? TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayWidth()+2 : rowIconSize;
|
||||
}
|
||||
|
||||
// If cmd.special is -1 then the slot size is auto detected
|
||||
if(iconSize == -1)
|
||||
{
|
||||
if(!vertical)
|
||||
slotOffset += (reverse ? -1 : 1) * (TexMan(item->TextureIDVar(NAME_Icon))->GetScaledWidth() + 2);
|
||||
slotOffset += (reverse ? -1 : 1) * (TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayWidth() + 2);
|
||||
else
|
||||
slotOffset += (reverse ? -1 : 1) * (TexMan(item->TextureIDVar(NAME_Icon))->GetScaledHeight() + 2);
|
||||
slotOffset += (reverse ? -1 : 1) * (TexMan.GetTexture(item->TextureIDVar(NAME_Icon), true)->GetDisplayHeight() + 2);
|
||||
}
|
||||
else
|
||||
slotOffset += (reverse ? -iconSize : iconSize);
|
||||
|
@ -2504,7 +2504,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
else
|
||||
{
|
||||
// Draw background
|
||||
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
||||
if (bg != NULL && bg->GetDisplayWidth() == fg->GetDisplayWidth() && bg->GetDisplayHeight() == fg->GetDisplayHeight())
|
||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
else
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, nulclip, true);
|
||||
|
@ -2513,7 +2513,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
// {cx, cy, cr, cb}
|
||||
double Clip[4] = {0, 0, 0, 0};
|
||||
|
||||
int sizeOfImage = (horizontal ? fg->GetScaledWidth()-border*2 : fg->GetScaledHeight()-border*2);
|
||||
int sizeOfImage = (horizontal ? fg->GetDisplayWidth()-border*2 : fg->GetDisplayHeight()-border*2);
|
||||
Clip[(!horizontal)|((horizontal ? !reverse : reverse)<<1)] = sizeOfImage - sizeOfImage *value;
|
||||
// Draw background
|
||||
if(border != 0)
|
||||
|
@ -2521,7 +2521,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
for(unsigned int i = 0;i < 4;i++)
|
||||
Clip[i] += border;
|
||||
|
||||
if (bg != NULL && bg->GetScaledWidth() == fg->GetScaledWidth() && bg->GetScaledHeight() == fg->GetScaledHeight())
|
||||
if (bg != NULL && bg->GetDisplayWidth() == fg->GetDisplayWidth() && bg->GetDisplayHeight() == fg->GetDisplayHeight())
|
||||
statusBar->DrawGraphic(bg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip);
|
||||
else
|
||||
statusBar->DrawGraphic(fg, this->x, this->y, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets(), false, false, 0, false, -1, -1, Clip, true);
|
||||
|
@ -2802,7 +2802,7 @@ class CommandDrawBar : public SBarInfoCommand
|
|||
// [BL] Since we used a percentage (in order to get the most fluid animation)
|
||||
// we need to establish a cut off point so the last pixel won't hang as the animation slows
|
||||
if(pixel == -1 && statusBar->Images[foreground])
|
||||
pixel = MAX(1 / 65536., 1./statusBar->Images[foreground]->GetWidth());
|
||||
pixel = MAX(1 / 65536., 1./statusBar->Images[foreground]->GetDisplayWidth());
|
||||
|
||||
if(fabs(drawValue - value) < pixel)
|
||||
drawValue = value;
|
||||
|
@ -3115,7 +3115,7 @@ class CommandDrawGem : public SBarInfoCommand
|
|||
SBarInfoCoordinate drawY = y;
|
||||
if(wiggle && drawValue != goalValue) // Should only wiggle when the value doesn't equal what is being drawn.
|
||||
drawY += chainWiggle;
|
||||
int chainWidth = chainImg->GetScaledWidth();
|
||||
int chainWidth = chainImg->GetDisplayWidth();
|
||||
int offset = (int) (((double) (chainWidth-leftPadding-rightPadding)/100)*drawValue);
|
||||
statusBar->DrawGraphic(chainImg, x+(offset%chainSize), drawY, block->XOffset(), block->YOffset(), block->Alpha(), block->FullScreenOffsets());
|
||||
if(gemImg != NULL)
|
||||
|
|
|
@ -203,7 +203,7 @@ void ST_LoadCrosshair(bool alwaysload)
|
|||
}
|
||||
}
|
||||
CrosshairNum = num;
|
||||
CrosshairImage = TexMan[texid];
|
||||
CrosshairImage = TexMan.GetTexture(texid);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
@ -817,11 +817,11 @@ void DBaseStatusBar::RefreshBackground () const
|
|||
|
||||
if (setblocks >= 10)
|
||||
{
|
||||
FTexture *p = TexMan[gameinfo.Border.b];
|
||||
FTexture *p = TexMan.GetTextureByName(gameinfo.Border.b);
|
||||
if (p != NULL)
|
||||
{
|
||||
screen->FlatFill(0, y, x, y + p->GetHeight(), p, true);
|
||||
screen->FlatFill(x2, y, SCREENWIDTH, y + p->GetHeight(), p, true);
|
||||
screen->FlatFill(0, y, x, y + p->GetDisplayHeight(), p, true);
|
||||
screen->FlatFill(x2, y, SCREENWIDTH, y + p->GetDisplayHeight(), p, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -864,8 +864,8 @@ void DBaseStatusBar::DrawCrosshair ()
|
|||
{
|
||||
size *= CrosshairSize;
|
||||
}
|
||||
w = int(CrosshairImage->GetWidth() * size);
|
||||
h = int(CrosshairImage->GetHeight() * size);
|
||||
w = int(CrosshairImage->GetDisplayWidth() * size);
|
||||
h = int(CrosshairImage->GetDisplayHeight() * size);
|
||||
|
||||
if (crosshairhealth)
|
||||
{
|
||||
|
@ -1323,10 +1323,10 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
|
|||
if (!texture.isValid())
|
||||
return;
|
||||
|
||||
FTexture *tex = (flags & DI_DONTANIMATE)? TexMan[texture] : TexMan(texture);
|
||||
FTexture *tex = TexMan.GetTexture(texture, !(flags & DI_DONTANIMATE));
|
||||
|
||||
double texwidth = tex->GetScaledWidthDouble() * scaleX;
|
||||
double texheight = tex->GetScaledHeightDouble() * scaleY;
|
||||
double texwidth = tex->GetDisplayWidthDouble() * scaleX;
|
||||
double texheight = tex->GetDisplayHeightDouble() * scaleY;
|
||||
|
||||
if (boxwidth > 0 || boxheight > 0)
|
||||
{
|
||||
|
@ -1378,14 +1378,14 @@ void DBaseStatusBar::DrawGraphic(FTextureID texture, double x, double y, int fla
|
|||
{
|
||||
case DI_ITEM_HCENTER: x -= boxwidth / 2; break;
|
||||
case DI_ITEM_RIGHT: x -= boxwidth; break;
|
||||
case DI_ITEM_HOFFSET: x -= tex->GetScaledLeftOffsetDouble(0) * boxwidth / texwidth; break;
|
||||
case DI_ITEM_HOFFSET: x -= tex->GetDisplayLeftOffsetDouble() * boxwidth / texwidth; break;
|
||||
}
|
||||
|
||||
switch (flags & DI_ITEM_VMASK)
|
||||
{
|
||||
case DI_ITEM_VCENTER: y -= boxheight / 2; break;
|
||||
case DI_ITEM_BOTTOM: y -= boxheight; break;
|
||||
case DI_ITEM_VOFFSET: y -= tex->GetScaledTopOffsetDouble(0) * boxheight / texheight; break;
|
||||
case DI_ITEM_VOFFSET: y -= tex->GetDisplayTopOffsetDouble() * boxheight / texheight; break;
|
||||
}
|
||||
|
||||
if (!fullscreenOffsets)
|
||||
|
@ -1513,20 +1513,20 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
|||
}
|
||||
|
||||
int width;
|
||||
FTexture* c = font->GetChar((unsigned char)ch, &width);
|
||||
FTexture* c = font->GetChar((unsigned char)ch, fontcolor, &width);
|
||||
if (c == NULL) //missing character.
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!monospaced) //If we are monospaced lets use the offset
|
||||
x += (c->GetLeftOffset(0) + 1); //ignore x offsets since we adapt to character size
|
||||
x += (c->GetDisplayLeftOffsetDouble() + 1); //ignore x offsets since we adapt to character size
|
||||
|
||||
double rx, ry, rw, rh;
|
||||
rx = x + drawOffset.X;
|
||||
ry = y + drawOffset.Y;
|
||||
rw = c->GetScaledWidthDouble();
|
||||
rh = c->GetScaledHeightDouble();
|
||||
rw = c->GetDisplayWidthDouble();
|
||||
rh = c->GetDisplayHeightDouble();
|
||||
|
||||
if (!fullscreenOffsets)
|
||||
{
|
||||
|
@ -1560,7 +1560,7 @@ void DBaseStatusBar::DrawString(FFont *font, const FString &cstring, double x, d
|
|||
TAG_DONE);
|
||||
|
||||
if (!monospaced)
|
||||
x += width + spacing - (c->GetLeftOffset(0) + 1);
|
||||
x += width + spacing - (c->GetDisplayLeftOffsetDouble() + 1);
|
||||
else
|
||||
x += spacing;
|
||||
}
|
||||
|
|
|
@ -966,11 +966,11 @@ void FGLRenderBuffers::RenderEffect(const FString &name)
|
|||
auto &shader = GLShaders[step.ShaderName];
|
||||
|
||||
// Set uniforms
|
||||
if (step.Uniforms.Size > 0)
|
||||
if (step.Uniforms.Data.Size() > 0)
|
||||
{
|
||||
if (!shader->Uniforms)
|
||||
shader->Uniforms.reset(screen->CreateDataBuffer(POSTPROCESS_BINDINGPOINT, false));
|
||||
shader->Uniforms->SetData(step.Uniforms.Size, step.Uniforms.Data);
|
||||
shader->Uniforms->SetData(step.Uniforms.Data.Size(), step.Uniforms.Data.Data());
|
||||
shader->Uniforms->BindBase();
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ FGLRenderer::~FGLRenderer()
|
|||
{
|
||||
FlushModels();
|
||||
AActor::DeleteAllAttachedLights();
|
||||
FMaterial::FlushAll();
|
||||
TexMan.FlushAll();
|
||||
if (mShaderManager != nullptr) delete mShaderManager;
|
||||
if (mSamplerManager != nullptr) delete mSamplerManager;
|
||||
if (mFBID != 0) glDeleteFramebuffers(1, &mFBID);
|
||||
|
@ -254,7 +254,10 @@ sector_t *FGLRenderer::RenderView(player_t* player)
|
|||
bool saved_niv = NoInterpolateView;
|
||||
NoInterpolateView = false;
|
||||
// prepare all camera textures that have been used in the last frame
|
||||
FCanvasTextureInfo::UpdateAll();
|
||||
level.canvasTextureInfo.UpdateAll([&](AActor *camera, FCanvasTexture *camtex, double fov)
|
||||
{
|
||||
RenderTextureView(camtex, camera, fov);
|
||||
});
|
||||
NoInterpolateView = saved_niv;
|
||||
|
||||
|
||||
|
@ -285,7 +288,7 @@ sector_t *FGLRenderer::RenderView(player_t* player)
|
|||
|
||||
void FGLRenderer::BindToFrameBuffer(FMaterial *mat)
|
||||
{
|
||||
auto BaseLayer = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
||||
auto BaseLayer = static_cast<FHardwareTexture*>(mat->GetLayer(0, 0));
|
||||
|
||||
if (BaseLayer == nullptr)
|
||||
{
|
||||
|
@ -324,7 +327,8 @@ void FGLRenderer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, doub
|
|||
|
||||
EndOffscreen();
|
||||
|
||||
tex->SetUpdated();
|
||||
tex->SetUpdated(true);
|
||||
static_cast<OpenGLFrameBuffer*>(screen)->camtexcount++;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -303,7 +303,7 @@ void FGLRenderState::Apply()
|
|||
|
||||
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
||||
{
|
||||
if (mat->tex->bHasCanvas)
|
||||
if (mat->tex->isHardwareCanvas())
|
||||
{
|
||||
mTempTM = TM_OPAQUE;
|
||||
}
|
||||
|
@ -317,8 +317,8 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
|||
|
||||
auto tex = mat->tex;
|
||||
if (tex->UseType == ETextureType::SWCanvas) clampmode = CLAMP_NOFILTER;
|
||||
if (tex->bHasCanvas) clampmode = CLAMP_CAMTEX;
|
||||
else if ((tex->bWarped || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
|
||||
if (tex->isHardwareCanvas()) clampmode = CLAMP_CAMTEX;
|
||||
else if ((tex->isWarped() || tex->shaderindex >= FIRST_USER_SHADER) && clampmode <= CLAMP_XY) clampmode = CLAMP_NONE;
|
||||
|
||||
// avoid rebinding the same texture multiple times.
|
||||
if (mat == lastMaterial && lastClamp == clampmode && translation == lastTranslation) return;
|
||||
|
@ -330,16 +330,16 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio
|
|||
int maxbound = 0;
|
||||
|
||||
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
|
||||
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && tex->Scale.X == 1 && tex->Scale.Y == 1 && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
|
||||
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled() && clampmode <= CLAMP_XY) ? CTF_CheckHires : 0;
|
||||
int numLayers = mat->GetLayers();
|
||||
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
||||
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation));
|
||||
|
||||
if (base->BindOrCreate(tex, 0, clampmode, translation, flags))
|
||||
{
|
||||
for (int i = 1; i<numLayers; i++)
|
||||
{
|
||||
FTexture *layer;
|
||||
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, &layer));
|
||||
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, 0, &layer));
|
||||
systex->BindOrCreate(layer, i, clampmode, 0, mat->isExpanded() ? CTF_Expand : 0);
|
||||
maxbound = i;
|
||||
}
|
||||
|
@ -595,4 +595,4 @@ bool FGLRenderState::SetDepthClamp(bool on)
|
|||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -216,8 +216,8 @@ void PostProcessShaderInstance::BindTextures()
|
|||
continue;
|
||||
|
||||
FString name = pair->Value;
|
||||
FTexture *tex = TexMan(TexMan.CheckForTexture(name, ETextureType::Any));
|
||||
if (tex && tex->UseType != ETextureType::Null)
|
||||
FTexture *tex = TexMan.GetTexture(TexMan.CheckForTexture(name, ETextureType::Any), true);
|
||||
if (tex && tex->isValid())
|
||||
{
|
||||
glUniform1i(location, textureUnit);
|
||||
|
||||
|
@ -225,14 +225,14 @@ void PostProcessShaderInstance::BindTextures()
|
|||
auto it = mTextureHandles.find(tex);
|
||||
if (it == mTextureHandles.end())
|
||||
{
|
||||
FBitmap bitmap;
|
||||
bitmap.Create(tex->GetWidth(), tex->GetHeight());
|
||||
tex->CopyTrueColorPixels(&bitmap, 0, 0);
|
||||
// Why does this completely circumvent the normal way of handling textures?
|
||||
// This absolutely needs fixing because it will also circumvent any potential caching system that may get implemented.
|
||||
auto buffer = tex->CreateTexBuffer(0);
|
||||
|
||||
GLuint handle = 0;
|
||||
glGenTextures(1, &handle);
|
||||
glBindTexture(GL_TEXTURE_2D, handle);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, tex->GetWidth(), tex->GetHeight(), 0, GL_BGRA, GL_UNSIGNED_BYTE, bitmap.GetPixels());
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, buffer.mWidth, buffer.mHeight, 0, GL_BGRA, GL_UNSIGNED_BYTE, buffer.mBuffer);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
mTextureHandles[tex] = handle;
|
||||
|
@ -247,4 +247,4 @@ void PostProcessShaderInstance::BindTextures()
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -186,25 +186,6 @@ void OpenGLFrameBuffer::Update()
|
|||
Super::Update();
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void OpenGLFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV)
|
||||
{
|
||||
if (!V_IsHardwareRenderer())
|
||||
{
|
||||
Super::RenderTextureView(tex, Viewpoint, FOV);
|
||||
}
|
||||
else if (GLRenderer != nullptr)
|
||||
{
|
||||
GLRenderer->RenderTextureView(tex, Viewpoint, FOV);
|
||||
camtexcount++;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Render the view to a savegame picture
|
||||
|
@ -345,27 +326,27 @@ void OpenGLFrameBuffer::SetTextureFilterMode()
|
|||
if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
||||
}
|
||||
|
||||
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(FTexture *tex)
|
||||
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture()
|
||||
{
|
||||
return new FHardwareTexture(tex->bNoCompress);
|
||||
return new FHardwareTexture(true/*tex->bNoCompress*/);
|
||||
}
|
||||
|
||||
void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||
{
|
||||
auto tex = mat->tex;
|
||||
if (tex->UseType == ETextureType::SWCanvas) return;
|
||||
if (tex->isSWCanvas()) return;
|
||||
|
||||
// Textures that are already scaled in the texture lump will not get replaced by hires textures.
|
||||
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && tex->Scale.X == 1 && tex->Scale.Y == 1) ? CTF_CheckHires : 0;
|
||||
int flags = mat->isExpanded() ? CTF_Expand : (gl_texture_usehires && !tex->isScaled()) ? CTF_CheckHires : 0;
|
||||
int numLayers = mat->GetLayers();
|
||||
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0));
|
||||
auto base = static_cast<FHardwareTexture*>(mat->GetLayer(0, translation));
|
||||
|
||||
if (base->BindOrCreate(tex, 0, CLAMP_NONE, translation, flags))
|
||||
{
|
||||
for (int i = 1; i < numLayers; i++)
|
||||
{
|
||||
FTexture *layer;
|
||||
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, &layer));
|
||||
auto systex = static_cast<FHardwareTexture*>(mat->GetLayer(i, 0, &layer));
|
||||
systex->BindOrCreate(layer, i, CLAMP_NONE, 0, mat->isExpanded() ? CTF_Expand : 0);
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +354,7 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
|||
FHardwareTexture::UnbindAll();
|
||||
}
|
||||
|
||||
FModelRenderer *OpenGLFrameBuffer::CreateModelRenderer(int mli)
|
||||
FModelRenderer *OpenGLFrameBuffer::CreateModelRenderer(int mli)
|
||||
{
|
||||
return new FGLModelRenderer(nullptr, gl_RenderState, mli);
|
||||
}
|
||||
|
@ -527,9 +508,9 @@ FTexture *OpenGLFrameBuffer::WipeStartScreen()
|
|||
const auto &viewport = screen->mScreenViewport;
|
||||
|
||||
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
||||
tex->SystemTexture[0]->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
||||
tex->GetSystemTexture()->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
|
||||
glFinish();
|
||||
static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false);
|
||||
static_cast<FHardwareTexture*>(tex->GetSystemTexture())->Bind(0, false);
|
||||
|
||||
GLRenderer->mBuffers->BindCurrentFB();
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
||||
|
@ -549,12 +530,12 @@ FTexture *OpenGLFrameBuffer::WipeEndScreen()
|
|||
GLRenderer->Flush();
|
||||
const auto &viewport = screen->mScreenViewport;
|
||||
auto tex = new FWrapperTexture(viewport.width, viewport.height, 1);
|
||||
tex->SystemTexture[0]->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
||||
tex->GetSystemTexture()->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
|
||||
glFinish();
|
||||
static_cast<FHardwareTexture*>(tex->SystemTexture[0])->Bind(0, false, false);
|
||||
static_cast<FHardwareTexture*>(tex->GetSystemTexture())->Bind(0, false);
|
||||
GLRenderer->mBuffers->BindCurrentFB();
|
||||
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height);
|
||||
return tex;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,11 +30,10 @@ public:
|
|||
void CleanForRestart() override;
|
||||
void UpdatePalette() override;
|
||||
uint32_t GetCaps() override;
|
||||
void RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, double FOV) override;
|
||||
void WriteSavePic(player_t *player, FileWriter *file, int width, int height) override;
|
||||
sector_t *RenderView(player_t *player) override;
|
||||
void SetTextureFilterMode() override;
|
||||
IHardwareTexture *CreateHardwareTexture(FTexture *tex) override;
|
||||
IHardwareTexture *CreateHardwareTexture() override;
|
||||
void PrecacheMaterial(FMaterial *mat, int translation) override;
|
||||
FModelRenderer *CreateModelRenderer(int mli) override;
|
||||
void TextureFilterChanged() override;
|
||||
|
@ -64,7 +63,7 @@ public:
|
|||
|
||||
FTexture *WipeStartScreen() override;
|
||||
FTexture *WipeEndScreen() override;
|
||||
private:
|
||||
|
||||
int camtexcount = 0;
|
||||
};
|
||||
|
||||
|
|
|
@ -96,13 +96,16 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
|||
texformat = GL_RGBA8;
|
||||
}
|
||||
*/
|
||||
TranslatedTexture * glTex=GetTexID(translation);
|
||||
bool firstCall = glTex->glTexID == 0;
|
||||
if (firstCall) glGenTextures(1,&glTex->glTexID);
|
||||
if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit);
|
||||
glBindTexture(GL_TEXTURE_2D, glTex->glTexID);
|
||||
FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name);
|
||||
lastbound[texunit] = glTex->glTexID;
|
||||
bool firstCall = glTexID == 0;
|
||||
if (firstCall) glGenTextures(1,&glTexID);
|
||||
|
||||
int textureBinding = UINT_MAX;
|
||||
if (texunit == -1) glGetIntegerv(GL_TEXTURE_BINDING_2D, &textureBinding);
|
||||
if (texunit > 0) glActiveTexture(GL_TEXTURE0+texunit);
|
||||
if (texunit >= 0) lastbound[texunit] = glTexID;
|
||||
glBindTexture(GL_TEXTURE_2D, glTexID);
|
||||
|
||||
FGLDebug::LabelObject(GL_TEXTURE, glTexID, name);
|
||||
|
||||
rw = GetTexDimension(w);
|
||||
rh = GetTexDimension(h);
|
||||
|
@ -114,7 +117,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
|||
else if (!buffer)
|
||||
{
|
||||
// The texture must at least be initialized if no data is present.
|
||||
glTex->mipmapped = false;
|
||||
mipmapped = false;
|
||||
buffer=(unsigned char *)calloc(4,rw * (rh+1));
|
||||
deletebuffer=true;
|
||||
//texheight=-h;
|
||||
|
@ -165,11 +168,12 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
|
|||
if (mipmap && TexFilter[gl_texture_filter].mipmapping)
|
||||
{
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
glTex->mipmapped = true;
|
||||
mipmapped = true;
|
||||
}
|
||||
|
||||
if (texunit != 0) glActiveTexture(GL_TEXTURE0);
|
||||
return glTex->glTexID;
|
||||
if (texunit > 0) glActiveTexture(GL_TEXTURE0);
|
||||
else if (texunit == -1) glBindTexture(GL_TEXTURE_2D, textureBinding);
|
||||
return glTexID;
|
||||
}
|
||||
|
||||
|
||||
|
@ -200,89 +204,6 @@ uint8_t *FHardwareTexture::MapBuffer()
|
|||
return (uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Creates a texture
|
||||
//
|
||||
//===========================================================================
|
||||
FHardwareTexture::FHardwareTexture(bool nocompression)
|
||||
{
|
||||
forcenocompression = nocompression;
|
||||
|
||||
glDefTex.glTexID = 0;
|
||||
glDefTex.translation = 0;
|
||||
glDefTex.mipmapped = false;
|
||||
glDepthID = 0;
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Deletes a texture id and unbinds it from the texture units
|
||||
//
|
||||
//===========================================================================
|
||||
void FHardwareTexture::TranslatedTexture::Delete()
|
||||
{
|
||||
if (glTexID != 0)
|
||||
{
|
||||
for(int i = 0; i < MAX_TEXTURES; i++)
|
||||
{
|
||||
if (lastbound[i] == glTexID)
|
||||
{
|
||||
lastbound[i] = 0;
|
||||
}
|
||||
}
|
||||
glDeleteTextures(1, &glTexID);
|
||||
glTexID = 0;
|
||||
mipmapped = false;
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Frees all associated resources
|
||||
//
|
||||
//===========================================================================
|
||||
void FHardwareTexture::Clean(bool all)
|
||||
{
|
||||
int cm_arraysize = CM_FIRSTSPECIALCOLORMAP + SpecialColormaps.Size();
|
||||
|
||||
if (all)
|
||||
{
|
||||
glDefTex.Delete();
|
||||
}
|
||||
for(unsigned int i=0;i<glTex_Translated.Size();i++)
|
||||
{
|
||||
glTex_Translated[i].Delete();
|
||||
}
|
||||
glTex_Translated.Clear();
|
||||
if (glDepthID != 0) glDeleteRenderbuffers(1, &glDepthID);
|
||||
glDepthID = 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Deletes all allocated resources and considers translations
|
||||
// This will only be called for sprites
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void FHardwareTexture::CleanUnused(SpriteHits &usedtranslations)
|
||||
{
|
||||
if (usedtranslations.CheckKey(0) == nullptr)
|
||||
{
|
||||
glDefTex.Delete();
|
||||
}
|
||||
for (int i = glTex_Translated.Size()-1; i>= 0; i--)
|
||||
{
|
||||
if (usedtranslations.CheckKey(glTex_Translated[i].translation) == nullptr)
|
||||
{
|
||||
glTex_Translated[i].Delete();
|
||||
glTex_Translated.Delete(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Destroys the texture
|
||||
|
@ -290,72 +211,38 @@ void FHardwareTexture::CleanUnused(SpriteHits &usedtranslations)
|
|||
//===========================================================================
|
||||
FHardwareTexture::~FHardwareTexture()
|
||||
{
|
||||
Clean(true);
|
||||
glDeleteBuffers(1, &glBufferID);
|
||||
}
|
||||
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Gets a texture ID address and validates all required data
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
FHardwareTexture::TranslatedTexture *FHardwareTexture::GetTexID(int translation)
|
||||
{
|
||||
if (translation == 0)
|
||||
{
|
||||
return &glDefTex;
|
||||
}
|
||||
|
||||
// normally there aren't more than very few different
|
||||
// translations here so this isn't performance critical.
|
||||
for (unsigned int i = 0; i < glTex_Translated.Size(); i++)
|
||||
{
|
||||
if (glTex_Translated[i].translation == translation)
|
||||
{
|
||||
return &glTex_Translated[i];
|
||||
}
|
||||
}
|
||||
|
||||
int add = glTex_Translated.Reserve(1);
|
||||
glTex_Translated[add].translation = translation;
|
||||
glTex_Translated[add].glTexID = 0;
|
||||
glTex_Translated[add].mipmapped = false;
|
||||
return &glTex_Translated[add];
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Binds this patch
|
||||
//
|
||||
//===========================================================================
|
||||
unsigned int FHardwareTexture::Bind(int texunit, int translation, bool needmipmap)
|
||||
unsigned int FHardwareTexture::Bind(int texunit, bool needmipmap)
|
||||
{
|
||||
TranslatedTexture *pTex = GetTexID(translation);
|
||||
|
||||
if (pTex->glTexID != 0)
|
||||
if (glTexID != 0)
|
||||
{
|
||||
if (lastbound[texunit] == pTex->glTexID) return pTex->glTexID;
|
||||
lastbound[texunit] = pTex->glTexID;
|
||||
if (lastbound[texunit] == glTexID) return glTexID;
|
||||
lastbound[texunit] = glTexID;
|
||||
if (texunit != 0) glActiveTexture(GL_TEXTURE0 + texunit);
|
||||
glBindTexture(GL_TEXTURE_2D, pTex->glTexID);
|
||||
glBindTexture(GL_TEXTURE_2D, glTexID);
|
||||
// Check if we need mipmaps on a texture that was creted without them.
|
||||
if (needmipmap && !pTex->mipmapped && TexFilter[gl_texture_filter].mipmapping)
|
||||
if (needmipmap && !mipmapped && TexFilter[gl_texture_filter].mipmapping)
|
||||
{
|
||||
glGenerateMipmap(GL_TEXTURE_2D);
|
||||
pTex->mipmapped = true;
|
||||
mipmapped = true;
|
||||
}
|
||||
if (texunit != 0) glActiveTexture(GL_TEXTURE0);
|
||||
return pTex->glTexID;
|
||||
return glTexID;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned int FHardwareTexture::GetTextureHandle(int translation)
|
||||
{
|
||||
TranslatedTexture *pTex = GetTexID(translation);
|
||||
return pTex->glTexID;
|
||||
return glTexID;
|
||||
}
|
||||
|
||||
void FHardwareTexture::Unbind(int texunit)
|
||||
|
@ -408,7 +295,7 @@ void FHardwareTexture::BindToFrameBuffer(int width, int height)
|
|||
{
|
||||
width = GetTexDimension(width);
|
||||
height = GetTexDimension(height);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glDefTex.glTexID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, glTexID, 0);
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height));
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, GetDepthBuffer(width, height));
|
||||
}
|
||||
|
@ -437,34 +324,35 @@ bool FHardwareTexture::BindOrCreate(FTexture *tex, int texunit, int clampmode, i
|
|||
bool needmipmap = (clampmode <= CLAMP_XY);
|
||||
|
||||
// Bind it to the system.
|
||||
if (!Bind(texunit, translation, needmipmap))
|
||||
if (!Bind(texunit, needmipmap))
|
||||
{
|
||||
|
||||
int w = 0, h = 0;
|
||||
|
||||
// Create this texture
|
||||
unsigned char * buffer = nullptr;
|
||||
|
||||
FTextureBuffer texbuffer;
|
||||
|
||||
if (!tex->bHasCanvas)
|
||||
if (!tex->isHardwareCanvas())
|
||||
{
|
||||
buffer = tex->CreateTexBuffer(translation, w, h, flags | CTF_ProcessData);
|
||||
texbuffer = std::move(tex->CreateTexBuffer(translation, flags | CTF_ProcessData));
|
||||
w = texbuffer.mWidth;
|
||||
h = texbuffer.mHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
w = tex->GetWidth();
|
||||
h = tex->GetHeight();
|
||||
}
|
||||
if (!CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FHardwareTexture.BindOrCreate"))
|
||||
if (!CreateTexture(texbuffer.mBuffer, w, h, texunit, needmipmap, translation, "FHardwareTexture.BindOrCreate"))
|
||||
{
|
||||
// could not create texture
|
||||
delete[] buffer;
|
||||
return false;
|
||||
}
|
||||
delete[] buffer;
|
||||
}
|
||||
if (tex->bHasCanvas) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
|
||||
if (tex->isHardwareCanvas()) static_cast<FCanvasTexture*>(tex)->NeedUpdate();
|
||||
GLRenderer->mSamplerManager->Bind(texunit, clampmode, 255);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,31 +19,8 @@ class AActor;
|
|||
namespace OpenGLRenderer
|
||||
{
|
||||
|
||||
|
||||
// For error catching while changing parameters.
|
||||
enum EInvalid
|
||||
{
|
||||
Invalid = 0
|
||||
};
|
||||
|
||||
class FHardwareTexture : public IHardwareTexture
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_TEXTURES = 16
|
||||
};
|
||||
|
||||
private:
|
||||
struct TranslatedTexture
|
||||
{
|
||||
unsigned int glTexID;
|
||||
int translation;
|
||||
bool mipmapped;
|
||||
|
||||
void Delete();
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
static unsigned int lastbound[MAX_TEXTURES];
|
||||
|
@ -60,18 +37,20 @@ private:
|
|||
|
||||
bool forcenocompression;
|
||||
|
||||
TranslatedTexture glDefTex;
|
||||
TArray<TranslatedTexture> glTex_Translated;
|
||||
unsigned int glDepthID; // only used by camera textures
|
||||
unsigned int glTexID = 0;
|
||||
unsigned int glDepthID = 0; // only used by camera textures
|
||||
unsigned int glBufferID = 0;
|
||||
int glTextureBytes = 4;
|
||||
|
||||
TranslatedTexture * GetTexID(int translation);
|
||||
bool mipmapped = false;
|
||||
|
||||
int GetDepthBuffer(int w, int h);
|
||||
|
||||
public:
|
||||
FHardwareTexture(bool nocompress);
|
||||
FHardwareTexture(bool nocompress)
|
||||
{
|
||||
forcenocompression = nocompress;
|
||||
}
|
||||
|
||||
~FHardwareTexture();
|
||||
|
||||
static void Unbind(int texunit);
|
||||
|
@ -79,18 +58,14 @@ public:
|
|||
|
||||
void BindToFrameBuffer(int w, int h);
|
||||
|
||||
unsigned int Bind(int texunit, int translation, bool needmipmap);
|
||||
unsigned int Bind(int texunit, bool needmipmap);
|
||||
bool BindOrCreate(FTexture *tex, int texunit, int clampmode, int translation, int flags);
|
||||
|
||||
void AllocateBuffer(int w, int h, int texelsize);
|
||||
uint8_t *MapBuffer();
|
||||
|
||||
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name) = delete;
|
||||
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name);
|
||||
unsigned int GetTextureHandle(int translation);
|
||||
|
||||
void Clean(bool all);
|
||||
void CleanUnused(SpriteHits &usedtranslations);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -209,15 +209,15 @@ void HU_GetPlayerWidths(int &maxnamewidth, int &maxscorewidth, int &maxiconheigh
|
|||
}
|
||||
if (players[i].mo->ScoreIcon.isValid())
|
||||
{
|
||||
FTexture *pic = TexMan[players[i].mo->ScoreIcon];
|
||||
width = pic->GetScaledWidth() - pic->GetScaledLeftOffset(0) + 2;
|
||||
FTexture *pic = TexMan.GetTexture(players[i].mo->ScoreIcon);
|
||||
width = pic->GetDisplayWidth() - pic->GetDisplayLeftOffset() + 2;
|
||||
if (width > maxscorewidth)
|
||||
{
|
||||
maxscorewidth = width;
|
||||
}
|
||||
// The icon's top offset does not count toward its height, because
|
||||
// zdoom.pk3's standard Hexen class icons are designed that way.
|
||||
int height = pic->GetScaledHeight() - pic->GetScaledTopOffset(0);
|
||||
int height = pic->GetDisplayHeight() - pic->GetDisplayTopOffset();
|
||||
if (height > maxiconheight)
|
||||
{
|
||||
maxiconheight = height;
|
||||
|
@ -422,7 +422,7 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
|
|||
|
||||
if (player->mo->ScoreIcon.isValid())
|
||||
{
|
||||
FTexture *pic = TexMan[player->mo->ScoreIcon];
|
||||
FTexture *pic = TexMan.GetTexture(player->mo->ScoreIcon);
|
||||
screen->DrawTexture (pic, col3, y,
|
||||
DTA_CleanNoMove, true,
|
||||
TAG_DONE);
|
||||
|
@ -445,8 +445,8 @@ static void HU_DrawPlayer (player_t *player, bool highlight, int col1, int col2,
|
|||
|
||||
if (teamplay && Teams[player->userinfo.GetTeam()].GetLogo().IsNotEmpty ())
|
||||
{
|
||||
FTexture *pic = TexMan[Teams[player->userinfo.GetTeam()].GetLogo().GetChars ()];
|
||||
screen->DrawTexture (pic, col1 - (pic->GetScaledWidth() + 2) * CleanXfac, y,
|
||||
FTexture *pic = TexMan.GetTextureByName(Teams[player->userinfo.GetTeam()].GetLogo().GetChars ());
|
||||
screen->DrawTexture (pic, col1 - (pic->GetDisplayWidth() + 2) * CleanXfac, y,
|
||||
DTA_CleanNoMove, true, TAG_DONE);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,12 +38,7 @@ public:
|
|||
|
||||
PPUniforms(const PPUniforms &src)
|
||||
{
|
||||
if (src.Size > 0)
|
||||
{
|
||||
Data = new uint8_t[src.Size];
|
||||
Size = src.Size;
|
||||
memcpy(Data, src.Data, Size);
|
||||
}
|
||||
Data = src.Data;
|
||||
}
|
||||
|
||||
~PPUniforms()
|
||||
|
@ -53,49 +48,26 @@ public:
|
|||
|
||||
PPUniforms &operator=(const PPUniforms &src)
|
||||
{
|
||||
if (this != &src)
|
||||
{
|
||||
if (src.Size > 0)
|
||||
{
|
||||
Data = new uint8_t[src.Size];
|
||||
Size = src.Size;
|
||||
memcpy(Data, src.Data, Size);
|
||||
}
|
||||
else
|
||||
{
|
||||
delete[] Data;
|
||||
Data = nullptr;
|
||||
Size = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Data = src.Data;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
delete[] Data;
|
||||
Data = nullptr;
|
||||
Size = 0;
|
||||
Data.Clear();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void Set(const T &v)
|
||||
{
|
||||
if (Size != (int)sizeof(T))
|
||||
if (Data.Size() != (int)sizeof(T))
|
||||
{
|
||||
delete[] Data;
|
||||
Data = nullptr;
|
||||
Size = 0;
|
||||
|
||||
Data = new uint8_t[sizeof(T)];
|
||||
Size = sizeof(T);
|
||||
memcpy(Data, &v, Size);
|
||||
Data.Resize(sizeof(T));
|
||||
memcpy(Data.Data(), &v, Data.Size());
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t *Data = nullptr;
|
||||
int Size = 0;
|
||||
TArray<uint8_t> Data;
|
||||
};
|
||||
|
||||
class PPStep
|
||||
|
|
|
@ -283,8 +283,8 @@ void HWDrawInfo::AddLine (seg_t *seg, bool portalclip)
|
|||
{
|
||||
if (!seg->linedef->isVisualPortal())
|
||||
{
|
||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::mid));
|
||||
if (!tex || tex->UseType==ETextureType::Null)
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::mid), true);
|
||||
if (!tex || !tex->isValid())
|
||||
{
|
||||
// nothing to do here!
|
||||
seg->linedef->validcount=validcount;
|
||||
|
|
|
@ -208,7 +208,7 @@ void GLWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
|
|||
flipy = !!(decal->RenderFlags & RF_YFLIP);
|
||||
|
||||
|
||||
FTexture *texture = TexMan[decalTile];
|
||||
FTexture *texture = TexMan.GetTexture(decalTile);
|
||||
if (texture == NULL) return;
|
||||
|
||||
|
||||
|
|
|
@ -117,8 +117,8 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
|||
// now check for closed sectors!
|
||||
if (bs_ceilingheight1 <= fs_floorheight1 && bs_ceilingheight2 <= fs_floorheight2)
|
||||
{
|
||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::top));
|
||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
||||
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::top), true);
|
||||
if (!tex || !tex->isValid()) return false;
|
||||
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
|
||||
return true;
|
||||
|
@ -126,8 +126,8 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
|||
|
||||
if (fs_ceilingheight1 <= bs_floorheight1 && fs_ceilingheight2 <= bs_floorheight2)
|
||||
{
|
||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom));
|
||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
||||
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::bottom), true);
|
||||
if (!tex || !tex->isValid()) return false;
|
||||
|
||||
// properly render skies (consider door "open" if both floors are sky):
|
||||
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||
|
@ -140,13 +140,13 @@ bool hw_CheckClip(side_t * sidedef, sector_t * frontsector, sector_t * backsecto
|
|||
// preserve a kind of transparent door/lift special effect:
|
||||
if (bs_ceilingheight1 < fs_ceilingheight1 || bs_ceilingheight2 < fs_ceilingheight2)
|
||||
{
|
||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::top));
|
||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
||||
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::top), true);
|
||||
if (!tex || !tex->isValid()) return false;
|
||||
}
|
||||
if (bs_floorheight1 > fs_floorheight1 || bs_floorheight2 > fs_floorheight2)
|
||||
{
|
||||
FTexture * tex = TexMan(sidedef->GetTexture(side_t::bottom));
|
||||
if (!tex || tex->UseType == ETextureType::Null) return false;
|
||||
FTexture * tex = TexMan.GetTexture(sidedef->GetTexture(side_t::bottom), true);
|
||||
if (!tex || !tex->isValid()) return false;
|
||||
}
|
||||
if (backsector->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||
frontsector->GetTexture(sector_t::ceiling) == skyflatnum) return false;
|
||||
|
|
|
@ -70,7 +70,7 @@ bool hw_SetPlaneTextureRotation(const GLSectorPlane * secplane, FMaterial * glte
|
|||
|
||||
float xscale1 = secplane->Scale.X;
|
||||
float yscale1 = secplane->Scale.Y;
|
||||
if (gltexture->tex->bHasCanvas)
|
||||
if (gltexture->hasCanvas())
|
||||
{
|
||||
yscale1 = 0 - yscale1;
|
||||
}
|
||||
|
|
|
@ -350,8 +350,8 @@ bool HWDrawInfo::DoOneSectorUpper(subsector_t * subsec, float Planez, area_t in_
|
|||
if (sec->GetPlaneTexZ(sector_t::ceiling) == Planez)
|
||||
{
|
||||
// If there's a texture abort
|
||||
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::top)];
|
||||
if (!tex || tex->UseType == ETextureType::Null) continue;
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::top));
|
||||
if (!tex || !tex->isValid()) continue;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
@ -408,8 +408,8 @@ bool HWDrawInfo::DoOneSectorLower(subsector_t * subsec, float Planez, area_t in_
|
|||
if (sec->GetPlaneTexZ(sector_t::floor) == Planez)
|
||||
{
|
||||
// If there's a texture abort
|
||||
FTexture * tex = TexMan[seg->sidedef->GetTexture(side_t::bottom)];
|
||||
if (!tex || tex->UseType == ETextureType::Null) continue;
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom));
|
||||
if (!tex || !tex->isValid()) continue;
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
|||
|
||||
FTextureID texno = s->GetTexture(pos);
|
||||
texture[0] = FMaterial::ValidateTexture(texno, false, true);
|
||||
if (!texture[0] || texture[0]->tex->UseType == ETextureType::Null) goto normalsky;
|
||||
if (!texture[0] || !texture[0]->tex->isValid()) goto normalsky;
|
||||
skytexno1 = texno;
|
||||
x_offset[0] = s->GetTextureXOffset(pos) * (360.f/65536.f);
|
||||
y_offset = s->GetTextureYOffset(pos);
|
||||
|
@ -243,13 +243,13 @@ void GLWall::SkyTop(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,vert
|
|||
{
|
||||
if (bs->GetPlaneTexZ(sector_t::floor)==fs->GetPlaneTexZ(sector_t::floor)+1.)
|
||||
{
|
||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
||||
if (!tex || tex->UseType==ETextureType::Null) return;
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom), true);
|
||||
if (!tex || !tex->isValid()) return;
|
||||
|
||||
// very, very, very ugly special case (See Icarus MAP14)
|
||||
// It is VERY important that this is only done for a floor height difference of 1
|
||||
// or it will cause glitches elsewhere.
|
||||
tex = TexMan(seg->sidedef->GetTexture(side_t::mid));
|
||||
tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::mid), true);
|
||||
if (tex != NULL && !(seg->linedef->flags & ML_DONTPEGTOP) &&
|
||||
seg->sidedef->GetTextureYOffset(side_t::mid) > 0)
|
||||
{
|
||||
|
@ -265,7 +265,7 @@ void GLWall::SkyTop(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,vert
|
|||
|
||||
ztop[0]=ztop[1]=32768.0f;
|
||||
|
||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top));
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::top), true);
|
||||
if (bs->GetTexture(sector_t::ceiling) != skyflatnum)
|
||||
|
||||
{
|
||||
|
@ -325,10 +325,10 @@ void GLWall::SkyBottom(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,v
|
|||
if (fs->GetTexture(sector_t::floor)==skyflatnum)
|
||||
{
|
||||
if (bs->special == GLSector_NoSkyDraw) return;
|
||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom), true);
|
||||
|
||||
// For lower skies the normal logic only applies to walls with no lower texture!
|
||||
if (tex->UseType==ETextureType::Null)
|
||||
// For lower skies the normal logic only applies to walls with no lower texture.
|
||||
if (!tex->isValid())
|
||||
{
|
||||
if (bs->GetTexture(sector_t::floor)==skyflatnum)
|
||||
{
|
||||
|
@ -346,7 +346,7 @@ void GLWall::SkyBottom(HWDrawInfo *di, seg_t * seg,sector_t * fs,sector_t * bs,v
|
|||
}
|
||||
zbottom[0]=zbottom[1]=-32768.0f;
|
||||
|
||||
if ((tex && tex->UseType!=ETextureType::Null) || bs->GetTexture(sector_t::floor)!=skyflatnum)
|
||||
if ((tex && !tex->isValid()) || bs->GetTexture(sector_t::floor)!=skyflatnum)
|
||||
{
|
||||
ztop[0]=zfloor[0];
|
||||
ztop[1]=zfloor[1];
|
||||
|
|
|
@ -293,7 +293,7 @@ void FSkyVertexBuffer::SetupMatrices(FMaterial *tex, float x_offset, float y_off
|
|||
float yscale = 1.f;
|
||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
||||
{
|
||||
modelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f);
|
||||
modelMatrix.translate(0.f, (-40 + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
||||
yscale = 240.f / texh;
|
||||
}
|
||||
|
@ -311,12 +311,12 @@ void FSkyVertexBuffer::SetupMatrices(FMaterial *tex, float x_offset, float y_off
|
|||
}
|
||||
else if (texh <= 240)
|
||||
{
|
||||
modelMatrix.translate(0.f, (200 - texh + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f);
|
||||
modelMatrix.translate(0.f, (200 - texh + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||
modelMatrix.scale(1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f, 1.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
modelMatrix.translate(0.f, (-40 + tex->tex->SkyOffset + skyoffset)*skyoffsetfactor, 0.f);
|
||||
modelMatrix.translate(0.f, (-40 + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
||||
yscale = 240.f / texh;
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
|||
di->SetupView(state, 0, 0, 0, !!(mState->MirrorFlag & 1), !!(mState->PlaneMirrorFlag & 1));
|
||||
|
||||
state.SetVertexBuffer(vertexBuffer);
|
||||
if (origin->texture[0] && origin->texture[0]->tex->bSkybox)
|
||||
if (origin->texture[0] && origin->texture[0]->tex->isSkybox())
|
||||
{
|
||||
RenderBox(di, state, origin->skytexno1, origin->texture[0], origin->x_offset[0], origin->sky2);
|
||||
}
|
||||
|
|
|
@ -789,9 +789,9 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
if (isPicnumOverride)
|
||||
{
|
||||
// Animate picnum overrides.
|
||||
auto tex = TexMan(thing->picnum);
|
||||
auto tex = TexMan.GetTexture(thing->picnum, true);
|
||||
if (tex == nullptr) return;
|
||||
patch = tex->id;
|
||||
patch = tex->GetID();
|
||||
mirror = false;
|
||||
}
|
||||
else
|
||||
|
@ -910,7 +910,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
|||
// allow disabling of the fullbright flag by a brightmap definition
|
||||
// (e.g. to do the gun flashes of Doom's zombies correctly.
|
||||
fullbright = (thing->flags5 & MF5_BRIGHT) ||
|
||||
((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->bDisableFullbright));
|
||||
((thing->renderflags & RF_FULLBRIGHT) && (!gltexture || !gltexture->tex->isFullbrightDisabled()));
|
||||
|
||||
lightlevel = fullbright ? 255 :
|
||||
hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
|
||||
|
|
|
@ -1000,7 +1000,7 @@ bool GLWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
|
|||
if (gltexture != NULL)
|
||||
{
|
||||
bool normalize = false;
|
||||
if (gltexture->tex->bHasCanvas) normalize = true;
|
||||
if (gltexture->tex->isHardwareCanvas()) normalize = true;
|
||||
else if (flags & GLWF_CLAMPY)
|
||||
{
|
||||
// for negative scales we can get negative coordinates here.
|
||||
|
@ -1029,7 +1029,7 @@ void GLWall::CheckTexturePosition(FTexCoordInfo *tci)
|
|||
{
|
||||
float sub;
|
||||
|
||||
if (gltexture->tex->bHasCanvas) return;
|
||||
if (gltexture->tex->isHardwareCanvas()) return;
|
||||
|
||||
// clamp texture coordinates to a reasonable range.
|
||||
// Extremely large values can cause visual problems
|
||||
|
@ -1222,8 +1222,8 @@ void GLWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary,
|
|||
// Set up the top
|
||||
//
|
||||
//
|
||||
FTexture * tex = TexMan(seg->sidedef->GetTexture(side_t::top));
|
||||
if (!tex || tex->UseType==ETextureType::Null)
|
||||
FTexture * tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::top), true);
|
||||
if (!tex || !tex->isValid())
|
||||
{
|
||||
if (front->GetTexture(sector_t::ceiling) == skyflatnum &&
|
||||
back->GetTexture(sector_t::ceiling) == skyflatnum && !wrap)
|
||||
|
@ -1258,8 +1258,8 @@ void GLWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary,
|
|||
// Set up the bottom
|
||||
//
|
||||
//
|
||||
tex = TexMan(seg->sidedef->GetTexture(side_t::bottom));
|
||||
if (!tex || tex->UseType==ETextureType::Null)
|
||||
tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::bottom), true);
|
||||
if (!tex || !tex->isValid())
|
||||
{
|
||||
// texture is missing - use the lower plane
|
||||
bottomleft = MIN(bfh1,ffh1);
|
||||
|
@ -2057,7 +2057,7 @@ void GLWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
|
|||
sector_t *backsec = isportal? seg->linedef->getPortalDestination()->frontsector : backsector;
|
||||
|
||||
bool drawfogboundary = !di->isFullbrightScene() && hw_CheckFog(frontsector, backsec);
|
||||
FTexture *tex = TexMan(seg->sidedef->GetTexture(side_t::mid));
|
||||
FTexture *tex = TexMan.GetTexture(seg->sidedef->GetTexture(side_t::mid), true);
|
||||
if (tex != NULL)
|
||||
{
|
||||
if (i_compatflags & COMPATF_MASKEDMIDTEX)
|
||||
|
|
|
@ -131,8 +131,8 @@ static bool isBright(DPSprite *psp)
|
|||
FTextureID lump = sprites[psp->GetSprite()].GetSpriteFrame(psp->GetFrame(), 0, 0., nullptr);
|
||||
if (lump.isValid())
|
||||
{
|
||||
FTexture * tex = TexMan(lump);
|
||||
if (tex) disablefullbright = tex->bDisableFullbright;
|
||||
FTexture * tex = TexMan.GetTexture(lump, true);
|
||||
if (tex) disablefullbright = tex->isFullbrightDisabled();
|
||||
}
|
||||
return psp->GetState()->GetFullbright() && !disablefullbright;
|
||||
}
|
||||
|
|
|
@ -25,9 +25,6 @@ public:
|
|||
virtual uint8_t *MapBuffer() = 0;
|
||||
virtual unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const char *name) = 0;
|
||||
|
||||
virtual void Clean(bool all) = 0;
|
||||
virtual void CleanUnused(SpriteHits &usedtranslations) = 0;
|
||||
|
||||
void Resize(int swidth, int sheight, int width, int height, unsigned char *src_data, unsigned char *dst_data);
|
||||
};
|
||||
|
||||
|
|
|
@ -128,25 +128,6 @@ void IHardwareTexture::Resize(int swidth, int sheight, int width, int height, un
|
|||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
IHardwareTexture * FMaterial::ValidateSysTexture(FTexture * tex, bool expand)
|
||||
{
|
||||
if (tex && tex->UseType!=ETextureType::Null)
|
||||
{
|
||||
IHardwareTexture *gltex = tex->SystemTexture[expand];
|
||||
if (gltex == nullptr)
|
||||
{
|
||||
gltex = tex->SystemTexture[expand] = screen->CreateHardwareTexture(tex);
|
||||
}
|
||||
return gltex;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Constructor
|
||||
|
@ -160,16 +141,15 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
mShaderIndex = SHADER_Default;
|
||||
sourcetex = tex = tx;
|
||||
|
||||
if (tx->UseType == ETextureType::SWCanvas && tx->WidthBits == 0)
|
||||
if (tx->UseType == ETextureType::SWCanvas && static_cast<FWrapperTexture*>(tx)->GetColorFormat() == 0)
|
||||
{
|
||||
mShaderIndex = SHADER_Paletted;
|
||||
}
|
||||
else if (tx->bWarped)
|
||||
else if (tx->isWarped())
|
||||
{
|
||||
mShaderIndex = tx->bWarped; // This picks SHADER_Warp1 or SHADER_Warp2
|
||||
tx->shaderspeed = static_cast<FWarpTexture*>(tx)->GetSpeed();
|
||||
mShaderIndex = tx->isWarped(); // This picks SHADER_Warp1 or SHADER_Warp2
|
||||
}
|
||||
else if (tx->bHasCanvas)
|
||||
else if (tx->isHardwareCanvas())
|
||||
{
|
||||
if (tx->shaderindex >= FIRST_USER_SHADER)
|
||||
{
|
||||
|
@ -183,7 +163,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
{
|
||||
for (auto &texture : { tx->Normal, tx->Specular })
|
||||
{
|
||||
ValidateSysTexture(texture, expanded);
|
||||
mTextureLayers.Push(texture);
|
||||
}
|
||||
mShaderIndex = SHADER_Specular;
|
||||
|
@ -192,7 +171,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
{
|
||||
for (auto &texture : { tx->Normal, tx->Metallic, tx->Roughness, tx->AmbientOcclusion })
|
||||
{
|
||||
ValidateSysTexture(texture, expanded);
|
||||
mTextureLayers.Push(texture);
|
||||
}
|
||||
mShaderIndex = SHADER_PBR;
|
||||
|
@ -201,7 +179,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
tx->CreateDefaultBrightmap();
|
||||
if (tx->Brightmap)
|
||||
{
|
||||
ValidateSysTexture(tx->Brightmap, expanded);
|
||||
mTextureLayers.Push(tx->Brightmap);
|
||||
if (mShaderIndex == SHADER_Specular)
|
||||
mShaderIndex = SHADER_SpecularBrightmap;
|
||||
|
@ -219,16 +196,12 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
for (auto &texture : tx->CustomShaderTextures)
|
||||
{
|
||||
if (texture == nullptr) continue;
|
||||
ValidateSysTexture(texture, expanded);
|
||||
mTextureLayers.Push(texture);
|
||||
}
|
||||
mShaderIndex = tx->shaderindex;
|
||||
}
|
||||
}
|
||||
}
|
||||
mBaseLayer = ValidateSysTexture(tx, expanded);
|
||||
|
||||
|
||||
mWidth = tx->GetWidth();
|
||||
mHeight = tx->GetHeight();
|
||||
mLeftOffset = tx->GetLeftOffset(0); // These only get used by decals and decals should not use renderer-specific offsets.
|
||||
|
@ -238,14 +211,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
mSpriteU[0] = mSpriteV[0] = 0.f;
|
||||
mSpriteU[1] = mSpriteV[1] = 1.f;
|
||||
|
||||
FTexture *basetex = tx->GetRedirect();
|
||||
// allow the redirect only if the texture is not expanded or the scale matches.
|
||||
if (!expanded || (tx->Scale.X == basetex->Scale.X && tx->Scale.Y == basetex->Scale.Y))
|
||||
{
|
||||
sourcetex = basetex;
|
||||
mBaseLayer = ValidateSysTexture(basetex, expanded);
|
||||
}
|
||||
|
||||
mExpanded = expanded;
|
||||
if (expanded)
|
||||
{
|
||||
|
@ -265,7 +230,7 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
mMaxBound = -1;
|
||||
mMaterials.Push(this);
|
||||
tx->Material[expanded] = this;
|
||||
if (tx->bHasCanvas) tx->bTranslucent = 0;
|
||||
if (tx->isHardwareCanvas()) tx->bTranslucent = 0;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -350,19 +315,19 @@ void FMaterial::SetSpriteRect()
|
|||
|
||||
bool FMaterial::TrimBorders(uint16_t *rect)
|
||||
{
|
||||
int w;
|
||||
int h;
|
||||
|
||||
unsigned char *buffer = sourcetex->CreateTexBuffer(0, w, h);
|
||||
auto texbuffer = sourcetex->CreateTexBuffer(0);
|
||||
int w = texbuffer.mWidth;
|
||||
int h = texbuffer.mHeight;
|
||||
auto Buffer = texbuffer.mBuffer;
|
||||
|
||||
if (buffer == NULL)
|
||||
if (texbuffer.mBuffer == nullptr)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (w != mWidth || h != mHeight)
|
||||
{
|
||||
// external Hires replacements cannot be trimmed.
|
||||
delete [] buffer;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -374,14 +339,13 @@ bool FMaterial::TrimBorders(uint16_t *rect)
|
|||
rect[1] = 0;
|
||||
rect[2] = 1;
|
||||
rect[3] = 1;
|
||||
delete[] buffer;
|
||||
return true;
|
||||
}
|
||||
int first, last;
|
||||
|
||||
for(first = 0; first < size; first++)
|
||||
{
|
||||
if (buffer[first*4+3] != 0) break;
|
||||
if (Buffer[first*4+3] != 0) break;
|
||||
}
|
||||
if (first >= size)
|
||||
{
|
||||
|
@ -390,13 +354,12 @@ bool FMaterial::TrimBorders(uint16_t *rect)
|
|||
rect[1] = 0;
|
||||
rect[2] = 1;
|
||||
rect[3] = 1;
|
||||
delete [] buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
for(last = size-1; last >= first; last--)
|
||||
{
|
||||
if (buffer[last*4+3] != 0) break;
|
||||
if (Buffer[last*4+3] != 0) break;
|
||||
}
|
||||
|
||||
rect[1] = first / w;
|
||||
|
@ -405,7 +368,7 @@ bool FMaterial::TrimBorders(uint16_t *rect)
|
|||
rect[0] = 0;
|
||||
rect[2] = w;
|
||||
|
||||
unsigned char *bufferoff = buffer + (rect[1] * w * 4);
|
||||
unsigned char *bufferoff = Buffer + (rect[1] * w * 4);
|
||||
h = rect[3];
|
||||
|
||||
for(int x = 0; x < w; x++)
|
||||
|
@ -425,16 +388,38 @@ outl:
|
|||
{
|
||||
if (bufferoff[(x+y*w)*4+3] != 0)
|
||||
{
|
||||
delete [] buffer;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
rect[2]--;
|
||||
}
|
||||
delete [] buffer;
|
||||
return true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
IHardwareTexture *FMaterial::GetLayer(int i, int translation, FTexture **pLayer)
|
||||
{
|
||||
FTexture *layer = i == 0 ? tex : mTextureLayers[i - 1];
|
||||
if (pLayer) *pLayer = layer;
|
||||
|
||||
if (layer && layer->UseType!=ETextureType::Null)
|
||||
{
|
||||
IHardwareTexture *hwtex = layer->SystemTextures.GetHardwareTexture(translation, mExpanded);
|
||||
if (hwtex == nullptr)
|
||||
{
|
||||
hwtex = screen->CreateHardwareTexture();
|
||||
layer->SystemTextures.AddHardwareTexture(translation, mExpanded, hwtex);
|
||||
}
|
||||
return hwtex;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
//
|
||||
|
@ -452,7 +437,7 @@ void FMaterial::Precache()
|
|||
//===========================================================================
|
||||
void FMaterial::PrecacheList(SpriteHits &translations)
|
||||
{
|
||||
if (mBaseLayer != nullptr) mBaseLayer->CleanUnused(translations);
|
||||
tex->SystemTextures.CleanUnused(translations, mExpanded);
|
||||
SpriteHits::Iterator it(translations);
|
||||
SpriteHits::Pair *pair;
|
||||
while(it.NextPair(pair)) screen->PrecacheMaterial(this, pair->Key);
|
||||
|
@ -484,19 +469,19 @@ int FMaterial::GetAreas(FloatRect **pAreas) const
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand)
|
||||
FMaterial * FMaterial::ValidateTexture(FTexture * tex, bool expand, bool create)
|
||||
{
|
||||
again:
|
||||
if (tex && tex->UseType!=ETextureType::Null)
|
||||
if (tex && tex->isValid())
|
||||
{
|
||||
if (tex->bNoExpand) expand = false;
|
||||
|
||||
FMaterial *gltex = tex->Material[expand];
|
||||
if (gltex == NULL)
|
||||
FMaterial *hwtex = tex->Material[expand];
|
||||
if (hwtex == NULL && create)
|
||||
{
|
||||
if (expand)
|
||||
{
|
||||
if (tex->bWarped || tex->bHasCanvas || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap))
|
||||
if (tex->isWarped() || tex->isHardwareCanvas() || tex->shaderindex >= FIRST_USER_SHADER || (tex->shaderindex >= SHADER_Specular && tex->shaderindex <= SHADER_PBRBrightmap))
|
||||
{
|
||||
tex->bNoExpand = true;
|
||||
goto again;
|
||||
|
@ -511,84 +496,14 @@ again:
|
|||
goto again;
|
||||
}
|
||||
}
|
||||
gltex = new FMaterial(tex, expand);
|
||||
hwtex = new FMaterial(tex, expand);
|
||||
}
|
||||
return gltex;
|
||||
return hwtex;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate)
|
||||
FMaterial * FMaterial::ValidateTexture(FTextureID no, bool expand, bool translate, bool create)
|
||||
{
|
||||
return ValidateTexture(translate? TexMan(no) : TexMan[no], expand);
|
||||
return ValidateTexture(TexMan.GetTexture(no, translate), expand, create);
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Flushes all hardware dependent data
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FMaterial::FlushAll()
|
||||
{
|
||||
for(int i=mMaterials.Size()-1;i>=0;i--)
|
||||
{
|
||||
mMaterials[i]->mBaseLayer->Clean(true);
|
||||
}
|
||||
// This is for shader layers. All shader layers must be managed by the texture manager
|
||||
// so this will catch everything.
|
||||
for(int i=TexMan.NumTextures()-1;i>=0;i--)
|
||||
{
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
auto gltex = TexMan.ByIndex(i)->SystemTexture[j];
|
||||
if (gltex != nullptr) gltex->Clean(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void FMaterial::Clean(bool f)
|
||||
{
|
||||
// This somehow needs to deal with the other layers as well, but they probably need some form of reference counting to work properly...
|
||||
mBaseLayer->Clean(f);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// Prints some texture info
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
CCMD(textureinfo)
|
||||
{
|
||||
int cntt = 0;
|
||||
for (int i = 0; i < TexMan.NumTextures(); i++)
|
||||
{
|
||||
FTexture *tex = TexMan.ByIndex(i);
|
||||
if (tex->SystemTexture[0] || tex->SystemTexture[1] || tex->Material[0] || tex->Material[1])
|
||||
{
|
||||
int lump = tex->GetSourceLump();
|
||||
Printf(PRINT_LOG, "Texture '%s' (Index %d, Lump %d, Name '%s'):\n", tex->Name.GetChars(), i, lump, Wads.GetLumpFullName(lump));
|
||||
if (tex->Material[0])
|
||||
{
|
||||
Printf(PRINT_LOG, "in use (normal)\n");
|
||||
}
|
||||
else if (tex->SystemTexture[0])
|
||||
{
|
||||
Printf(PRINT_LOG, "referenced (normal)\n");
|
||||
}
|
||||
if (tex->Material[1])
|
||||
{
|
||||
Printf(PRINT_LOG, "in use (expanded)\n");
|
||||
}
|
||||
else if (tex->SystemTexture[1])
|
||||
{
|
||||
Printf(PRINT_LOG, "referenced (normal)\n");
|
||||
}
|
||||
cntt++;
|
||||
}
|
||||
}
|
||||
Printf(PRINT_LOG, "%d system textures\n", cntt);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ class FMaterial
|
|||
static TArray<FMaterial *> mMaterials;
|
||||
static int mMaxBound;
|
||||
|
||||
IHardwareTexture *mBaseLayer;
|
||||
TArray<FTexture*> mTextureLayers;
|
||||
int mShaderIndex;
|
||||
|
||||
|
@ -68,7 +67,6 @@ public:
|
|||
void Precache();
|
||||
void PrecacheList(SpriteHits &translations);
|
||||
int GetShaderIndex() const { return mShaderIndex; }
|
||||
IHardwareTexture * ValidateSysTexture(FTexture * tex, bool expand);
|
||||
void AddTextureLayer(FTexture *tex)
|
||||
{
|
||||
ValidateTexture(tex, false);
|
||||
|
@ -87,24 +85,13 @@ public:
|
|||
{
|
||||
return mTextureLayers.Size() + 1;
|
||||
}
|
||||
|
||||
IHardwareTexture *GetLayer(int i, FTexture **pLayer = nullptr)
|
||||
|
||||
bool hasCanvas()
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
if (pLayer) *pLayer = tex;
|
||||
return mBaseLayer;
|
||||
}
|
||||
else
|
||||
{
|
||||
i--;
|
||||
FTexture *layer = mTextureLayers[i];
|
||||
if (pLayer) *pLayer = layer;
|
||||
return ValidateSysTexture(layer, isExpanded());
|
||||
}
|
||||
return tex->isHardwareCanvas();
|
||||
}
|
||||
|
||||
void Clean(bool f);
|
||||
IHardwareTexture *GetLayer(int i, int translation, FTexture **pLayer = nullptr);
|
||||
|
||||
// Patch drawing utilities
|
||||
|
||||
|
@ -163,10 +150,8 @@ public:
|
|||
float GetSpriteVB() const { return mSpriteV[1]; }
|
||||
|
||||
|
||||
static void DeleteAll();
|
||||
static void FlushAll();
|
||||
static FMaterial *ValidateTexture(FTexture * tex, bool expand);
|
||||
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans);
|
||||
static FMaterial *ValidateTexture(FTexture * tex, bool expand, bool create = true);
|
||||
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans, bool create = true);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include "r_data/models/models.h"
|
||||
#include "textures/skyboxtexture.h"
|
||||
#include "hwrenderer/textures/hw_material.h"
|
||||
#include "image.h"
|
||||
|
||||
|
||||
//==========================================================================
|
||||
|
@ -48,11 +49,6 @@ static void PrecacheTexture(FTexture *tex, int cache)
|
|||
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
||||
if (gltex) gltex->Precache();
|
||||
}
|
||||
else
|
||||
{
|
||||
// make sure that software pixel buffers do not stick around for unneeded textures.
|
||||
tex->Unload();
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -91,14 +87,14 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
if (texhitlist[i] & (FTextureManager::HIT_Sky | FTextureManager::HIT_Wall))
|
||||
{
|
||||
FTexture *tex = TexMan.ByIndex(i);
|
||||
if (tex->bSkybox)
|
||||
if (tex->isSkybox())
|
||||
{
|
||||
FSkyBox *sb = static_cast<FSkyBox*>(tex);
|
||||
for (int i = 0; i<6; i++)
|
||||
{
|
||||
if (sb->faces[i])
|
||||
{
|
||||
int index = sb->faces[i]->id.GetIndex();
|
||||
int index = sb->faces[i]->GetID().GetIndex();
|
||||
texhitlist[index] |= FTextureManager::HIT_Flat;
|
||||
}
|
||||
}
|
||||
|
@ -181,17 +177,41 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
{
|
||||
if (!texhitlist[i])
|
||||
{
|
||||
if (tex->Material[0]) tex->Material[0]->Clean(true);
|
||||
tex->SystemTextures.Clean(true, false);
|
||||
}
|
||||
if (spritehitlist[i] == nullptr || (*spritehitlist[i]).CountUsed() == 0)
|
||||
{
|
||||
if (tex->Material[1]) tex->Material[1]->Clean(true);
|
||||
tex->SystemTextures.Clean(false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gl_precache)
|
||||
{
|
||||
FImageSource::BeginPrecaching();
|
||||
|
||||
// cache all used textures
|
||||
for (int i = cnt - 1; i >= 0; i--)
|
||||
{
|
||||
FTexture *tex = TexMan.ByIndex(i);
|
||||
if (tex != nullptr && tex->GetImage() != nullptr)
|
||||
{
|
||||
if (texhitlist[i] & (FTextureManager::HIT_Wall | FTextureManager::HIT_Flat | FTextureManager::HIT_Sky))
|
||||
{
|
||||
if (tex->GetImage() && tex->SystemTextures.GetHardwareTexture(0, false) == nullptr)
|
||||
{
|
||||
FImageSource::RegisterForPrecache(tex->GetImage());
|
||||
}
|
||||
}
|
||||
|
||||
// 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// cache all used textures
|
||||
for (int i = cnt - 1; i >= 0; i--)
|
||||
{
|
||||
|
@ -206,6 +226,9 @@ void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitl
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
FImageSource::EndPrecaching();
|
||||
|
||||
// cache all used models
|
||||
FModelRenderer *renderer = screen->CreateModelRenderer(-1);
|
||||
for (unsigned i = 0; i < Models.Size(); i++)
|
||||
|
|
130
src/hwrenderer/textures/hw_texcontainer.h
Normal file
130
src/hwrenderer/textures/hw_texcontainer.h
Normal file
|
@ -0,0 +1,130 @@
|
|||
#pragma once
|
||||
|
||||
#include "tarray.h"
|
||||
#include "hwrenderer/textures/hw_ihwtexture.h"
|
||||
|
||||
struct FTextureBuffer;
|
||||
class IHardwareTexture;
|
||||
|
||||
class FHardwareTextureContainer
|
||||
{
|
||||
public:
|
||||
enum
|
||||
{
|
||||
MAX_TEXTURES = 16
|
||||
};
|
||||
|
||||
private:
|
||||
struct TranslatedTexture
|
||||
{
|
||||
IHardwareTexture *hwTexture = nullptr;
|
||||
int translation = 0;
|
||||
|
||||
void Delete()
|
||||
{
|
||||
if (hwTexture) delete hwTexture;
|
||||
hwTexture = nullptr;
|
||||
}
|
||||
|
||||
~TranslatedTexture()
|
||||
{
|
||||
Delete();
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
TranslatedTexture hwDefTex[2];
|
||||
TArray<TranslatedTexture> hwTex_Translated;
|
||||
|
||||
TranslatedTexture * GetTexID(int translation, bool expanded)
|
||||
{
|
||||
translation = TranslationToIndex(translation);
|
||||
if (translation == 0)
|
||||
{
|
||||
return &hwDefTex[expanded];
|
||||
}
|
||||
|
||||
if (expanded) translation = -translation;
|
||||
// normally there aren't more than very few different
|
||||
// translations here so this isn't performance critical.
|
||||
unsigned index = hwTex_Translated.FindEx([=](auto &element)
|
||||
{
|
||||
return element.translation == translation;
|
||||
});
|
||||
if (index < hwTex_Translated.Size())
|
||||
{
|
||||
return &hwTex_Translated[index];
|
||||
}
|
||||
|
||||
int add = hwTex_Translated.Reserve(1);
|
||||
auto item = &hwTex_Translated[add];
|
||||
item->translation = translation;
|
||||
return item;
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
void Clean(bool cleannormal, bool cleanexpanded)
|
||||
{
|
||||
if (cleannormal) hwDefTex[0].Delete();
|
||||
if (cleanexpanded) hwDefTex[1].Delete();
|
||||
for (int i = hwTex_Translated.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
if (cleannormal && hwTex_Translated[i].translation > 0) hwTex_Translated.Delete(i);
|
||||
else if (cleanexpanded && hwTex_Translated[i].translation < 0) hwTex_Translated.Delete(i);
|
||||
}
|
||||
}
|
||||
|
||||
IHardwareTexture * GetHardwareTexture(int translation, bool expanded)
|
||||
{
|
||||
auto tt = GetTexID(translation, expanded);
|
||||
return tt->hwTexture;
|
||||
}
|
||||
|
||||
void AddHardwareTexture(int translation, bool expanded, IHardwareTexture *tex)
|
||||
{
|
||||
auto tt = GetTexID(translation, expanded);
|
||||
tt->Delete();
|
||||
tt->hwTexture =tex;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
//
|
||||
// Deletes all allocated resources and considers translations
|
||||
// This will only be called for sprites
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
void CleanUnused(SpriteHits &usedtranslations, bool expanded)
|
||||
{
|
||||
if (usedtranslations.CheckKey(0) == nullptr)
|
||||
{
|
||||
hwDefTex[expanded].Delete();
|
||||
}
|
||||
int fac = expanded ? -1 : 1;
|
||||
for (int i = hwTex_Translated.Size()-1; i>= 0; i--)
|
||||
{
|
||||
if (usedtranslations.CheckKey(hwTex_Translated[i].translation * fac) == nullptr)
|
||||
{
|
||||
hwTex_Translated.Delete(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int TranslationToIndex(int translation)
|
||||
{
|
||||
if (translation <= 0)
|
||||
{
|
||||
return -translation;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto remap = TranslationToTable(translation);
|
||||
return remap == nullptr ? 0 : remap->GetUniqueIndex();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
|
@ -92,7 +92,7 @@ CUSTOM_CVAR(Float,gl_texture_filter_anisotropic,8.0f,CVAR_ARCHIVE|CVAR_GLOBALCON
|
|||
|
||||
CCMD(gl_flush)
|
||||
{
|
||||
FMaterial::FlushAll();
|
||||
TexMan.FlushAll();
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINITCALL)
|
||||
|
@ -103,7 +103,7 @@ CUSTOM_CVAR(Int, gl_texture_filter, 4, CVAR_ARCHIVE|CVAR_GLOBALCONFIG|CVAR_NOINI
|
|||
|
||||
CUSTOM_CVAR(Bool, gl_texture_usehires, true, CVAR_ARCHIVE|CVAR_NOINITCALL)
|
||||
{
|
||||
FMaterial::FlushAll();
|
||||
TexMan.FlushAll();
|
||||
}
|
||||
|
||||
CVAR(Bool, gl_precache, false, CVAR_ARCHIVE)
|
||||
|
|
|
@ -169,7 +169,7 @@ void Draw2D(F2DDrawer *drawer, FRenderState &state)
|
|||
state.EnableTexture(true);
|
||||
|
||||
// Canvas textures are stored upside down
|
||||
if (cmd.mTexture->bHasCanvas)
|
||||
if (cmd.mTexture->isHardwareCanvas())
|
||||
{
|
||||
state.mTextureMatrix.loadIdentity();
|
||||
state.mTextureMatrix.scale(1.f, -1.f, 1.f);
|
||||
|
|
|
@ -162,11 +162,11 @@ void DIntermissionScreen::Drawer ()
|
|||
{
|
||||
if (!mFlatfill)
|
||||
{
|
||||
screen->DrawTexture (TexMan[mBackground], 0, 0, DTA_Fullscreen, true, TAG_DONE);
|
||||
screen->DrawTexture (TexMan.GetTexture(mBackground), 0, 0, DTA_Fullscreen, true, TAG_DONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
screen->FlatFill (0,0, SCREENWIDTH, SCREENHEIGHT, TexMan[mBackground]);
|
||||
screen->FlatFill (0,0, SCREENWIDTH, SCREENHEIGHT, TexMan.GetTexture(mBackground));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -176,7 +176,7 @@ void DIntermissionScreen::Drawer ()
|
|||
for (unsigned i=0; i < mOverlays.Size(); i++)
|
||||
{
|
||||
if (CheckOverlay(i))
|
||||
screen->DrawTexture (TexMan[mOverlays[i].mPic], mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, TAG_DONE);
|
||||
screen->DrawTexture (TexMan.GetTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, TAG_DONE);
|
||||
}
|
||||
if (!mFlatfill) screen->FillBorder (NULL);
|
||||
}
|
||||
|
@ -229,11 +229,11 @@ void DIntermissionScreenFader::Drawer ()
|
|||
if (mType == FADE_In) factor = 1.0 - factor;
|
||||
int color = MAKEARGB(int(factor*255), 0,0,0);
|
||||
|
||||
screen->DrawTexture (TexMan[mBackground], 0, 0, DTA_Fullscreen, true, DTA_ColorOverlay, color, TAG_DONE);
|
||||
screen->DrawTexture (TexMan.GetTexture(mBackground), 0, 0, DTA_Fullscreen, true, DTA_ColorOverlay, color, TAG_DONE);
|
||||
for (unsigned i=0; i < mOverlays.Size(); i++)
|
||||
{
|
||||
if (CheckOverlay(i))
|
||||
screen->DrawTexture (TexMan[mOverlays[i].mPic], mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, DTA_ColorOverlay, color, TAG_DONE);
|
||||
screen->DrawTexture (TexMan.GetTexture(mOverlays[i].mPic), mOverlays[i].x, mOverlays[i].y, DTA_320x200, true, DTA_ColorOverlay, color, TAG_DONE);
|
||||
}
|
||||
screen->FillBorder (NULL);
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ void DIntermissionScreenText::Drawer ()
|
|||
continue;
|
||||
}
|
||||
|
||||
pic = SmallFont->GetChar (c, &w);
|
||||
pic = SmallFont->GetChar (c, mTextColor, &w);
|
||||
w += kerning;
|
||||
w *= CleanXfac;
|
||||
if (cx + w > SCREENWIDTH)
|
||||
|
@ -568,13 +568,13 @@ void DIntermissionScreenCast::Drawer ()
|
|||
}
|
||||
|
||||
sprframe = &SpriteFrames[sprites[castsprite].spriteframes + caststate->GetFrame()];
|
||||
pic = TexMan(sprframe->Texture[0]);
|
||||
pic = TexMan.GetTexture(sprframe->Texture[0], true);
|
||||
|
||||
screen->DrawTexture (pic, 160, 170,
|
||||
DTA_320x200, true,
|
||||
DTA_FlipX, sprframe->Flip & 1,
|
||||
DTA_DestHeightF, pic->GetScaledHeightDouble() * castscale.Y,
|
||||
DTA_DestWidthF, pic->GetScaledWidthDouble() * castscale.X,
|
||||
DTA_DestHeightF, pic->GetDisplayHeightDouble() * castscale.Y,
|
||||
DTA_DestWidthF, pic->GetDisplayWidthDouble() * castscale.X,
|
||||
DTA_RenderStyle, mDefaults->RenderStyle,
|
||||
DTA_Alpha, mDefaults->Alpha,
|
||||
DTA_TranslationIndex, casttranslation,
|
||||
|
@ -611,13 +611,13 @@ int DIntermissionScreenScroller::Responder (event_t *ev)
|
|||
|
||||
void DIntermissionScreenScroller::Drawer ()
|
||||
{
|
||||
FTexture *tex = TexMan[mFirstPic];
|
||||
FTexture *tex2 = TexMan[mSecondPic];
|
||||
FTexture *tex = TexMan.GetTexture(mFirstPic);
|
||||
FTexture *tex2 = TexMan.GetTexture(mSecondPic);
|
||||
if (mTicker >= mScrollDelay && mTicker < mScrollDelay + mScrollTime && tex != NULL && tex2 != NULL)
|
||||
{
|
||||
|
||||
int fwidth = tex->GetScaledWidth();
|
||||
int fheight = tex->GetScaledHeight();
|
||||
int fwidth = tex->GetDisplayWidth();
|
||||
int fheight = tex->GetDisplayHeight();
|
||||
|
||||
double xpos1 = 0, ypos1 = 0, xpos2 = 0, ypos2 = 0;
|
||||
|
||||
|
|
|
@ -502,7 +502,7 @@ unsigned FSavegameManager::ExtractSaveData(int index)
|
|||
{
|
||||
SavePic = PNGTexture_CreateFromFile(png, node->Filename);
|
||||
delete png;
|
||||
if (SavePic->GetWidth() == 1 && SavePic->GetHeight() == 1)
|
||||
if (SavePic->GetDisplayWidth() == 1 && SavePic->GetDisplayHeight() == 1)
|
||||
{
|
||||
delete SavePic;
|
||||
SavePic = nullptr;
|
||||
|
|
|
@ -229,7 +229,7 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, do
|
|||
side_t *side = line->sidedef[sideno];
|
||||
FTextureID texnum = side->GetTexture(side_t::mid);
|
||||
if (!texnum.isValid()) return false;
|
||||
FTexture * tex= TexMan(texnum);
|
||||
FTexture * tex= TexMan.GetTexture(texnum, true);
|
||||
if (!tex) return false;
|
||||
|
||||
FTexCoordInfo tci;
|
||||
|
|
|
@ -3747,7 +3747,7 @@ void DLevelScript::ChangeFlat (int tag, int name, bool floorOrCeiling)
|
|||
if (flatname == NULL)
|
||||
return;
|
||||
|
||||
flat = TexMan.GetTexture (flatname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
flat = TexMan.GetTextureID(flatname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
FSectorTagIterator it(tag);
|
||||
while ((secnum = it.Next()) >= 0)
|
||||
|
@ -3779,7 +3779,7 @@ void DLevelScript::SetLineTexture (int lineid, int side, int position, int name)
|
|||
|
||||
side = !!side;
|
||||
|
||||
texture = TexMan.GetTexture (texname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
texture = TexMan.GetTextureID(texname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
FLineIdIterator itr(lineid);
|
||||
while ((linenum = itr.Next()) >= 0)
|
||||
|
@ -4574,10 +4574,10 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
|
|||
{
|
||||
return 0;
|
||||
}
|
||||
FTexture *tex = TexMan.FindTexture(FBehavior::StaticLookupString(string), ETextureType::Flat,
|
||||
FTextureID tex = TexMan.CheckForTexture(FBehavior::StaticLookupString(string), ETextureType::Flat,
|
||||
FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_DontCreate);
|
||||
|
||||
if (tex == NULL)
|
||||
if (!tex.Exists())
|
||||
{ // If the texture we want to check against doesn't exist, then
|
||||
// they're obviously not the same.
|
||||
return 0;
|
||||
|
@ -4596,7 +4596,7 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b
|
|||
NextHighestCeilingAt(actor->Sector, actor->X(), actor->Y(), actor->Z(), actor->Top(), 0, &resultsec, &resffloor);
|
||||
secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture;
|
||||
}
|
||||
return tex == TexMan[secpic];
|
||||
return tex == secpic;
|
||||
}
|
||||
|
||||
|
||||
|
@ -6690,7 +6690,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
auto a = SingleActorFromTID(args[0], activator);
|
||||
if (a != nullptr)
|
||||
{
|
||||
return GlobalACSStrings.AddString(TexMan[a->floorpic]->Name);
|
||||
return GlobalACSStrings.AddString(TexMan.GetTexture(a->floorpic)->GetName());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -9865,11 +9865,11 @@ scriptwait:
|
|||
sky2name = FBehavior::StaticLookupString (STACK(1));
|
||||
if (sky1name[0] != 0)
|
||||
{
|
||||
sky1texture = level.skytexture1 = TexMan.GetTexture (sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
sky1texture = level.skytexture1 = TexMan.GetTextureID(sky1name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
}
|
||||
if (sky2name[0] != 0)
|
||||
{
|
||||
sky2texture = level.skytexture2 = TexMan.GetTexture (sky2name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
sky2texture = level.skytexture2 = TexMan.GetTextureID(sky2name, ETextureType::Wall, FTextureManager::TEXMAN_Overridable|FTextureManager::TEXMAN_ReturnFirst);
|
||||
}
|
||||
R_InitSkyMap ();
|
||||
sp -= 2;
|
||||
|
@ -9900,7 +9900,7 @@ scriptwait:
|
|||
}
|
||||
else
|
||||
{
|
||||
FCanvasTextureInfo::Add (camera, picnum, STACK(1));
|
||||
level.canvasTextureInfo.Add(camera, picnum, STACK(1));
|
||||
}
|
||||
}
|
||||
sp -= 3;
|
||||
|
|
|
@ -293,8 +293,8 @@ void DDoor::DoorSound(bool raise, DSeqNode *curseq) const
|
|||
if (line->backsector == NULL)
|
||||
continue;
|
||||
|
||||
FTexture *tex = TexMan[line->sidedef[0]->GetTexture(side_t::top)];
|
||||
texname = tex ? tex->Name.GetChars() : NULL;
|
||||
FTexture *tex = TexMan.GetTexture(line->sidedef[0]->GetTexture(side_t::top));
|
||||
texname = tex ? tex->GetName().GetChars() : NULL;
|
||||
if (texname != NULL && texname[0] == 'D' && texname[1] == 'O' && texname[2] == 'R')
|
||||
{
|
||||
switch (texname[3])
|
||||
|
@ -715,9 +715,8 @@ DAnimatedDoor::DAnimatedDoor (sector_t *sec, line_t *line, int speed, int delay,
|
|||
|
||||
picnum = tex1[side_t::top].texture;
|
||||
|
||||
// don't forget texture scaling here!
|
||||
FTexture *tex = TexMan[picnum];
|
||||
topdist = tex ? tex->GetScaledHeight() : 64;
|
||||
FTexture *tex = TexMan.GetTexture(picnum);
|
||||
topdist = tex ? tex->GetDisplayHeight() : 64;
|
||||
|
||||
topdist = m_Sector->ceilingplane.fD() - topdist * m_Sector->ceilingplane.fC();
|
||||
|
||||
|
|
|
@ -59,10 +59,9 @@ FRandom pr_railtrail("RailTrail");
|
|||
#define FADEFROMTTL(a) (1.f/(a))
|
||||
|
||||
// [RH] particle globals
|
||||
uint16_t NumParticles;
|
||||
uint16_t ActiveParticles;
|
||||
uint16_t InactiveParticles;
|
||||
particle_t *Particles;
|
||||
uint32_t ActiveParticles;
|
||||
uint32_t InactiveParticles;
|
||||
TArray<particle_t> Particles;
|
||||
TArray<uint16_t> ParticlesInSubsec;
|
||||
|
||||
static int grey1, grey2, grey3, grey4, red, green, blue, yellow, black,
|
||||
|
@ -105,13 +104,13 @@ static const struct ColorList {
|
|||
|
||||
inline particle_t *NewParticle (void)
|
||||
{
|
||||
particle_t *result = NULL;
|
||||
particle_t *result = nullptr;
|
||||
if (InactiveParticles != NO_PARTICLE)
|
||||
{
|
||||
result = Particles + InactiveParticles;
|
||||
result = &Particles[InactiveParticles];
|
||||
InactiveParticles = result->tnext;
|
||||
result->tnext = ActiveParticles;
|
||||
ActiveParticles = uint16_t(result - Particles);
|
||||
ActiveParticles = uint32_t(result - Particles.Data());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -120,7 +119,6 @@ inline particle_t *NewParticle (void)
|
|||
// [RH] Particle functions
|
||||
//
|
||||
void P_InitParticles ();
|
||||
void P_DeinitParticles ();
|
||||
|
||||
// [BC] Allow the maximum number of particles to be specified by a cvar (so people
|
||||
// with lots of nice hardware can have lots of particles!).
|
||||
|
@ -135,7 +133,6 @@ CUSTOM_CVAR( Int, r_maxparticles, 4000, CVAR_ARCHIVE )
|
|||
|
||||
if ( gamestate != GS_STARTUP )
|
||||
{
|
||||
P_DeinitParticles( );
|
||||
P_InitParticles( );
|
||||
}
|
||||
}
|
||||
|
@ -152,33 +149,21 @@ void P_InitParticles ()
|
|||
num = r_maxparticles;
|
||||
|
||||
// This should be good, but eh...
|
||||
NumParticles = (uint16_t)clamp<int>(num, 100, 65535);
|
||||
int NumParticles = clamp<int>(num, 100, 65535);
|
||||
|
||||
P_DeinitParticles();
|
||||
Particles = new particle_t[NumParticles];
|
||||
Particles.Resize(NumParticles);
|
||||
P_ClearParticles ();
|
||||
atterm (P_DeinitParticles);
|
||||
}
|
||||
|
||||
void P_DeinitParticles()
|
||||
{
|
||||
if (Particles != NULL)
|
||||
{
|
||||
delete[] Particles;
|
||||
Particles = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void P_ClearParticles ()
|
||||
{
|
||||
int i;
|
||||
|
||||
memset (Particles, 0, NumParticles * sizeof(particle_t));
|
||||
int i = 0;
|
||||
memset (Particles.Data(), 0, Particles.Size() * sizeof(particle_t));
|
||||
ActiveParticles = NO_PARTICLE;
|
||||
InactiveParticles = 0;
|
||||
for (i = 0; i < NumParticles-1; i++)
|
||||
Particles[i].tnext = i + 1;
|
||||
Particles[i].tnext = NO_PARTICLE;
|
||||
for (auto &p : Particles)
|
||||
p.tnext = ++i;
|
||||
Particles.Last().tnext = NO_PARTICLE;
|
||||
}
|
||||
|
||||
// Group particles by subsectors. Because particles are always
|
||||
|
@ -255,7 +240,7 @@ void P_ThinkParticles ()
|
|||
prev = NULL;
|
||||
while (i != NO_PARTICLE)
|
||||
{
|
||||
particle = Particles + i;
|
||||
particle = &Particles[i];
|
||||
i = particle->tnext;
|
||||
if (!particle->notimefreeze && ((bglobal.freeze) || (level.flags2 & LEVEL2_FROZEN)))
|
||||
{
|
||||
|
@ -274,7 +259,7 @@ void P_ThinkParticles ()
|
|||
else
|
||||
ActiveParticles = i;
|
||||
particle->tnext = InactiveParticles;
|
||||
InactiveParticles = (int)(particle - Particles);
|
||||
InactiveParticles = (int)(particle - Particles.Data());
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ struct particle_t
|
|||
uint16_t snext;
|
||||
};
|
||||
|
||||
extern particle_t *Particles;
|
||||
extern TArray<particle_t> Particles;
|
||||
extern TArray<uint16_t> ParticlesInSubsec;
|
||||
|
||||
const uint16_t NO_PARTICLE = 0xffff;
|
||||
|
|
|
@ -1012,7 +1012,7 @@ void G_SerializeLevel(FSerializer &arc, bool hubload)
|
|||
StatusBar->SerializeMessages(arc);
|
||||
AM_SerializeMarkers(arc);
|
||||
FRemapTable::StaticSerializeTranslations(arc);
|
||||
FCanvasTextureInfo::Serialize(arc);
|
||||
level.canvasTextureInfo.Serialize(arc);
|
||||
P_SerializePlayers(arc, hubload);
|
||||
P_SerializeSounds(arc);
|
||||
|
||||
|
|
|
@ -477,10 +477,10 @@ static inline void CheckShortestTex (FTextureID texnum, double &minsize)
|
|||
{
|
||||
if (texnum.isValid() || (texnum.isNull() && (i_compatflags & COMPATF_SHORTTEX)))
|
||||
{
|
||||
FTexture *tex = TexMan[texnum];
|
||||
FTexture *tex = TexMan.GetTexture(texnum);
|
||||
if (tex != NULL)
|
||||
{
|
||||
double h = tex->GetScaledHeight();
|
||||
double h = tex->GetDisplayHeight();
|
||||
if (h < minsize)
|
||||
{
|
||||
minsize = h;
|
||||
|
@ -501,7 +501,7 @@ double FindShortestTextureAround (sector_t *sec)
|
|||
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::bottom), minsize);
|
||||
}
|
||||
}
|
||||
return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight();
|
||||
return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -526,7 +526,7 @@ double FindShortestUpperAround (sector_t *sec)
|
|||
CheckShortestTex (check->sidedef[1]->GetTexture(side_t::top), minsize);
|
||||
}
|
||||
}
|
||||
return minsize < FLT_MAX ? minsize : TexMan[0]->GetHeight();
|
||||
return minsize < FLT_MAX ? minsize : TexMan.ByIndex(0)->GetDisplayHeight();
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1144,14 +1144,14 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac)
|
|||
auto c = planes[sector_t::floor].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
||||
FTexture *tex = TexMan.GetTexture(GetTexture(sector_t::floor));
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor));
|
||||
if (!tex->isAutoGlowing()) tex = TexMan.GetTexture(GetTexture(sector_t::floor), true);
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
tex->GetGlowColor(bottomglowcolor);
|
||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
||||
bottomglowcolor[3] = (float)tex->GetGlowHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1189,15 +1189,15 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac)
|
|||
auto c = planes[sector_t::ceiling].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[GetTexture(sector_t::ceiling)];
|
||||
FTexture *tex = TexMan.GetTexture(GetTexture(sector_t::ceiling));
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::ceiling));
|
||||
if (!tex->isAutoGlowing()) tex = TexMan.GetTexture(GetTexture(sector_t::ceiling), true);
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
ret = true;
|
||||
tex->GetGlowColor(topglowcolor);
|
||||
topglowcolor[3] = (float)tex->GlowHeight;
|
||||
topglowcolor[3] = (float)tex->GetGlowHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1213,15 +1213,15 @@ double GetFriction(const sector_t *self, int plane, double *pMoveFac)
|
|||
c = planes[sector_t::floor].GlowColor;
|
||||
if (c == 0)
|
||||
{
|
||||
FTexture *tex = TexMan[GetTexture(sector_t::floor)];
|
||||
FTexture *tex = TexMan.GetTexture(GetTexture(sector_t::floor));
|
||||
if (tex != NULL && tex->isGlowing())
|
||||
{
|
||||
if (!tex->bAutoGlowing) tex = TexMan(GetTexture(sector_t::floor));
|
||||
if (!tex->isAutoGlowing()) tex = TexMan.GetTexture(GetTexture(sector_t::floor), true);
|
||||
if (tex->isGlowing()) // recheck the current animation frame.
|
||||
{
|
||||
ret = true;
|
||||
tex->GetGlowColor(bottomglowcolor);
|
||||
bottomglowcolor[3] = (float)tex->GlowHeight;
|
||||
bottomglowcolor[3] = (float)tex->GetGlowHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1397,8 +1397,8 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags)
|
|||
|
||||
if ((flags ^ (NOT_BOTTOM | NOT_MIDDLE | NOT_TOP)) != 0)
|
||||
{
|
||||
picnum1 = TexMan.GetTexture(fromname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture(toname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
picnum1 = TexMan.GetTextureID(fromname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTextureID(toname, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (auto &side : level.sides)
|
||||
{
|
||||
|
@ -1414,8 +1414,8 @@ void P_ReplaceTextures(const char *fromname, const char *toname, int flags)
|
|||
}
|
||||
if ((flags ^ (NOT_FLOOR | NOT_CEILING)) != 0)
|
||||
{
|
||||
picnum1 = TexMan.GetTexture(fromname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTexture(toname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
picnum1 = TexMan.GetTextureID(fromname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
picnum2 = TexMan.GetTextureID(toname, ETextureType::Flat, FTextureManager::TEXMAN_Overridable);
|
||||
|
||||
for (auto &sec : level.sectors)
|
||||
{
|
||||
|
|
|
@ -3408,6 +3408,45 @@ void P_GetPolySpots (MapData * map, TArray<FNodeBuilder::FPolyStart> &spots, TAr
|
|||
//===========================================================================
|
||||
void hw_PrecacheTexture(uint8_t *texhitlist, TMap<PClassActor*, bool> &actorhitlist);
|
||||
|
||||
static void AddToList(uint8_t *hitlist, FTextureID texid, int bitmask)
|
||||
{
|
||||
if (hitlist[texid.GetIndex()] & bitmask) return; // already done, no need to process everything again.
|
||||
hitlist[texid.GetIndex()] |= (uint8_t)bitmask;
|
||||
|
||||
for (auto anim : TexMan.mAnimations)
|
||||
{
|
||||
if (texid == anim->BasePic || (!anim->bDiscrete && anim->BasePic < texid && texid < anim->BasePic + anim->NumFrames))
|
||||
{
|
||||
for (int i = anim->BasePic.GetIndex(); i < anim->BasePic.GetIndex() + anim->NumFrames; i++)
|
||||
{
|
||||
hitlist[i] |= (uint8_t)bitmask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
auto switchdef = TexMan.FindSwitch(texid);
|
||||
if (switchdef)
|
||||
{
|
||||
for (int i = 0; i < switchdef->NumFrames; i++)
|
||||
{
|
||||
hitlist[switchdef->frames[i].Texture.GetIndex()] |= (uint8_t)bitmask;
|
||||
}
|
||||
for (int i = 0; i < switchdef->PairDef->NumFrames; i++)
|
||||
{
|
||||
hitlist[switchdef->frames[i].Texture.GetIndex()] |= (uint8_t)bitmask;
|
||||
}
|
||||
}
|
||||
|
||||
auto adoor = TexMan.FindAnimatedDoor(texid);
|
||||
if (adoor)
|
||||
{
|
||||
for (int i = 0; i < adoor->NumTextureFrames; i++)
|
||||
{
|
||||
hitlist[adoor->TextureFrames[i].GetIndex()] |= (uint8_t)bitmask;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void P_PrecacheLevel()
|
||||
{
|
||||
int i;
|
||||
|
@ -3443,15 +3482,15 @@ static void P_PrecacheLevel()
|
|||
|
||||
for (i = level.sectors.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[level.sectors[i].GetTexture(sector_t::floor).GetIndex()] |= FTextureManager::HIT_Flat;
|
||||
hitlist[level.sectors[i].GetTexture(sector_t::ceiling).GetIndex()] |= FTextureManager::HIT_Flat;
|
||||
AddToList(hitlist, level.sectors[i].GetTexture(sector_t::floor), FTextureManager::HIT_Flat);
|
||||
AddToList(hitlist, level.sectors[i].GetTexture(sector_t::ceiling), FTextureManager::HIT_Flat);
|
||||
}
|
||||
|
||||
for (i = level.sides.Size() - 1; i >= 0; i--)
|
||||
{
|
||||
hitlist[level.sides[i].GetTexture(side_t::top).GetIndex()] |= FTextureManager::HIT_Wall;
|
||||
hitlist[level.sides[i].GetTexture(side_t::mid).GetIndex()] |= FTextureManager::HIT_Wall;
|
||||
hitlist[level.sides[i].GetTexture(side_t::bottom).GetIndex()] |= FTextureManager::HIT_Wall;
|
||||
AddToList(hitlist, level.sides[i].GetTexture(side_t::top), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist, level.sides[i].GetTexture(side_t::mid), FTextureManager::HIT_Wall);
|
||||
AddToList(hitlist, level.sides[i].GetTexture(side_t::bottom), FTextureManager::HIT_Wall);
|
||||
}
|
||||
|
||||
// Sky texture is always present.
|
||||
|
@ -3463,22 +3502,22 @@ static void P_PrecacheLevel()
|
|||
|
||||
if (sky1texture.isValid())
|
||||
{
|
||||
hitlist[sky1texture.GetIndex()] |= FTextureManager::HIT_Sky;
|
||||
AddToList(hitlist, sky1texture, FTextureManager::HIT_Sky);
|
||||
}
|
||||
if (sky2texture.isValid())
|
||||
{
|
||||
hitlist[sky2texture.GetIndex()] |= FTextureManager::HIT_Sky;
|
||||
AddToList(hitlist, sky2texture, FTextureManager::HIT_Sky);
|
||||
}
|
||||
|
||||
for (auto n : gameinfo.PrecachedTextures)
|
||||
{
|
||||
FTextureID tex = TexMan.CheckForTexture(n, ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst);
|
||||
if (tex.Exists()) hitlist[tex.GetIndex()] |= FTextureManager::HIT_Wall;
|
||||
if (tex.Exists()) AddToList(hitlist, tex, FTextureManager::HIT_Wall);
|
||||
}
|
||||
for (unsigned i = 0; i < level.info->PrecacheTextures.Size(); i++)
|
||||
{
|
||||
FTextureID tex = TexMan.CheckForTexture(level.info->PrecacheTextures[i], ETextureType::Wall, FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ReturnFirst);
|
||||
if (tex.Exists()) hitlist[tex.GetIndex()] |= FTextureManager::HIT_Wall;
|
||||
if (tex.Exists()) AddToList(hitlist, tex, FTextureManager::HIT_Wall);
|
||||
}
|
||||
|
||||
// This is just a temporary solution, until the hardware renderer's texture manager is in a better state.
|
||||
|
@ -3516,7 +3555,6 @@ void P_FreeLevelData ()
|
|||
MapThingsUserDataIndex.Clear();
|
||||
MapThingsUserData.Clear();
|
||||
linemap.Clear();
|
||||
FCanvasTextureInfo::EmptyList();
|
||||
R_FreePastViewers();
|
||||
P_ClearUDMFKeys();
|
||||
|
||||
|
@ -3555,6 +3593,7 @@ void P_FreeLevelData ()
|
|||
|
||||
|
||||
FBehavior::StaticUnloadModules ();
|
||||
level.canvasTextureInfo.EmptyList();
|
||||
level.sections.Clear();
|
||||
level.segs.Clear();
|
||||
level.sectors.Clear();
|
||||
|
|
|
@ -47,7 +47,7 @@ void PolyDrawArgs::SetTexture(const uint8_t *texels, int width, int height)
|
|||
mTranslation = nullptr;
|
||||
}
|
||||
|
||||
void PolyDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
||||
void PolyDrawArgs::SetTexture(FSoftwareTexture *texture, FRenderStyle style)
|
||||
{
|
||||
mTexture = texture;
|
||||
mTextureWidth = texture->GetWidth();
|
||||
|
@ -59,7 +59,7 @@ void PolyDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
|||
mTranslation = nullptr;
|
||||
}
|
||||
|
||||
void PolyDrawArgs::SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style)
|
||||
void PolyDrawArgs::SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style)
|
||||
{
|
||||
// Alphatexture overrides translations.
|
||||
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
|
||||
|
@ -140,7 +140,7 @@ void PolyDrawArgs::SetColor(uint32_t bgra, uint8_t palindex)
|
|||
}
|
||||
}
|
||||
|
||||
void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *tex, bool fullbright)
|
||||
void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *tex, bool fullbright)
|
||||
{
|
||||
SetTexture(tex, translationID, renderstyle);
|
||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||
|
@ -203,7 +203,7 @@ void PolyDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint3
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RectDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
||||
void RectDrawArgs::SetTexture(FSoftwareTexture *texture, FRenderStyle style)
|
||||
{
|
||||
mTexture = texture;
|
||||
mTextureWidth = texture->GetWidth();
|
||||
|
@ -215,7 +215,7 @@ void RectDrawArgs::SetTexture(FTexture *texture, FRenderStyle style)
|
|||
mTranslation = nullptr;
|
||||
}
|
||||
|
||||
void RectDrawArgs::SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style)
|
||||
void RectDrawArgs::SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style)
|
||||
{
|
||||
// Alphatexture overrides translations.
|
||||
if (translationID != 0xffffffff && translationID != 0 && !(style.Flags & STYLEF_RedIsAlpha))
|
||||
|
@ -291,7 +291,7 @@ void RectDrawArgs::Draw(PolyRenderThread *thread, double x0, double x1, double y
|
|||
thread->DrawQueue->Push<DrawRectCommand>(*this);
|
||||
}
|
||||
|
||||
void RectDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *tex, bool fullbright)
|
||||
void RectDrawArgs::SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *tex, bool fullbright)
|
||||
{
|
||||
SetTexture(tex, translationID, renderstyle);
|
||||
SetColor(0xff000000 | fillcolor, fillcolor >> 24);
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
#include "screen_triangle.h"
|
||||
|
||||
class PolyRenderThread;
|
||||
class FTexture;
|
||||
class FSoftwareTexture;
|
||||
class Mat4f;
|
||||
|
||||
enum class PolyDrawMode
|
||||
|
@ -67,8 +67,8 @@ class PolyDrawArgs
|
|||
public:
|
||||
void SetClipPlane(int index, const PolyClipPlane &plane) { mClipPlane[index] = plane; }
|
||||
void SetTexture(const uint8_t *texels, int width, int height);
|
||||
void SetTexture(FTexture *texture, FRenderStyle style);
|
||||
void SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style);
|
||||
void SetTexture(FSoftwareTexture *texture, FRenderStyle style);
|
||||
void SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style);
|
||||
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel, double globVis, bool fixed);
|
||||
void SetDepthTest(bool enable) { mDepthTest = enable; }
|
||||
void SetStencilTestValue(uint8_t stencilTestValue) { mStencilTestValue = stencilTestValue; }
|
||||
|
@ -76,7 +76,7 @@ public:
|
|||
void SetWriteStencil(bool enable, uint8_t stencilWriteValue = 0) { mWriteStencil = enable; mStencilWriteValue = stencilWriteValue; }
|
||||
void SetWriteDepth(bool enable) { mWriteDepth = enable; }
|
||||
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
|
||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright);
|
||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *texture, bool fullbright);
|
||||
void SetColor(uint32_t bgra, uint8_t palindex);
|
||||
void SetLights(PolyLight *lights, int numLights) { mLights = lights; mNumLights = numLights; }
|
||||
void SetDynLightColor(uint32_t color) { mDynLightColor = color; }
|
||||
|
@ -85,7 +85,7 @@ public:
|
|||
|
||||
bool WriteColor() const { return mWriteColor; }
|
||||
|
||||
FTexture *Texture() const { return mTexture; }
|
||||
FSoftwareTexture *Texture() const { return mTexture; }
|
||||
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
||||
int TextureWidth() const { return mTextureWidth; }
|
||||
int TextureHeight() const { return mTextureHeight; }
|
||||
|
@ -131,7 +131,7 @@ private:
|
|||
bool mWriteStencil = true;
|
||||
bool mWriteColor = true;
|
||||
bool mWriteDepth = true;
|
||||
FTexture *mTexture = nullptr;
|
||||
FSoftwareTexture *mTexture = nullptr;
|
||||
const uint8_t *mTexturePixels = nullptr;
|
||||
int mTextureWidth = 0;
|
||||
int mTextureHeight = 0;
|
||||
|
@ -166,15 +166,15 @@ private:
|
|||
class RectDrawArgs
|
||||
{
|
||||
public:
|
||||
void SetTexture(FTexture *texture, FRenderStyle style);
|
||||
void SetTexture(FTexture *texture, uint32_t translationID, FRenderStyle style);
|
||||
void SetTexture(FSoftwareTexture *texture, FRenderStyle style);
|
||||
void SetTexture(FSoftwareTexture *texture, uint32_t translationID, FRenderStyle style);
|
||||
void SetLight(FSWColormap *basecolormap, uint32_t lightlevel);
|
||||
void SetStyle(TriBlendMode blendmode, double alpha = 1.0) { mBlendMode = blendmode; mAlpha = (uint32_t)(alpha * 256.0 + 0.5); }
|
||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FTexture *texture, bool fullbright);
|
||||
void SetStyle(const FRenderStyle &renderstyle, double alpha, uint32_t fillcolor, uint32_t translationID, FSoftwareTexture *texture, bool fullbright);
|
||||
void SetColor(uint32_t bgra, uint8_t palindex);
|
||||
void Draw(PolyRenderThread *thread, double x0, double x1, double y0, double y1, double u0, double u1, double v0, double v1);
|
||||
|
||||
FTexture *Texture() const { return mTexture; }
|
||||
FSoftwareTexture *Texture() const { return mTexture; }
|
||||
const uint8_t *TexturePixels() const { return mTexturePixels; }
|
||||
int TextureWidth() const { return mTextureWidth; }
|
||||
int TextureHeight() const { return mTextureHeight; }
|
||||
|
@ -207,7 +207,7 @@ public:
|
|||
float V1() const { return mV1; }
|
||||
|
||||
private:
|
||||
FTexture *mTexture = nullptr;
|
||||
FSoftwareTexture *mTexture = nullptr;
|
||||
const uint8_t *mTexturePixels = nullptr;
|
||||
int mTextureWidth = 0;
|
||||
int mTextureHeight = 0;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include "../swrenderer/textures/r_swtexture.h"
|
||||
#include "poly_renderer.cpp"
|
||||
#include "poly_renderthread.cpp"
|
||||
#include "drawers/poly_buffer.cpp"
|
||||
|
|
|
@ -75,7 +75,7 @@ void PolyRenderThread::FlushDrawQueue()
|
|||
}
|
||||
|
||||
static std::mutex loadmutex;
|
||||
void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
|
||||
void PolyRenderThread::PrepareTexture(FSoftwareTexture *texture, FRenderStyle style)
|
||||
{
|
||||
if (texture == nullptr)
|
||||
return;
|
||||
|
@ -90,14 +90,18 @@ void PolyRenderThread::PrepareTexture(FTexture *texture, FRenderStyle style)
|
|||
|
||||
std::unique_lock<std::mutex> lock(loadmutex);
|
||||
|
||||
texture->GetPixels(style);
|
||||
const FTexture::Span *spans;
|
||||
texture->GetColumn(style, 0, &spans);
|
||||
const FSoftwareTextureSpan *spans;
|
||||
if (PolyRenderer::Instance()->RenderTarget->IsBgra())
|
||||
{
|
||||
texture->GetPixelsBgra();
|
||||
texture->GetColumnBgra(0, &spans);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool alpha = !!(style.Flags & STYLEF_RedIsAlpha);
|
||||
texture->GetPixels(alpha);
|
||||
texture->GetColumn(alpha, 0, &spans);
|
||||
}
|
||||
}
|
||||
|
||||
static std::mutex polyobjmutex;
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
TArray<ADynamicLight*> AddedLightsArray;
|
||||
|
||||
// Make sure texture can accessed safely
|
||||
void PrepareTexture(FTexture *texture, FRenderStyle style);
|
||||
void PrepareTexture(FSoftwareTexture *texture, FRenderStyle style);
|
||||
|
||||
// Setup poly object in a threadsafe manner
|
||||
void PreparePolyObject(subsector_t *sub);
|
||||
|
|
|
@ -49,9 +49,11 @@ void RenderPolyDecal::Render(PolyRenderThread *thread, DBaseDecal *decal, const
|
|||
if (decal->RenderFlags & RF_INVISIBLE || !viewactive || !decal->PicNum.isValid())
|
||||
return;
|
||||
|
||||
FTexture *tex = TexMan(decal->PicNum, true);
|
||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
||||
FTexture *ttex = TexMan.GetPalettedTexture(decal->PicNum, true);
|
||||
if (ttex == nullptr || !ttex->isValid())
|
||||
return;
|
||||
|
||||
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||
|
||||
sector_t *front, *back;
|
||||
GetDecalSectors(decal, line, &front, &back);
|
||||
|
@ -73,16 +75,16 @@ void RenderPolyDecal::Render(PolyRenderThread *thread, DBaseDecal *decal, const
|
|||
|
||||
bool flipTextureX = (decal->RenderFlags & RF_XFLIP) == RF_XFLIP;
|
||||
double u_left = flipTextureX ? 1.0 : 0.0;
|
||||
double u_right = flipTextureX ? 1.0 - tex->Scale.X : tex->Scale.X;
|
||||
double u_right = flipTextureX ? 1.0 - tex->GetScale().X : tex->GetScale().X;
|
||||
double u_unit = (u_right - u_left) / (edge_left + edge_right);
|
||||
|
||||
double zpos = GetDecalZ(decal, line, front, back);
|
||||
double spriteHeight = decal->ScaleY / tex->Scale.Y * tex->GetHeight();
|
||||
double spriteHeight = decal->ScaleY / tex->GetScale().Y * tex->GetHeight();
|
||||
double ztop = zpos + spriteHeight - spriteHeight * 0.5;
|
||||
double zbottom = zpos - spriteHeight * 0.5;
|
||||
|
||||
double v_top = 0.0;
|
||||
double v_bottom = tex->Scale.Y;
|
||||
double v_bottom = tex->GetScale().Y;
|
||||
double v_unit = (v_bottom - v_top) / (zbottom - ztop);
|
||||
|
||||
// Clip decal to wall part
|
||||
|
|
|
@ -66,8 +66,8 @@ static bool isBright(DPSprite *psp)
|
|||
FTextureID lump = sprites[psp->GetSprite()].GetSpriteFrame(psp->GetFrame(), 0, 0., nullptr);
|
||||
if (lump.isValid())
|
||||
{
|
||||
FTexture * tex = TexMan(lump);
|
||||
if (tex) disablefullbright = tex->bDisableFullbright;
|
||||
FTexture * tex = TexMan.GetPalettedTexture(lump, true);
|
||||
if (tex) disablefullbright = tex->isFullbrightDisabled();
|
||||
}
|
||||
return psp->GetState()->GetFullbright() && !disablefullbright;
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ void PolyModelRenderer::SetInterpolation(double interpolation)
|
|||
|
||||
void PolyModelRenderer::SetMaterial(FTexture *skin, bool clampNoFilter, int translation)
|
||||
{
|
||||
SkinTexture = skin;
|
||||
SkinTexture = skin? skin->GetSoftwareTexture() : nullptr;
|
||||
}
|
||||
|
||||
void PolyModelRenderer::SetTransform()
|
||||
|
|
|
@ -65,7 +65,7 @@ public:
|
|||
uint32_t Translation;
|
||||
|
||||
Mat4f ObjectToWorld;
|
||||
FTexture *SkinTexture = nullptr;
|
||||
FSoftwareTexture *SkinTexture = nullptr;
|
||||
unsigned int *IndexBuffer = nullptr;
|
||||
FModelVertex *VertexBuffer = nullptr;
|
||||
float InterpolationFactor = 0.0;
|
||||
|
|
|
@ -66,11 +66,11 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyTransferH
|
|||
FTextureID picnum = fakeflat.FrontSector->GetTexture(ceiling ? sector_t::ceiling : sector_t::floor);
|
||||
if (picnum != skyflatnum)
|
||||
{
|
||||
FTexture *tex = TexMan(picnum);
|
||||
if (!tex || tex->UseType == ETextureType::Null)
|
||||
FTexture *tex = TexMan.GetPalettedTexture(picnum, true);
|
||||
if (!tex || !tex->isValid())
|
||||
return;
|
||||
|
||||
PolyPlaneUVTransform transform = PolyPlaneUVTransform(ceiling ? fakeflat.FrontSector->planes[sector_t::ceiling].xform : fakeflat.FrontSector->planes[sector_t::floor].xform, tex);
|
||||
PolyPlaneUVTransform transform = PolyPlaneUVTransform(ceiling ? fakeflat.FrontSector->planes[sector_t::ceiling].xform : fakeflat.FrontSector->planes[sector_t::floor].xform, tex->GetSoftwareTexture());
|
||||
TriVertex *vertices = CreatePlaneVertices(thread, fakeflat.Subsector, transform, ceiling ? fakeflat.FrontSector->ceilingplane : fakeflat.FrontSector->floorplane);
|
||||
|
||||
PolyDrawArgs args;
|
||||
|
@ -78,7 +78,7 @@ void RenderPolyPlane::RenderNormal(PolyRenderThread *thread, const PolyTransferH
|
|||
SetDynLights(thread, args, fakeflat.Subsector, ceiling);
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetTexture(tex, DefaultRenderStyle());
|
||||
args.SetTexture(tex->GetSoftwareTexture(), DefaultRenderStyle());
|
||||
args.SetStyle(TriBlendMode::Opaque);
|
||||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, fakeflat.Subsector->numlines, PolyDrawMode::TriangleFan);
|
||||
}
|
||||
|
@ -389,12 +389,12 @@ TriVertex *RenderPolyPlane::CreateSkyPlaneVertices(PolyRenderThread *thread, sub
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PolyPlaneUVTransform::PolyPlaneUVTransform(const FTransform &transform, FTexture *tex)
|
||||
PolyPlaneUVTransform::PolyPlaneUVTransform(const FTransform &transform, FSoftwareTexture *tex)
|
||||
{
|
||||
if (tex)
|
||||
{
|
||||
xscale = (float)(transform.xScale * tex->Scale.X / tex->GetWidth());
|
||||
yscale = (float)(transform.yScale * tex->Scale.Y / tex->GetHeight());
|
||||
xscale = (float)(transform.xScale * tex->GetScale().X / tex->GetWidth());
|
||||
yscale = (float)(transform.yScale * tex->GetScale().Y / tex->GetHeight());
|
||||
|
||||
double planeang = (transform.Angle + transform.baseAngle).Radians();
|
||||
cosine = (float)cos(planeang);
|
||||
|
@ -510,8 +510,8 @@ void Render3DFloorPlane::RenderPlanes(PolyRenderThread *thread, subsector_t *sub
|
|||
void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
||||
{
|
||||
FTextureID picnum = ceiling ? *fakeFloor->bottom.texture : *fakeFloor->top.texture;
|
||||
FTexture *tex = TexMan(picnum);
|
||||
if (tex->UseType == ETextureType::Null)
|
||||
auto tex = TexMan.GetPalettedTexture(picnum, true);
|
||||
if (!tex->isValid())
|
||||
return;
|
||||
|
||||
PolyCameraLight *cameraLight = PolyCameraLight::Instance();
|
||||
|
@ -528,7 +528,7 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
|||
int actualextralight = foggy ? 0 : PolyRenderer::Instance()->Viewpoint.extralight << 4;
|
||||
lightlevel = clamp(lightlevel + actualextralight, 0, 255);
|
||||
|
||||
PolyPlaneUVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex);
|
||||
PolyPlaneUVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex->GetSoftwareTexture());
|
||||
|
||||
TriVertex *vertices = thread->FrameMemory->AllocMemory<TriVertex>(sub->numlines);
|
||||
if (ceiling)
|
||||
|
@ -562,6 +562,6 @@ void Render3DFloorPlane::Render(PolyRenderThread *thread)
|
|||
}
|
||||
args.SetStencilTestValue(stencilValue);
|
||||
args.SetWriteStencil(true, stencilValue + 1);
|
||||
args.SetTexture(tex, DefaultRenderStyle());
|
||||
args.SetTexture(tex->GetSoftwareTexture(), DefaultRenderStyle());
|
||||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, vertices, sub->numlines, PolyDrawMode::TriangleFan);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ class PolyDrawSectorPortal;
|
|||
class PolyPlaneUVTransform
|
||||
{
|
||||
public:
|
||||
PolyPlaneUVTransform(const FTransform &transform, FTexture *tex);
|
||||
PolyPlaneUVTransform(const FTransform &transform, FSoftwareTexture *tex);
|
||||
|
||||
TriVertex GetVertex(vertex_t *v1, double height) const
|
||||
{
|
||||
|
|
|
@ -162,7 +162,7 @@ void RenderPolyPlayerSprites::RenderRemainingSprites()
|
|||
{
|
||||
for (const PolyHWAccelPlayerSprite &sprite : AcceleratedSprites)
|
||||
{
|
||||
screen->DrawTexture(sprite.pic,
|
||||
screen->DrawTexture(sprite.pic->GetTexture(),
|
||||
viewwindowx + sprite.x1,
|
||||
viewwindowy + viewheight / 2 - sprite.texturemid * sprite.yscale - 0.5,
|
||||
DTA_DestWidthF, FIXED2DBL(sprite.pic->GetWidth() * sprite.xscale),
|
||||
|
@ -198,7 +198,8 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
spriteframe_t* sprframe;
|
||||
FTextureID picnum;
|
||||
uint16_t flip;
|
||||
FTexture* tex;
|
||||
FTexture* ttex;
|
||||
FSoftwareTexture* tex;
|
||||
bool noaccel;
|
||||
double alpha = owner->Alpha;
|
||||
|
||||
|
@ -226,10 +227,12 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
|
||||
picnum = sprframe->Texture[0];
|
||||
flip = sprframe->Flip & 1;
|
||||
tex = TexMan(picnum);
|
||||
ttex = TexMan.GetTexture(picnum);
|
||||
|
||||
if (tex->UseType == ETextureType::Null)
|
||||
if (!ttex->isValid())
|
||||
return;
|
||||
|
||||
tex = ttex->GetSoftwareTexture();
|
||||
|
||||
if (pspr->firstTic)
|
||||
{ // Can't interpolate the first tic.
|
||||
|
@ -290,7 +293,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
|
||||
vis.renderflags = owner->renderflags;
|
||||
|
||||
vis.texturemid = (BASEYCENTER - sy) * tex->Scale.Y + tex->GetTopOffsetPo();
|
||||
vis.texturemid = (BASEYCENTER - sy) * tex->GetScale().Y + tex->GetTopOffsetPo();
|
||||
|
||||
if (viewpoint.camera->player && (renderToCanvas ||
|
||||
viewheight == renderTarget->GetHeight() ||
|
||||
|
@ -304,20 +307,20 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
}
|
||||
vis.x1 = x1 < 0 ? 0 : x1;
|
||||
vis.x2 = x2 >= viewwidth ? viewwidth : x2;
|
||||
vis.xscale = FLOAT2FIXED(pspritexscale / tex->Scale.X);
|
||||
vis.yscale = float(pspriteyscale / tex->Scale.Y);
|
||||
vis.xscale = FLOAT2FIXED(pspritexscale / tex->GetScale().X);
|
||||
vis.yscale = float(pspriteyscale / tex->GetScale().Y);
|
||||
vis.pic = tex;
|
||||
|
||||
// If flip is used, provided that it's not already flipped (that would just invert itself)
|
||||
// (It's an XOR...)
|
||||
if (!(flip) != !(pspr->Flags & PSPF_FLIP))
|
||||
{
|
||||
vis.xiscale = -FLOAT2FIXED(pspritexiscale * tex->Scale.X);
|
||||
vis.xiscale = -FLOAT2FIXED(pspritexiscale * tex->GetScale().X);
|
||||
vis.startfrac = (tex->GetWidth() << FRACBITS) - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
vis.xiscale = FLOAT2FIXED(pspritexiscale * tex->Scale.X);
|
||||
vis.xiscale = FLOAT2FIXED(pspritexiscale * tex->GetScale().X);
|
||||
vis.startfrac = 0;
|
||||
}
|
||||
|
||||
|
@ -383,6 +386,8 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
{
|
||||
noaccel = true;
|
||||
}
|
||||
#if 0
|
||||
// The HW 2D drawer should be able to handle this without problems
|
||||
// If the main colormap has fixed lights, and this sprite is being drawn with that
|
||||
// colormap, disable acceleration so that the lights can remain fixed.
|
||||
PolyCameraLight *cameraLight = PolyCameraLight::Instance();
|
||||
|
@ -392,6 +397,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
{
|
||||
noaccel = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ public:
|
|||
fixed_t xscale = 0;
|
||||
float yscale = 0.0f;
|
||||
|
||||
FTexture *pic = nullptr;
|
||||
FSoftwareTexture *pic = nullptr;
|
||||
|
||||
fixed_t xiscale = 0;
|
||||
fixed_t startfrac = 0;
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
class PolyHWAccelPlayerSprite
|
||||
{
|
||||
public:
|
||||
FTexture *pic = nullptr;
|
||||
FSoftwareTexture *pic = nullptr;
|
||||
double texturemid = 0.0;
|
||||
float yscale = 0.0f;
|
||||
fixed_t xscale = 0;
|
||||
|
|
|
@ -189,7 +189,7 @@ void RenderPolyScene::RenderSubsector(PolyRenderThread *thread, subsector_t *sub
|
|||
int subsectorIndex = sub->Index();
|
||||
for (int i = ParticlesInSubsec[subsectorIndex]; i != NO_PARTICLE; i = Particles[i].snext)
|
||||
{
|
||||
particle_t *particle = Particles + i;
|
||||
particle_t *particle = &Particles[i];
|
||||
thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentParticle>(particle, sub, subsectorDepth, CurrentViewpoint->StencilValue));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,11 @@
|
|||
|
||||
EXTERN_CVAR(Float, skyoffset)
|
||||
|
||||
extern double skytexturemid;
|
||||
extern float skyiscale;
|
||||
extern double skyscale;
|
||||
extern fixed_t sky1cyl, sky2cyl;
|
||||
|
||||
|
||||
PolySkyDome::PolySkyDome()
|
||||
{
|
||||
|
@ -63,7 +68,7 @@ void PolySkyDome::Render(PolyRenderThread *thread, const Mat4f &worldToView, con
|
|||
float offsetBaseV = 0.25f;
|
||||
|
||||
float scaleFrontU = frameSetup.frontcyl / (float)frameSetup.frontskytex->GetWidth();
|
||||
float scaleFrontV = (float)frameSetup.frontskytex->Scale.Y * scaleBaseV;
|
||||
float scaleFrontV = (float)frameSetup.frontskytex->GetScale().Y * scaleBaseV;
|
||||
float offsetFrontU = (float)((frameSetup.frontpos / 65536.0 + frameSetup.frontcyl / 2) / frameSetup.frontskytex->GetWidth());
|
||||
float offsetFrontV = (float)((frameSetup.skymid / frameSetup.frontskytex->GetHeight() + offsetBaseV) * scaleBaseV);
|
||||
|
||||
|
@ -115,7 +120,7 @@ void PolySkyDome::RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int ro
|
|||
PolyTriangleDrawer::DrawArray(thread->DrawQueue, args, &mVertices[mPrimStart[row]], mPrimStart[row + 1] - mPrimStart[row], PolyDrawMode::TriangleStrip);
|
||||
}
|
||||
|
||||
void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap)
|
||||
void PolySkyDome::RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FSoftwareTexture *skytex, int row, bool bottomCap)
|
||||
{
|
||||
uint32_t solid = skytex->GetSkyCapColor(bottomCap);
|
||||
uint8_t palsolid = RGB32k.RGB[(RPART(solid) >> 3)][(GPART(solid) >> 3)][(BPART(solid) >> 3)];
|
||||
|
@ -214,7 +219,7 @@ Mat4f PolySkyDome::GLSkyMath()
|
|||
float x_offset = 0.0f;
|
||||
float y_offset = 0.0f;
|
||||
bool mirror = false;
|
||||
FTexture *tex = mCurrentSetup.frontskytex;
|
||||
FSoftwareTexture *tex = mCurrentSetup.frontskytex;
|
||||
|
||||
int texh = 0;
|
||||
int texw = 0;
|
||||
|
@ -231,7 +236,7 @@ Mat4f PolySkyDome::GLSkyMath()
|
|||
float yscale = 1.f;
|
||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
||||
{
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
yscale = 240.f / texh;
|
||||
}
|
||||
|
@ -249,12 +254,12 @@ Mat4f PolySkyDome::GLSkyMath()
|
|||
}
|
||||
else if (texh <= 240)
|
||||
{
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (200 - texh + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (200 - texh + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.f + ((texh - 200.f) / 200.f) * 1.17f);
|
||||
}
|
||||
else
|
||||
{
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->SkyOffset + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
yscale = 240.f / texh;
|
||||
}
|
||||
|
@ -277,6 +282,14 @@ Mat4f PolySkyDome::GLSkyMath()
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static FSoftwareTexture *GetSWTex(FTextureID texid, bool allownull = true)
|
||||
{
|
||||
auto tex = TexMan.GetPalettedTexture(texid, true);
|
||||
if (tex == nullptr) return nullptr;
|
||||
if (!allownull && !tex->isValid()) return nullptr;
|
||||
return tex->GetSoftwareTexture();
|
||||
}
|
||||
|
||||
void PolySkySetup::Update()
|
||||
{
|
||||
FTextureID sky1tex, sky2tex;
|
||||
|
@ -299,9 +312,9 @@ void PolySkySetup::Update()
|
|||
if (!(sectorSky & PL_SKYFLAT))
|
||||
{ // use sky1
|
||||
sky1:
|
||||
frontskytex = TexMan(sky1tex, true);
|
||||
frontskytex = GetSWTex(sky1tex);
|
||||
if (level.flags & LEVEL_DOUBLESKY)
|
||||
backskytex = TexMan(sky2tex, true);
|
||||
backskytex = GetSWTex(sky2tex);
|
||||
else
|
||||
backskytex = nullptr;
|
||||
skyflip = false;
|
||||
|
@ -312,7 +325,7 @@ void PolySkySetup::Update()
|
|||
}
|
||||
else if (sectorSky == PL_SKYFLAT)
|
||||
{ // use sky2
|
||||
frontskytex = TexMan(sky2tex, true);
|
||||
frontskytex = GetSWTex(sky2tex);
|
||||
backskytex = nullptr;
|
||||
frontcyl = sky2cyl;
|
||||
skyflip = false;
|
||||
|
@ -338,8 +351,8 @@ void PolySkySetup::Update()
|
|||
pos = side_t::top;
|
||||
}
|
||||
|
||||
frontskytex = TexMan(s->GetTexture(pos), true);
|
||||
if (frontskytex == nullptr || frontskytex->UseType == ETextureType::Null)
|
||||
frontskytex = GetSWTex(s->GetTexture(pos), false);
|
||||
if (frontskytex == nullptr)
|
||||
{ // [RH] The blank texture: Use normal sky instead.
|
||||
goto sky1;
|
||||
}
|
||||
|
@ -361,7 +374,7 @@ void PolySkySetup::Update()
|
|||
// allow old sky textures to be used.
|
||||
skyflip = l->args[2] ? false : true;
|
||||
|
||||
int frontxscale = int(frontskytex->Scale.X * 1024);
|
||||
int frontxscale = int(frontskytex->GetScale().X * 1024);
|
||||
frontcyl = MAX(frontskytex->GetWidth(), frontxscale);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,8 @@ public:
|
|||
bool operator==(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) == 0; }
|
||||
bool operator!=(const PolySkySetup &that) const { return memcmp(this, &that, sizeof(PolySkySetup)) != 0; }
|
||||
|
||||
FTexture *frontskytex = nullptr;
|
||||
FTexture *backskytex = nullptr;
|
||||
FSoftwareTexture *frontskytex = nullptr;
|
||||
FSoftwareTexture *backskytex = nullptr;
|
||||
bool skyflip = 0;
|
||||
int frontpos = 0;
|
||||
int backpos = 0;
|
||||
|
@ -58,7 +58,7 @@ private:
|
|||
void CreateSkyHemisphere(bool zflip);
|
||||
void CreateDome();
|
||||
void RenderRow(PolyRenderThread *thread, PolyDrawArgs &args, int row, uint32_t capcolor, uint8_t capcolorindex);
|
||||
void RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FTexture *skytex, int row, bool bottomCap);
|
||||
void RenderCapColorRow(PolyRenderThread *thread, PolyDrawArgs &args, FSoftwareTexture *skytex, int row, bool bottomCap);
|
||||
|
||||
TriVertex SetVertexXYZ(float xx, float yy, float zz, float uu = 0, float vv = 0);
|
||||
|
||||
|
|
|
@ -49,13 +49,13 @@ bool RenderPolySprite::GetLine(AActor *thing, DVector2 &left, DVector2 &right)
|
|||
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
||||
|
||||
bool flipTextureX = false;
|
||||
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||
FSoftwareTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||
if (tex == nullptr)
|
||||
return false;
|
||||
|
||||
DVector2 spriteScale = thing->Scale;
|
||||
double thingxscalemul = spriteScale.X / tex->Scale.X;
|
||||
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
|
||||
double thingxscalemul = spriteScale.X / tex->GetScale().X;
|
||||
double thingyscalemul = spriteScale.Y / tex->GetScale().Y;
|
||||
|
||||
double spriteWidth = thingxscalemul * tex->GetWidth();
|
||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||
|
@ -105,11 +105,11 @@ void RenderPolySprite::Render(PolyRenderThread *thread, AActor *thing, subsector
|
|||
posZ += thing->GetBobOffset(viewpoint.TicFrac);
|
||||
|
||||
bool flipTextureX = false;
|
||||
FTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
||||
FSoftwareTexture *tex = GetSpriteTexture(thing, flipTextureX);
|
||||
if (tex == nullptr)
|
||||
return;
|
||||
|
||||
double thingyscalemul = thing->Scale.Y / tex->Scale.Y;
|
||||
double thingyscalemul = thing->Scale.Y / tex->GetScale().Y;
|
||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||
|
||||
posZ -= (tex->GetHeight() - tex->GetTopOffsetPo()) * thingyscalemul;
|
||||
|
@ -302,7 +302,7 @@ bool RenderPolySprite::IsThingCulled(AActor *thing)
|
|||
return false;
|
||||
}
|
||||
|
||||
FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
||||
FSoftwareTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
||||
{
|
||||
const auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
flipX = false;
|
||||
|
@ -312,16 +312,17 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
|||
|
||||
if (thing->picnum.isValid())
|
||||
{
|
||||
FTexture *tex = TexMan(thing->picnum);
|
||||
if (tex->UseType == ETextureType::Null)
|
||||
FTexture *ttex = TexMan.GetPalettedTexture(thing->picnum, true);
|
||||
if (!ttex || !ttex->isValid())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||
|
||||
if (tex->Rotations != 0xFFFF)
|
||||
if (ttex->GetRotations() != 0xFFFF)
|
||||
{
|
||||
// choose a different rotation based on player view
|
||||
spriteframe_t *sprframe = &SpriteFrames[tex->Rotations];
|
||||
spriteframe_t *sprframe = &SpriteFrames[ttex->GetRotations()];
|
||||
DVector3 pos = thing->InterpolatedPosition(viewpoint.TicFrac);
|
||||
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
||||
DAngle ang = (pos - viewpoint.Pos).Angle();
|
||||
|
@ -335,7 +336,13 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
|||
rot = (ang - thing->Angles.Yaw + (45.0 / 2 * 9 - 180.0 / 16)).BAMs() >> 28;
|
||||
}
|
||||
flipX = (sprframe->Flip & (1 << rot)) != 0;
|
||||
tex = TexMan[sprframe->Texture[rot]]; // Do not animate the rotation
|
||||
ttex = TexMan.GetPalettedTexture(sprframe->Texture[rot], false); // Do not animate the rotation
|
||||
tex = ttex->GetSoftwareTexture();
|
||||
if (!ttex || !ttex->isValid())
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
FSoftwareTexture *tex = ttex->GetSoftwareTexture();
|
||||
}
|
||||
return tex;
|
||||
}
|
||||
|
@ -364,7 +371,7 @@ FTexture *RenderPolySprite::GetSpriteTexture(AActor *thing, /*out*/ bool &flipX)
|
|||
DAngle sprangle = thing->GetSpriteAngle((pos - viewpoint.Pos).Angle(), viewpoint.TicFrac);
|
||||
FTextureID tex = sprdef->GetSpriteFrame(thing->frame, -1, sprangle, &flipX);
|
||||
if (!tex.isValid()) return nullptr;
|
||||
return TexMan[tex];
|
||||
return TexMan.GetPalettedTexture(tex, false)->GetSoftwareTexture();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
static bool GetLine(AActor *thing, DVector2 &left, DVector2 &right);
|
||||
static bool IsThingCulled(AActor *thing);
|
||||
static FTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX);
|
||||
static FSoftwareTexture *GetSpriteTexture(AActor *thing, /*out*/ bool &flipX);
|
||||
|
||||
private:
|
||||
static double PerformSpriteClipAdjustment(AActor *thing, const DVector2 &thingpos, double spriteheight, double z);
|
||||
|
|
|
@ -171,8 +171,8 @@ bool RenderPolyWall::RenderLine(PolyRenderThread *thread, seg_t *line, sector_t
|
|||
wall.Alpha = wall.Line->alpha;
|
||||
wall.FogBoundary = IsFogBoundary(frontsector, backsector);
|
||||
|
||||
FTexture *midtex = TexMan(line->sidedef->GetTexture(side_t::mid), true);
|
||||
if ((midtex && midtex->UseType != ETextureType::Null) || wall.FogBoundary)
|
||||
FTexture *midtex = TexMan.GetPalettedTexture(line->sidedef->GetTexture(side_t::mid), true);
|
||||
if ((midtex && midtex->isValid()) || wall.FogBoundary)
|
||||
translucentWallsOutput.push_back(thread->FrameMemory->NewObject<PolyTranslucentWall>(wall));
|
||||
|
||||
if (polyportal)
|
||||
|
@ -526,10 +526,10 @@ void RenderPolyWall::ClampHeight(TriVertex &v1, TriVertex &v2)
|
|||
v2.v = texv1 * inv_t2 + texv2 * t2;
|
||||
}
|
||||
|
||||
FTexture *RenderPolyWall::GetTexture(const line_t *line, const side_t *side, side_t::ETexpart texpart)
|
||||
FSoftwareTexture *RenderPolyWall::GetTexture(const line_t *line, const side_t *side, side_t::ETexpart texpart)
|
||||
{
|
||||
FTexture *tex = TexMan(side->GetTexture(texpart), true);
|
||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
||||
FTexture *tex = TexMan.GetPalettedTexture(side->GetTexture(texpart), true);
|
||||
if (tex == nullptr || !tex->isValid())
|
||||
{
|
||||
// Mapping error. Doom floodfills this with a plane.
|
||||
// This code doesn't do that, but at least it uses the "right" texture..
|
||||
|
@ -537,22 +537,22 @@ FTexture *RenderPolyWall::GetTexture(const line_t *line, const side_t *side, sid
|
|||
if (line && line->backsector && line->sidedef[0] == side)
|
||||
{
|
||||
if (texpart == side_t::top)
|
||||
tex = TexMan(line->backsector->GetTexture(sector_t::ceiling), true);
|
||||
tex = TexMan.GetPalettedTexture(line->backsector->GetTexture(sector_t::ceiling), true);
|
||||
else if (texpart == side_t::bottom)
|
||||
tex = TexMan(line->backsector->GetTexture(sector_t::floor), true);
|
||||
tex = TexMan.GetPalettedTexture(line->backsector->GetTexture(sector_t::floor), true);
|
||||
}
|
||||
if (line && line->backsector && line->sidedef[1] == side)
|
||||
{
|
||||
if (texpart == side_t::top)
|
||||
tex = TexMan(line->frontsector->GetTexture(sector_t::ceiling), true);
|
||||
tex = TexMan.GetPalettedTexture(line->frontsector->GetTexture(sector_t::ceiling), true);
|
||||
else if (texpart == side_t::bottom)
|
||||
tex = TexMan(line->frontsector->GetTexture(sector_t::floor), true);
|
||||
tex = TexMan.GetPalettedTexture(line->frontsector->GetTexture(sector_t::floor), true);
|
||||
}
|
||||
|
||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
||||
if (tex == nullptr || !tex->isValid())
|
||||
return nullptr;
|
||||
}
|
||||
return tex;
|
||||
return tex? tex->GetSoftwareTexture() : nullptr;
|
||||
}
|
||||
|
||||
int RenderPolyWall::GetLightLevel()
|
||||
|
@ -572,13 +572,13 @@ int RenderPolyWall::GetLightLevel()
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart wallpart)
|
||||
PolyWallTextureCoordsU::PolyWallTextureCoordsU(FSoftwareTexture *tex, const seg_t *lineseg, const line_t *line, const side_t *side, side_t::ETexpart wallpart)
|
||||
{
|
||||
// Calculate the U texture coordinate for the line
|
||||
double lineu1 = side->GetTextureXOffset(wallpart);
|
||||
double lineu2 = side->GetTextureXOffset(wallpart) + line->sidedef[0]->TexelLength * side->GetTextureXScale(wallpart);
|
||||
lineu1 *= tex->Scale.X / tex->GetWidth();
|
||||
lineu2 *= tex->Scale.X / tex->GetWidth();
|
||||
lineu1 *= tex->GetScale().X / tex->GetWidth();
|
||||
lineu2 *= tex->GetScale().X / tex->GetWidth();
|
||||
|
||||
// Calculate where we are on the lineseg
|
||||
double t1, t2;
|
||||
|
@ -606,11 +606,11 @@ PolyWallTextureCoordsU::PolyWallTextureCoordsU(FTexture *tex, const seg_t *lines
|
|||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
PolyWallTextureCoordsV::PolyWallTextureCoordsV(FTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ)
|
||||
PolyWallTextureCoordsV::PolyWallTextureCoordsV(FSoftwareTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ)
|
||||
{
|
||||
double yoffset = side->GetTextureYOffset(wallpart);
|
||||
if (tex->bWorldPanning)
|
||||
yoffset *= side->GetTextureYScale(wallpart) * tex->Scale.Y;
|
||||
if (tex->useWorldPanning())
|
||||
yoffset *= side->GetTextureYScale(wallpart) * tex->GetScale().Y;
|
||||
|
||||
switch (wallpart)
|
||||
{
|
||||
|
@ -626,8 +626,8 @@ PolyWallTextureCoordsV::PolyWallTextureCoordsV(FTexture *tex, const line_t *line
|
|||
break;
|
||||
}
|
||||
|
||||
v1 *= tex->Scale.Y / tex->GetHeight();
|
||||
v2 *= tex->Scale.Y / tex->GetHeight();
|
||||
v1 *= tex->GetScale().Y / tex->GetHeight();
|
||||
v2 *= tex->GetScale().Y / tex->GetHeight();
|
||||
|
||||
double texZHeight = (bottomTexZ - topTexZ);
|
||||
if (texZHeight > 0.0f || texZHeight < -0.0f)
|
||||
|
@ -641,12 +641,12 @@ PolyWallTextureCoordsV::PolyWallTextureCoordsV(FTexture *tex, const line_t *line
|
|||
}
|
||||
}
|
||||
|
||||
void PolyWallTextureCoordsV::CalcVTopPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
||||
void PolyWallTextureCoordsV::CalcVTopPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
||||
{
|
||||
bool pegged = (line->flags & ML_DONTPEGTOP) == 0;
|
||||
if (pegged) // bottom to top
|
||||
{
|
||||
double texHeight = tex->GetHeight() / tex->Scale.Y;
|
||||
double texHeight = tex->GetHeight() / tex->GetScale().Y;
|
||||
v1 = (topz - bottomz) * side->GetTextureYScale(side_t::top) - yoffset;
|
||||
v2 = -yoffset;
|
||||
v1 = texHeight - v1;
|
||||
|
@ -659,7 +659,7 @@ void PolyWallTextureCoordsV::CalcVTopPart(FTexture *tex, const line_t *line, con
|
|||
}
|
||||
}
|
||||
|
||||
void PolyWallTextureCoordsV::CalcVMidPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
||||
void PolyWallTextureCoordsV::CalcVMidPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset)
|
||||
{
|
||||
bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0;
|
||||
if (pegged) // top to bottom
|
||||
|
@ -669,7 +669,7 @@ void PolyWallTextureCoordsV::CalcVMidPart(FTexture *tex, const line_t *line, con
|
|||
}
|
||||
else // bottom to top
|
||||
{
|
||||
double texHeight = tex->GetHeight() / tex->Scale.Y;
|
||||
double texHeight = tex->GetHeight() / tex->GetScale().Y;
|
||||
v1 = yoffset - (topz - bottomz) * side->GetTextureYScale(side_t::mid);
|
||||
v2 = yoffset;
|
||||
v1 = texHeight + v1;
|
||||
|
@ -677,7 +677,7 @@ void PolyWallTextureCoordsV::CalcVMidPart(FTexture *tex, const line_t *line, con
|
|||
}
|
||||
}
|
||||
|
||||
void PolyWallTextureCoordsV::CalcVBottomPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset)
|
||||
void PolyWallTextureCoordsV::CalcVBottomPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset)
|
||||
{
|
||||
bool pegged = (line->flags & ML_DONTPEGBOTTOM) == 0;
|
||||
if (pegged) // top to bottom
|
||||
|
|
|
@ -48,7 +48,7 @@ public:
|
|||
const line_t *LineSegLine = nullptr;
|
||||
const line_t *Line = nullptr;
|
||||
const side_t *Side = nullptr;
|
||||
FTexture *Texture = nullptr;
|
||||
FSoftwareTexture *Texture = nullptr;
|
||||
side_t::ETexpart Wallpart = side_t::mid;
|
||||
double TopTexZ = 0.0;
|
||||
double BottomTexZ = 0.0;
|
||||
|
@ -72,13 +72,13 @@ private:
|
|||
void SetDynLights(PolyRenderThread *thread, PolyDrawArgs &args);
|
||||
|
||||
static bool IsFogBoundary(sector_t *front, sector_t *back);
|
||||
static FTexture *GetTexture(const line_t *Line, const side_t *Side, side_t::ETexpart texpart);
|
||||
static FSoftwareTexture *GetTexture(const line_t *Line, const side_t *Side, side_t::ETexpart texpart);
|
||||
};
|
||||
|
||||
class PolyWallTextureCoordsU
|
||||
{
|
||||
public:
|
||||
PolyWallTextureCoordsU(FTexture *tex, const seg_t *lineseg, const line_t *linesegline, const side_t *side, side_t::ETexpart wallpart);
|
||||
PolyWallTextureCoordsU(FSoftwareTexture *tex, const seg_t *lineseg, const line_t *linesegline, const side_t *side, side_t::ETexpart wallpart);
|
||||
|
||||
double u1, u2;
|
||||
};
|
||||
|
@ -86,14 +86,14 @@ public:
|
|||
class PolyWallTextureCoordsV
|
||||
{
|
||||
public:
|
||||
PolyWallTextureCoordsV(FTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ);
|
||||
PolyWallTextureCoordsV(FSoftwareTexture *tex, const line_t *line, const side_t *side, side_t::ETexpart wallpart, double topz, double bottomz, double unpeggedceil, double topTexZ, double bottomTexZ);
|
||||
|
||||
double v1, v2;
|
||||
|
||||
private:
|
||||
void CalcVTopPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
||||
void CalcVMidPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
||||
void CalcVBottomPart(FTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset);
|
||||
void CalcVTopPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
||||
void CalcVMidPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double yoffset);
|
||||
void CalcVBottomPart(FSoftwareTexture *tex, const line_t *line, const side_t *side, double topz, double bottomz, double unpeggedceil, double yoffset);
|
||||
};
|
||||
|
||||
class PolyTranslucentWall : public PolyTranslucentObject
|
||||
|
|
|
@ -40,13 +40,13 @@ void RenderPolyWallSprite::Render(PolyRenderThread *thread, AActor *thing, subse
|
|||
pos.Z += thing->GetBobOffset(viewpoint.TicFrac);
|
||||
|
||||
bool flipTextureX = false;
|
||||
FTexture *tex = RenderPolySprite::GetSpriteTexture(thing, flipTextureX);
|
||||
if (tex == nullptr || tex->UseType == ETextureType::Null)
|
||||
FSoftwareTexture *tex = RenderPolySprite::GetSpriteTexture(thing, flipTextureX);
|
||||
if (tex == nullptr)
|
||||
return;
|
||||
|
||||
DVector2 spriteScale = thing->Scale;
|
||||
double thingxscalemul = spriteScale.X / tex->Scale.X;
|
||||
double thingyscalemul = spriteScale.Y / tex->Scale.Y;
|
||||
double thingxscalemul = spriteScale.X / tex->GetScale().X;
|
||||
double thingyscalemul = spriteScale.Y / tex->GetScale().Y;
|
||||
double spriteHeight = thingyscalemul * tex->GetHeight();
|
||||
|
||||
DAngle ang = thing->Angles.Yaw + 90;
|
||||
|
@ -91,8 +91,8 @@ void RenderPolyWallSprite::Render(PolyRenderThread *thread, AActor *thing, subse
|
|||
vertices[i].y = (float)p.Y;
|
||||
vertices[i].z = (float)(pos.Z + spriteHeight * offsets[i].second);
|
||||
vertices[i].w = 1.0f;
|
||||
vertices[i].u = (float)(offsets[i].first * tex->Scale.X);
|
||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->Scale.Y);
|
||||
vertices[i].u = (float)(offsets[i].first * tex->GetScale().X);
|
||||
vertices[i].v = (float)((1.0f - offsets[i].second) * tex->GetScale().Y);
|
||||
if (flipTextureX)
|
||||
vertices[i].u = 1.0f - vertices[i].u;
|
||||
}
|
||||
|
|
|
@ -647,18 +647,20 @@ CUSTOM_CVAR(Bool, vid_hidpi, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG | CVAR_NOINI
|
|||
// ---------------------------------------------------------------------------
|
||||
|
||||
|
||||
bool I_SetCursor(FTexture* cursorpic)
|
||||
bool I_SetCursor(FTexture *cursorpic)
|
||||
{
|
||||
NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
|
||||
NSCursor* cursor = nil;
|
||||
|
||||
if (NULL != cursorpic && ETextureType::Null != cursorpic->UseType)
|
||||
if (NULL != cursorpic && cursorpic->isValid())
|
||||
{
|
||||
// Create bitmap image representation
|
||||
|
||||
auto sbuffer = cursorpic->CreateTexBuffer(0);
|
||||
|
||||
const NSInteger imageWidth = cursorpic->GetWidth();
|
||||
const NSInteger imageHeight = cursorpic->GetHeight();
|
||||
const NSInteger imagePitch = imageWidth * 4;
|
||||
const NSInteger imageWidth = sbuffer.mWidth;
|
||||
const NSInteger imageHeight = sbuffer.mHeight;
|
||||
const NSInteger imagePitch = sbuffer.mWidth * 4;
|
||||
|
||||
NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep alloc];
|
||||
[bitmapImageRep initWithBitmapDataPlanes:NULL
|
||||
|
@ -675,20 +677,14 @@ bool I_SetCursor(FTexture* cursorpic)
|
|||
// Load bitmap data to representation
|
||||
|
||||
uint8_t* buffer = [bitmapImageRep bitmapData];
|
||||
memset(buffer, 0, imagePitch * imageHeight);
|
||||
|
||||
FBitmap bitmap(buffer, imagePitch, imageWidth, imageHeight);
|
||||
cursorpic->CopyTrueColorPixels(&bitmap, 0, 0);
|
||||
memcpy(buffer, sbuffer.mBuffer, imagePitch * imageHeight);
|
||||
|
||||
// Swap red and blue components in each pixel
|
||||
|
||||
for (size_t i = 0; i < size_t(imageWidth * imageHeight); ++i)
|
||||
{
|
||||
const size_t offset = i * 4;
|
||||
|
||||
const uint8_t temp = buffer[offset ];
|
||||
buffer[offset ] = buffer[offset + 2];
|
||||
buffer[offset + 2] = temp;
|
||||
std::swap(buffer[offset ], buffer[offset + 2]);
|
||||
}
|
||||
|
||||
// Create image from representation and set it as cursor
|
||||
|
|
|
@ -44,10 +44,11 @@ bool I_SetCursor(FTexture *cursorpic)
|
|||
static SDL_Cursor *cursor;
|
||||
static SDL_Surface *cursorSurface;
|
||||
|
||||
if (cursorpic != NULL && cursorpic->UseType != ETextureType::Null)
|
||||
if (cursorpic != NULL && cursorpic->isValid())
|
||||
{
|
||||
auto src = cursorpic->GetBgraBitmap(nullptr);
|
||||
// Must be no larger than 32x32.
|
||||
if (cursorpic->GetWidth() > 32 || cursorpic->GetHeight() > 32)
|
||||
if (src.GetWidth() > 32 || src.GetHeight() > 32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -59,7 +60,7 @@ bool I_SetCursor(FTexture *cursorpic)
|
|||
uint8_t buffer[32*32*4];
|
||||
memset(buffer, 0, 32*32*4);
|
||||
FBitmap bmp(buffer, 32*4, 32, 32);
|
||||
cursorpic->CopyTrueColorPixels(&bmp, 0, 0);
|
||||
bmp.Blit(0, 0, src); // expand to 32*32
|
||||
memcpy(cursorSurface->pixels, bmp.GetPixels(), 32*32*4);
|
||||
SDL_UnlockSurface(cursorSurface);
|
||||
|
||||
|
|
|
@ -73,9 +73,7 @@ static void ParseVavoomSkybox()
|
|||
int facecount=0;
|
||||
int maplump = -1;
|
||||
bool error = false;
|
||||
FSkyBox * sb = new FSkyBox;
|
||||
sb->Name = sc.String;
|
||||
sb->Name.ToUpper();
|
||||
FSkyBox * sb = new FSkyBox(sc.String);
|
||||
sb->fliptop = true;
|
||||
sc.MustGetStringName("{");
|
||||
while (!sc.CheckString("}"))
|
||||
|
@ -91,7 +89,7 @@ static void ParseVavoomSkybox()
|
|||
FTexture *tex = TexMan.FindTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny);
|
||||
if (tex == NULL)
|
||||
{
|
||||
sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->Name.GetChars());
|
||||
sc.ScriptMessage("Texture '%s' not found in Vavoom skybox '%s'\n", sc.String, sb->GetName().GetChars());
|
||||
error = true;
|
||||
}
|
||||
sb->faces[facecount] = tex;
|
||||
|
@ -101,10 +99,13 @@ static void ParseVavoomSkybox()
|
|||
}
|
||||
if (facecount != 6)
|
||||
{
|
||||
sc.ScriptError("%s: Skybox definition requires 6 faces", sb->Name.GetChars());
|
||||
sc.ScriptError("%s: Skybox definition requires 6 faces", sb->GetName().GetChars());
|
||||
}
|
||||
sb->SetSize();
|
||||
if (!error) TexMan.AddTexture(sb);
|
||||
if (!error)
|
||||
{
|
||||
TexMan.AddTexture(sb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -966,8 +967,7 @@ class GLDefsParser
|
|||
|
||||
sc.MustGetString();
|
||||
|
||||
FSkyBox * sb = new FSkyBox;
|
||||
sb->Name = sc.String;
|
||||
FSkyBox * sb = new FSkyBox(sc.String);
|
||||
sb->Name.ToUpper();
|
||||
if (sc.CheckString("fliptop"))
|
||||
{
|
||||
|
@ -979,7 +979,7 @@ class GLDefsParser
|
|||
sc.MustGetString();
|
||||
if (facecount<6)
|
||||
{
|
||||
sb->faces[facecount] = TexMan[TexMan.GetTexture(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable)];
|
||||
sb->faces[facecount] = TexMan.GetTexture(TexMan.GetTextureID(sc.String, ETextureType::Wall, FTextureManager::TEXMAN_TryAny|FTextureManager::TEXMAN_Overridable));
|
||||
}
|
||||
facecount++;
|
||||
}
|
||||
|
@ -1010,7 +1010,7 @@ class GLDefsParser
|
|||
{
|
||||
sc.MustGetString();
|
||||
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny);
|
||||
FTexture *tex = TexMan[flump];
|
||||
FTexture *tex = TexMan.GetTexture(flump);
|
||||
if (tex) tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true;
|
||||
}
|
||||
}
|
||||
|
@ -1021,7 +1021,7 @@ class GLDefsParser
|
|||
{
|
||||
sc.MustGetString();
|
||||
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Wall,FTextureManager::TEXMAN_TryAny);
|
||||
FTexture *tex = TexMan[flump];
|
||||
FTexture *tex = TexMan.GetTexture(flump);
|
||||
if (tex) tex->bAutoGlowing = tex->bGlowing = tex->bFullbright = true;
|
||||
}
|
||||
}
|
||||
|
@ -1030,7 +1030,7 @@ class GLDefsParser
|
|||
sc.SetCMode(true);
|
||||
sc.MustGetString();
|
||||
FTextureID flump=TexMan.CheckForTexture(sc.String, ETextureType::Flat,FTextureManager::TEXMAN_TryAny);
|
||||
FTexture *tex = TexMan[flump];
|
||||
FTexture *tex = TexMan.GetTexture(flump);
|
||||
sc.MustGetStringName(",");
|
||||
sc.MustGetString();
|
||||
PalEntry color = V_GetColor(NULL, sc.String);
|
||||
|
@ -1083,7 +1083,7 @@ class GLDefsParser
|
|||
|
||||
sc.MustGetString();
|
||||
FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable);
|
||||
FTexture *tex = TexMan[no];
|
||||
FTexture *tex = TexMan.GetTexture(no);
|
||||
|
||||
sc.MustGetToken('{');
|
||||
while (!sc.CheckToken('}'))
|
||||
|
@ -1140,14 +1140,6 @@ class GLDefsParser
|
|||
|
||||
if (bmtex != NULL)
|
||||
{
|
||||
/* I do not think this is needed any longer
|
||||
if (tex->bWarped != 0)
|
||||
{
|
||||
Printf("Cannot combine warping with brightmap on texture '%s'\n", tex->Name.GetChars());
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
bmtex->bMasked = false;
|
||||
tex->Brightmap = bmtex;
|
||||
}
|
||||
|
@ -1196,7 +1188,7 @@ class GLDefsParser
|
|||
|
||||
sc.MustGetString();
|
||||
FTextureID no = TexMan.CheckForTexture(sc.String, type, FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_Overridable);
|
||||
FTexture *tex = TexMan[no];
|
||||
FTexture *tex = TexMan.GetTexture(no);
|
||||
|
||||
sc.MustGetToken('{');
|
||||
while (!sc.CheckToken('}'))
|
||||
|
@ -1367,7 +1359,7 @@ class GLDefsParser
|
|||
usershader.defines.AppendFormat("#define %s texture%d\n", texNameList[i].GetChars(), texNameIndex[i] + firstUserTexture);
|
||||
}
|
||||
|
||||
if (tex->bWarped != 0)
|
||||
if (tex->isWarped() != 0)
|
||||
{
|
||||
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
|
||||
return;
|
||||
|
@ -1499,7 +1491,7 @@ class GLDefsParser
|
|||
|
||||
sc.MustGetString();
|
||||
FTextureID no = TexMan.CheckForTexture(sc.String, type);
|
||||
FTexture *tex = TexMan[no];
|
||||
FTexture *tex = TexMan.GetTexture(no);
|
||||
|
||||
sc.MustGetToken('{');
|
||||
while (!sc.CheckToken('}'))
|
||||
|
@ -1608,7 +1600,7 @@ class GLDefsParser
|
|||
|
||||
if (desc.shader.IsNotEmpty())
|
||||
{
|
||||
if (tex->bWarped != 0)
|
||||
if (tex->isWarped() != 0)
|
||||
{
|
||||
Printf("Cannot combine warping with hardware shader on texture '%s'\n", tex->Name.GetChars());
|
||||
return;
|
||||
|
@ -1766,7 +1758,7 @@ void ParseGLDefs()
|
|||
{
|
||||
const char *defsLump = NULL;
|
||||
|
||||
LightDefaults.Clear();
|
||||
LightDefaults.DeleteAndClear();
|
||||
//gl_DestroyUserShaders(); function says 'todo'
|
||||
switch (gameinfo.gametype)
|
||||
{
|
||||
|
|
|
@ -268,7 +268,7 @@ void FModelRenderer::RenderFrameModels(const FSpriteModelFrame *smf, const FStat
|
|||
if (smf->modelIDs[i] != -1)
|
||||
{
|
||||
FModel * mdl = Models[smf->modelIDs[i]];
|
||||
FTexture *tex = smf->skinIDs[i].isValid() ? TexMan(smf->skinIDs[i]) : nullptr;
|
||||
FTexture *tex = smf->skinIDs[i].isValid() ? TexMan.GetTexture(smf->skinIDs[i], true) : nullptr;
|
||||
mdl->BuildVertexBuffer(this);
|
||||
|
||||
mdl->PushSpriteMDLFrame(smf, i);
|
||||
|
|
|
@ -364,7 +364,7 @@ void FDMDModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
|||
if (!skin)
|
||||
{
|
||||
if (info.numSkins == 0 || !skins[0].isValid()) return;
|
||||
skin = TexMan(skins[0]);
|
||||
skin = TexMan.GetTexture(skins[0], true);
|
||||
if (!skin) return;
|
||||
}
|
||||
|
||||
|
|
|
@ -356,11 +356,11 @@ void FMD3Model::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
|||
{
|
||||
if (curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
|
||||
{
|
||||
surfaceSkin = TexMan(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i]);
|
||||
surfaceSkin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
|
||||
}
|
||||
else if(surf->numSkins > 0 && surf->skins[0].isValid())
|
||||
{
|
||||
surfaceSkin = TexMan(surf->skins[0]);
|
||||
surfaceSkin = TexMan.GetTexture(surf->skins[0], true);
|
||||
}
|
||||
|
||||
if (!surfaceSkin)
|
||||
|
|
|
@ -636,11 +636,11 @@ void FOBJModel::RenderFrame(FModelRenderer *renderer, FTexture * skin, int frame
|
|||
{
|
||||
if (i < MD3_MAX_SURFACES && curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i].isValid())
|
||||
{
|
||||
userSkin = TexMan(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i]);
|
||||
userSkin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][i], true);
|
||||
}
|
||||
else if (surf->skin.isValid())
|
||||
{
|
||||
userSkin = TexMan(surf->skin);
|
||||
userSkin = TexMan.GetTexture(surf->skin, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ void FUE1Model::RenderFrame( FModelRenderer *renderer, FTexture *skin, int frame
|
|||
if ( !sskin )
|
||||
{
|
||||
if ( curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum].isValid() )
|
||||
sskin = TexMan(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum]);
|
||||
sskin = TexMan.GetTexture(curSpriteMDLFrame->surfaceskinIDs[curMDLIndex][groups[i].texNum], true);
|
||||
if ( !sskin )
|
||||
{
|
||||
vofs += vsize;
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "textures/bitmap.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "models.h"
|
||||
#include "image.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4244) // warning C4244: conversion from 'double' to 'float', possible loss of data
|
||||
|
@ -46,14 +47,13 @@
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
class FVoxelTexture : public FWorldTexture
|
||||
class FVoxelTexture : public FImageSource
|
||||
{
|
||||
public:
|
||||
FVoxelTexture(FVoxel *voxel);
|
||||
|
||||
int CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf) override;
|
||||
bool UseBasePalette() override { return false; }
|
||||
uint8_t *MakeTexture(FRenderStyle style) override;
|
||||
int CopyPixels(FBitmap *bmp, int conversion) override;
|
||||
TArray<uint8_t> CreatePalettedPixels(int conversion) override;
|
||||
|
||||
protected:
|
||||
FVoxel *SourceVox;
|
||||
|
@ -70,10 +70,7 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox)
|
|||
SourceVox = vox;
|
||||
Width = 16;
|
||||
Height = 16;
|
||||
WidthBits = 4;
|
||||
HeightBits = 4;
|
||||
WidthMask = 15;
|
||||
bNoCompress = true;
|
||||
//bNoCompress = true;
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -82,10 +79,10 @@ FVoxelTexture::FVoxelTexture(FVoxel *vox)
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
uint8_t *FVoxelTexture::MakeTexture (FRenderStyle style)
|
||||
TArray<uint8_t> FVoxelTexture::CreatePalettedPixels(int conversion)
|
||||
{
|
||||
// GetPixels gets called when a translated palette is used so we still need to implement it here.
|
||||
auto Pixels = new uint8_t[256];
|
||||
TArray<uint8_t> Pixels(256, true);
|
||||
uint8_t *pp = SourceVox->Palette;
|
||||
|
||||
if(pp != NULL)
|
||||
|
@ -97,7 +94,7 @@ uint8_t *FVoxelTexture::MakeTexture (FRenderStyle style)
|
|||
pe.g = (pp[1] << 2) | (pp[1] >> 4);
|
||||
pe.b = (pp[2] << 2) | (pp[2] >> 4);
|
||||
// Alphatexture handling is just for completeness, but rather unlikely to be used ever.
|
||||
Pixels[i] = (style.Flags & STYLEF_RedIsAlpha)? pe.r : ColorMatcher.Pick(pe);
|
||||
Pixels[i] = conversion == luminance ? pe.r : ColorMatcher.Pick(pe);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -112,14 +109,14 @@ uint8_t *FVoxelTexture::MakeTexture (FRenderStyle style)
|
|||
|
||||
//===========================================================================
|
||||
//
|
||||
// FVoxelTexture::CopyTrueColorPixels
|
||||
// FVoxelTexture::CopyPixels
|
||||
//
|
||||
// This creates a dummy 16x16 paletted bitmap and converts that using the
|
||||
// voxel palette
|
||||
//
|
||||
//===========================================================================
|
||||
|
||||
int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, FCopyInfo *inf)
|
||||
int FVoxelTexture::CopyPixels(FBitmap *bmp, int conversion)
|
||||
{
|
||||
PalEntry pe[256];
|
||||
uint8_t bitmap[256];
|
||||
|
@ -145,7 +142,7 @@ int FVoxelTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rotate, F
|
|||
pe[i].a = 255;
|
||||
}
|
||||
}
|
||||
bmp->CopyPixelData(x, y, bitmap, Width, Height, 1, 16, rotate, pe, inf);
|
||||
bmp->CopyPixelData(0, 0, bitmap, Width, Height, 1, 16, 0, pe);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -159,7 +156,7 @@ FVoxelModel::FVoxelModel(FVoxel *voxel, bool owned)
|
|||
{
|
||||
mVoxel = voxel;
|
||||
mOwningVoxel = owned;
|
||||
mPalette = TexMan.AddTexture(new FVoxelTexture(voxel));
|
||||
mPalette = TexMan.AddTexture(new FImageTexture(new FVoxelTexture(voxel)));
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
210
src/r_data/r_canvastexture.cpp
Normal file
210
src/r_data/r_canvastexture.cpp
Normal file
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
** r_canvastexture.cpp
|
||||
** Maintenance data for camera textures
|
||||
**
|
||||
**---------------------------------------------------------------------------
|
||||
** Copyright 2004-2006 Randy Heit
|
||||
** Copyright 2006-2018 Christoph Oelckers
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions
|
||||
** are met:
|
||||
**
|
||||
** 1. Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** 2. Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in the
|
||||
** documentation and/or other materials provided with the distribution.
|
||||
** 3. The name of the author may not be used to endorse or promote products
|
||||
** derived from this software without specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
** (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 "actor.h"
|
||||
#include "r_canvastexture.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "serializer.h"
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: Add
|
||||
//
|
||||
// Assigns a camera to a canvas texture.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, double fov)
|
||||
{
|
||||
FCanvasTexture *texture;
|
||||
|
||||
if (!picnum.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
texture = static_cast<FCanvasTexture *>(TexMan.GetTexture(picnum));
|
||||
if (!texture->bHasCanvas)
|
||||
{
|
||||
Printf ("%s is not a valid target for a camera\n", texture->Name.GetChars());
|
||||
return;
|
||||
}
|
||||
|
||||
// Is this texture already assigned to a camera?
|
||||
unsigned index = List.FindEx([=](auto &entry) { return entry.Texture == texture; });
|
||||
if (index < List.Size())
|
||||
{
|
||||
auto probe = &List[index];
|
||||
// Yes, change its assignment to this new camera
|
||||
if (probe->Viewpoint != viewpoint || probe->FOV != fov)
|
||||
{
|
||||
texture->bFirstUpdate = true;
|
||||
}
|
||||
probe->Viewpoint = viewpoint;
|
||||
probe->FOV = fov;
|
||||
return;
|
||||
}
|
||||
// No, create a new assignment
|
||||
auto probe = &List[List.Reserve(1)];
|
||||
probe->Viewpoint = viewpoint;
|
||||
probe->Texture = texture;
|
||||
probe->PicNum = picnum;
|
||||
probe->FOV = fov;
|
||||
texture->bFirstUpdate = true;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// SetCameraToTexture
|
||||
//
|
||||
// [ZZ] expose this to ZScript
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov)
|
||||
{
|
||||
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
if (textureid.isValid())
|
||||
{
|
||||
// Only proceed if the texture actually has a canvas.
|
||||
FTexture *tex = TexMan.GetTexture(textureid);
|
||||
if (tex && tex->isCanvas())
|
||||
{
|
||||
level.canvasTextureInfo.Add(viewpoint, textureid, fov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: UpdateAll
|
||||
//
|
||||
// Updates all canvas textures that were visible in the last frame.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::UpdateAll(std::function<void(AActor *, FCanvasTexture *, double fov)> callback)
|
||||
{
|
||||
for (auto &probe : List)
|
||||
{
|
||||
if (probe.Viewpoint != nullptr && probe.Texture->bNeedsUpdate)
|
||||
{
|
||||
callback(probe.Viewpoint, probe.Texture, probe.FOV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: EmptyList
|
||||
//
|
||||
// Removes all camera->texture assignments.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::EmptyList ()
|
||||
{
|
||||
List.Clear();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: Serialize
|
||||
//
|
||||
// Reads or writes the current set of mappings in an archive.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::Serialize(FSerializer &arc)
|
||||
{
|
||||
if (arc.isWriting())
|
||||
{
|
||||
if (List.Size() > 0)
|
||||
{
|
||||
if (arc.BeginArray("canvastextures"))
|
||||
{
|
||||
for (auto &probe : List)
|
||||
{
|
||||
if (probe.Texture != nullptr && probe.Viewpoint != nullptr)
|
||||
{
|
||||
if (arc.BeginObject(nullptr))
|
||||
{
|
||||
arc("viewpoint", probe.Viewpoint)
|
||||
("fov", probe.FOV)
|
||||
("texture", probe.PicNum)
|
||||
.EndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
arc.EndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arc.BeginArray("canvastextures"))
|
||||
{
|
||||
AActor *viewpoint = nullptr;
|
||||
double fov;
|
||||
FTextureID picnum;
|
||||
while (arc.BeginObject(nullptr))
|
||||
{
|
||||
arc("viewpoint", viewpoint)
|
||||
("fov", fov)
|
||||
("texture", picnum)
|
||||
.EndObject();
|
||||
Add(viewpoint, picnum, fov);
|
||||
}
|
||||
arc.EndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: Mark
|
||||
//
|
||||
// Marks all viewpoints in the list for the collector.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::Mark()
|
||||
{
|
||||
for (auto & info : List)
|
||||
{
|
||||
GC::Mark(info.Viewpoint);
|
||||
}
|
||||
}
|
||||
|
24
src/r_data/r_canvastexture.h
Normal file
24
src/r_data/r_canvastexture.h
Normal file
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
|
||||
class FCanvasTexture;
|
||||
// This list keeps track of the cameras that draw into canvas textures.
|
||||
struct FCanvasTextureEntry
|
||||
{
|
||||
TObjPtr<AActor*> Viewpoint;
|
||||
FCanvasTexture *Texture;
|
||||
FTextureID PicNum;
|
||||
double FOV;
|
||||
};
|
||||
|
||||
|
||||
struct FCanvasTextureInfo
|
||||
{
|
||||
TArray<FCanvasTextureEntry> List;
|
||||
|
||||
void Add (AActor *viewpoint, FTextureID picnum, double fov);
|
||||
void UpdateAll (std::function<void(AActor *, FCanvasTexture *, double fov)> callback);
|
||||
void EmptyList ();
|
||||
void Serialize(FSerializer &arc);
|
||||
void Mark();
|
||||
|
||||
};
|
|
@ -122,7 +122,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool
|
|||
|
||||
if (frame >= MAX_SPRITE_FRAMES || rotation > 16)
|
||||
{
|
||||
Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan[lump]->Name.GetChars());
|
||||
Printf (TEXTCOLOR_RED "R_InstallSpriteLump: Bad frame characters in lump %s\n", TexMan.GetTexture(lump)->GetName().GetChars());
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ static bool R_InstallSpriteLump (FTextureID lump, unsigned frame, char rot, bool
|
|||
|
||||
|
||||
// [RH] Seperated out of R_InitSpriteDefs()
|
||||
static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
|
||||
void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxframe)
|
||||
{
|
||||
int frame;
|
||||
int framestart;
|
||||
|
@ -286,7 +286,7 @@ static void R_InstallSprite (int num, spriteframewithrotate *sprtemp, int &maxfr
|
|||
{
|
||||
for (int rot = 0; rot < 16; ++rot)
|
||||
{
|
||||
TexMan[sprtemp[frame].Texture[rot]]->Rotations = framestart + frame;
|
||||
TexMan.GetTexture(sprtemp[frame].Texture[rot])->Rotations = framestart + frame;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -414,7 +414,7 @@ void R_InitSpriteDefs ()
|
|||
int hash = hashes[intname % smax].Head;
|
||||
while (hash != -1)
|
||||
{
|
||||
FTexture *tex = TexMan[hash];
|
||||
FTexture *tex = TexMan.GetTexture(hash);
|
||||
if (TEX_DWNAME(tex) == intname)
|
||||
{
|
||||
bool res = R_InstallSpriteLump (FTextureID(hash), tex->Name[4] - 'A', tex->Name[5], false, sprtemp, maxframe);
|
||||
|
|
|
@ -28,9 +28,6 @@ struct FRenderer
|
|||
// renders view to a savegame picture
|
||||
virtual void WriteSavePic(player_t *player, FileWriter *file, int width, int height) = 0;
|
||||
|
||||
// render to a camera texture
|
||||
virtual void RenderTextureView(FCanvasTexture *tex, AActor *viewpoint, double fov) = 0;
|
||||
|
||||
// draws player sprites with hardware acceleration (only useful for software rendering)
|
||||
virtual void DrawRemainingPlayerSprites() = 0;
|
||||
|
||||
|
|
|
@ -44,19 +44,9 @@
|
|||
//
|
||||
FTextureID skyflatnum;
|
||||
FTextureID sky1texture, sky2texture;
|
||||
double skytexturemid;
|
||||
double skyscale;
|
||||
float skyiscale;
|
||||
bool skystretch;
|
||||
|
||||
fixed_t sky1cyl, sky2cyl;
|
||||
double sky1pos, sky2pos;
|
||||
float hw_sky1pos, hw_sky2pos;
|
||||
|
||||
CUSTOM_CVAR(Int, testskyoffset, 0, 0)
|
||||
{
|
||||
R_InitSkyMap();
|
||||
}
|
||||
bool skystretch;
|
||||
|
||||
// [RH] Stretch sky texture if not taller than 128 pixels?
|
||||
// Also now controls capped skies. 0 = normal, 1 = stretched, 2 = capped
|
||||
|
@ -67,10 +57,6 @@ CUSTOM_CVAR (Int, r_skymode, 2, CVAR_ARCHIVE)
|
|||
|
||||
CVAR(Float, skyoffset, 0, 0) // for testing
|
||||
|
||||
|
||||
|
||||
int freelookviewheight;
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_InitSkyMap
|
||||
|
@ -79,7 +65,7 @@ int freelookviewheight;
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_InitSkyMap ()
|
||||
void R_InitSkyMap()
|
||||
{
|
||||
int skyheight;
|
||||
FTexture *skytex1, *skytex2;
|
||||
|
@ -94,15 +80,15 @@ void R_InitSkyMap ()
|
|||
sky2texture = TexMan.CheckForTexture("-noflat-", ETextureType::Any);
|
||||
}
|
||||
|
||||
skytex1 = TexMan(sky1texture, true);
|
||||
skytex2 = TexMan(sky2texture, true);
|
||||
skytex1 = TexMan.GetTexture(sky1texture, false);
|
||||
skytex2 = TexMan.GetTexture(sky2texture, false);
|
||||
|
||||
if (skytex1 == nullptr)
|
||||
return;
|
||||
|
||||
if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetHeight() != skytex2->GetHeight())
|
||||
if ((level.flags & LEVEL_DOUBLESKY) && skytex1->GetDisplayHeight() != skytex2->GetDisplayHeight())
|
||||
{
|
||||
Printf (TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n");
|
||||
Printf(TEXTCOLOR_BOLD "Both sky textures must be the same height." TEXTCOLOR_NORMAL "\n");
|
||||
sky2texture = sky1texture;
|
||||
}
|
||||
|
||||
|
@ -119,47 +105,18 @@ void R_InitSkyMap ()
|
|||
// the screen when looking fully up.
|
||||
// h > 200: Unstretched, but the baseline is shifted down so that the top
|
||||
// of the texture is at the top of the screen when looking fully up.
|
||||
skyheight = skytex1->GetScaledHeight();
|
||||
skystretch = false;
|
||||
skytexturemid = 0;
|
||||
skyheight = skytex1->GetDisplayHeight();
|
||||
|
||||
if (skyheight >= 128 && skyheight < 200)
|
||||
{
|
||||
skystretch = (r_skymode == 1
|
||||
&& skyheight >= 128
|
||||
&& level.IsFreelookAllowed()
|
||||
&& !(level.flags & LEVEL_FORCETILEDSKY)) ? 1 : 0;
|
||||
skytexturemid = -28;
|
||||
&& skyheight >= 128
|
||||
&& level.IsFreelookAllowed()
|
||||
&& !(level.flags & LEVEL_FORCETILEDSKY)) ? 1 : 0;
|
||||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = (200 - skyheight) * skytex1->Scale.Y +((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->SkyOffset + testskyoffset : 0);
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
{
|
||||
skyiscale = float(r_Yaspect / freelookviewheight);
|
||||
skyscale = freelookviewheight / r_Yaspect;
|
||||
|
||||
skyiscale *= float(r_viewpoint.FieldOfView.Degrees / 90.);
|
||||
skyscale *= float(90. / r_viewpoint.FieldOfView.Degrees);
|
||||
}
|
||||
|
||||
if (skystretch)
|
||||
{
|
||||
skyscale *= (double)SKYSTRETCH_HEIGHT / skyheight;
|
||||
skyiscale *= skyheight / (float)SKYSTRETCH_HEIGHT;
|
||||
skytexturemid *= skyheight / (double)SKYSTRETCH_HEIGHT;
|
||||
}
|
||||
|
||||
// The standard Doom sky texture is 256 pixels wide, repeated 4 times over 360 degrees,
|
||||
// giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024,
|
||||
// we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of
|
||||
// the texture as the cylinder's circumfrence.
|
||||
sky1cyl = MAX(skytex1->GetWidth(), fixed_t(skytex1->Scale.X * 1024));
|
||||
sky2cyl = MAX(skytex2->GetWidth(), fixed_t(skytex2->Scale.Y * 1024));
|
||||
else skystretch = false;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_UpdateSky
|
||||
|
|
|
@ -31,13 +31,9 @@
|
|||
#include "textures/textures.h"
|
||||
|
||||
extern FTextureID skyflatnum;
|
||||
extern fixed_t sky1cyl, sky2cyl;
|
||||
extern FTextureID sky1texture, sky2texture;
|
||||
extern double sky1pos, sky2pos;
|
||||
extern float hw_sky1pos, hw_sky2pos;
|
||||
extern double skytexturemid;
|
||||
extern float skyiscale;
|
||||
extern double skyscale;
|
||||
extern bool skystretch;
|
||||
extern int freelookviewheight;
|
||||
|
||||
|
|
|
@ -144,7 +144,7 @@ bool setsizeneeded;
|
|||
unsigned int R_OldBlend = ~0;
|
||||
int validcount = 1; // increment every time a check is made
|
||||
int dl_validcount = 1; // increment every time a check is made
|
||||
FCanvasTextureInfo *FCanvasTextureInfo::List;
|
||||
int freelookviewheight;
|
||||
|
||||
DVector3a view;
|
||||
DAngle viewpitch;
|
||||
|
@ -431,7 +431,6 @@ static void R_Shutdown ()
|
|||
SWRenderer = nullptr;
|
||||
R_DeinitTranslationTables();
|
||||
R_DeinitColormaps ();
|
||||
FCanvasTextureInfo::EmptyList();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -1050,195 +1049,6 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
|||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: Add
|
||||
//
|
||||
// Assigns a camera to a canvas texture.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::Add (AActor *viewpoint, FTextureID picnum, double fov)
|
||||
{
|
||||
FCanvasTextureInfo *probe;
|
||||
FCanvasTexture *texture;
|
||||
|
||||
if (!picnum.isValid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
texture = static_cast<FCanvasTexture *>(TexMan[picnum]);
|
||||
if (!texture->bHasCanvas)
|
||||
{
|
||||
Printf ("%s is not a valid target for a camera\n", texture->Name.GetChars());
|
||||
return;
|
||||
}
|
||||
|
||||
// Is this texture already assigned to a camera?
|
||||
for (probe = List; probe != NULL; probe = probe->Next)
|
||||
{
|
||||
if (probe->Texture == texture)
|
||||
{
|
||||
// Yes, change its assignment to this new camera
|
||||
if (probe->Viewpoint != viewpoint || probe->FOV != fov)
|
||||
{
|
||||
texture->bFirstUpdate = true;
|
||||
}
|
||||
probe->Viewpoint = viewpoint;
|
||||
probe->FOV = fov;
|
||||
return;
|
||||
}
|
||||
}
|
||||
// No, create a new assignment
|
||||
probe = new FCanvasTextureInfo;
|
||||
probe->Viewpoint = viewpoint;
|
||||
probe->Texture = texture;
|
||||
probe->PicNum = picnum;
|
||||
probe->FOV = fov;
|
||||
probe->Next = List;
|
||||
texture->bFirstUpdate = true;
|
||||
List = probe;
|
||||
}
|
||||
|
||||
// [ZZ] expose this to ZScript
|
||||
void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov)
|
||||
{
|
||||
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
if (textureid.isValid())
|
||||
{
|
||||
// Only proceed if the texture actually has a canvas.
|
||||
FTexture *tex = TexMan[textureid];
|
||||
if (tex && tex->bHasCanvas)
|
||||
{
|
||||
FCanvasTextureInfo::Add(viewpoint, textureid, fov);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_OBJECT(viewpoint, AActor);
|
||||
PARAM_STRING(texturename); // [ZZ] there is no point in having this as FTextureID because it's easier to refer to a cameratexture by name and it isn't executed too often to cache it.
|
||||
PARAM_FLOAT(fov);
|
||||
SetCameraToTexture(viewpoint, texturename, fov);
|
||||
return 0;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: UpdateAll
|
||||
//
|
||||
// Updates all canvas textures that were visible in the last frame.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::UpdateAll ()
|
||||
{
|
||||
FCanvasTextureInfo *probe;
|
||||
|
||||
for (probe = List; probe != NULL; probe = probe->Next)
|
||||
{
|
||||
if (probe->Viewpoint != NULL && probe->Texture->bNeedsUpdate)
|
||||
{
|
||||
screen->RenderTextureView(probe->Texture, probe->Viewpoint, probe->FOV);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: EmptyList
|
||||
//
|
||||
// Removes all camera->texture assignments.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::EmptyList ()
|
||||
{
|
||||
FCanvasTextureInfo *probe, *next;
|
||||
|
||||
for (probe = List; probe != NULL; probe = next)
|
||||
{
|
||||
next = probe->Next;
|
||||
probe->Texture->Unload();
|
||||
delete probe;
|
||||
}
|
||||
List = NULL;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: Serialize
|
||||
//
|
||||
// Reads or writes the current set of mappings in an archive.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::Serialize(FSerializer &arc)
|
||||
{
|
||||
if (arc.isWriting())
|
||||
{
|
||||
if (List != nullptr)
|
||||
{
|
||||
if (arc.BeginArray("canvastextures"))
|
||||
{
|
||||
FCanvasTextureInfo *probe;
|
||||
|
||||
for (probe = List; probe != nullptr; probe = probe->Next)
|
||||
{
|
||||
if (probe->Texture != nullptr && probe->Viewpoint != nullptr)
|
||||
{
|
||||
if (arc.BeginObject(nullptr))
|
||||
{
|
||||
arc("viewpoint", probe->Viewpoint)
|
||||
("fov", probe->FOV)
|
||||
("texture", probe->PicNum)
|
||||
.EndObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
arc.EndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (arc.BeginArray("canvastextures"))
|
||||
{
|
||||
AActor *viewpoint = nullptr;
|
||||
double fov;
|
||||
FTextureID picnum;
|
||||
while (arc.BeginObject(nullptr))
|
||||
{
|
||||
arc("viewpoint", viewpoint)
|
||||
("fov", fov)
|
||||
("texture", picnum)
|
||||
.EndObject();
|
||||
Add(viewpoint, picnum, fov);
|
||||
}
|
||||
arc.EndArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// FCanvasTextureInfo :: Mark
|
||||
//
|
||||
// Marks all viewpoints in the list for the collector.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void FCanvasTextureInfo::Mark()
|
||||
{
|
||||
for (FCanvasTextureInfo *probe = List; probe != NULL; probe = probe->Next)
|
||||
{
|
||||
GC::Mark(probe->Viewpoint);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// CVAR transsouls
|
||||
|
|
|
@ -138,25 +138,5 @@ double R_ClampVisibility(double vis);
|
|||
extern void R_FreePastViewers ();
|
||||
extern void R_ClearPastViewer (AActor *actor);
|
||||
|
||||
class FCanvasTexture;
|
||||
// This list keeps track of the cameras that draw into canvas textures.
|
||||
struct FCanvasTextureInfo
|
||||
{
|
||||
FCanvasTextureInfo *Next;
|
||||
TObjPtr<AActor*> Viewpoint;
|
||||
FCanvasTexture *Texture;
|
||||
FTextureID PicNum;
|
||||
double FOV;
|
||||
|
||||
static void Add (AActor *viewpoint, FTextureID picnum, double fov);
|
||||
static void UpdateAll ();
|
||||
static void EmptyList ();
|
||||
static void Serialize(FSerializer &arc);
|
||||
static void Mark();
|
||||
|
||||
private:
|
||||
static FCanvasTextureInfo *List;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -53,7 +53,7 @@ static void CastCo2S(FString *a, int b) { PalEntry c(b); a->Format("%02x %02x %0
|
|||
static int CastS2So(FString *b) { return FSoundID(*b); }
|
||||
static void CastSo2S(FString *a, int b) { *a = S_sfx[b].name; }
|
||||
static void CastSID2S(FString *a, unsigned int b) { *a = (b >= sprites.Size()) ? "TNT1" : sprites[b].name; }
|
||||
static void CastTID2S(FString *a, int b) { auto tex = TexMan[*(FTextureID*)&b]; *a = (tex == nullptr) ? "(null)" : tex->Name.GetChars(); }
|
||||
static void CastTID2S(FString *a, int b) { auto tex = TexMan.GetTexture(*(FTextureID*)&b); *a = (tex == nullptr) ? "(null)" : tex->GetName().GetChars(); }
|
||||
|
||||
void JitCompiler::EmitCAST()
|
||||
{
|
||||
|
|
|
@ -1874,8 +1874,8 @@ static void DoCast(const VMRegisters ®, const VMFrame *f, int a, int b, int c
|
|||
case CAST_TID2S:
|
||||
{
|
||||
ASSERTS(a); ASSERTD(b);
|
||||
auto tex = TexMan[*(FTextureID*)&(reg.d[b])];
|
||||
reg.s[a] = tex == nullptr ? "(null)" : tex->Name.GetChars();
|
||||
auto tex = TexMan.GetTexture(*(FTextureID*)&(reg.d[b]));
|
||||
reg.s[a] = tex == nullptr ? "(null)" : tex->GetName().GetChars();
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -1584,6 +1584,19 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, ReplaceTextures, ReplaceTextures)
|
|||
return 0;
|
||||
}
|
||||
|
||||
void SetCameraToTexture(AActor *viewpoint, const FString &texturename, double fov);
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, SetCameraToTexture, SetCameraToTexture)
|
||||
{
|
||||
PARAM_PROLOGUE;
|
||||
PARAM_OBJECT(viewpoint, AActor);
|
||||
PARAM_STRING(texturename); // [ZZ] there is no point in having this as FTextureID because it's easier to refer to a cameratexture by name and it isn't executed too often to cache it.
|
||||
PARAM_FLOAT(fov);
|
||||
SetCameraToTexture(viewpoint, texturename, fov);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
//=====================================================================================
|
||||
//
|
||||
// secplane_t exports
|
||||
|
@ -2372,7 +2385,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, ReceivedWeapon, ReceivedWeapon)
|
|||
static int GetMugshot(DBaseStatusBar *self, int accuracy, int stateflags, const FString &def_face)
|
||||
{
|
||||
auto tex = self->mugshot.GetFace(self->CPlayer, def_face, accuracy, (FMugShot::StateFlags)stateflags);
|
||||
return (tex ? tex->id.GetIndex() : -1);
|
||||
return (tex ? tex->GetID().GetIndex() : -1);
|
||||
}
|
||||
|
||||
DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetMugshot, GetMugshot)
|
||||
|
|
|
@ -1515,7 +1515,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe
|
|||
}
|
||||
FTextureID chk = value;
|
||||
if (chk.GetIndex() >= TexMan.NumTextures()) chk.SetNull();
|
||||
FTexture *pic = TexMan[chk];
|
||||
FTexture *pic = TexMan.GetTexture(chk);
|
||||
const char *name;
|
||||
|
||||
if (Wads.GetLinkedTexture(pic->SourceLump) == pic)
|
||||
|
@ -1545,7 +1545,7 @@ FSerializer &Serialize(FSerializer &arc, const char *key, FTextureID &value, FTe
|
|||
assert(nameval.IsString() && typeval.IsInt());
|
||||
if (nameval.IsString() && typeval.IsInt())
|
||||
{
|
||||
value = TexMan.GetTexture(UnicodeToString(nameval.GetString()), static_cast<ETextureType>(typeval.GetInt()));
|
||||
value = TexMan.GetTextureID(UnicodeToString(nameval.GetString()), static_cast<ETextureType>(typeval.GetInt()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue