Move TexMan.GetCanvas and GetTextureCanvas to common
This commit is contained in:
parent
753822359e
commit
e2778ba442
9 changed files with 56 additions and 43 deletions
|
|
@ -41,6 +41,7 @@
|
|||
#include "v_draw.h"
|
||||
#include "v_video.h"
|
||||
#include "fcolormap.h"
|
||||
#include "texturemanager.h"
|
||||
|
||||
static F2DDrawer drawer = F2DDrawer();
|
||||
F2DDrawer* twod = &drawer;
|
||||
|
|
@ -1228,3 +1229,48 @@ F2DVertexBuffer::F2DVertexBuffer()
|
|||
};
|
||||
mVertexBuffer->SetFormat(1, 3, sizeof(F2DDrawer::TwoDVertex), format);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
//
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
TArray<FCanvas*> AllCanvases;
|
||||
|
||||
class InitTextureCanvasGC
|
||||
{
|
||||
public:
|
||||
InitTextureCanvasGC()
|
||||
{
|
||||
GC::AddMarkerFunc([]() {
|
||||
for (auto canvas : AllCanvases)
|
||||
GC::Mark(canvas);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
FCanvas* GetTextureCanvas(const FString& texturename)
|
||||
{
|
||||
FTextureID textureid = TexMan.CheckForTexture(texturename, ETextureType::Wall, FTextureManager::TEXMAN_Overridable);
|
||||
if (textureid.isValid())
|
||||
{
|
||||
// Only proceed if the texture is a canvas texture.
|
||||
auto tex = TexMan.GetGameTexture(textureid);
|
||||
if (tex && tex->GetTexture()->isCanvas())
|
||||
{
|
||||
FCanvasTexture* canvasTex = static_cast<FCanvasTexture*>(tex->GetTexture());
|
||||
if (!canvasTex->Canvas)
|
||||
{
|
||||
static InitTextureCanvasGC initCanvasGC; // Does the common code have a natural init function this could be moved to?
|
||||
|
||||
canvasTex->Canvas = Create<FCanvas>();
|
||||
canvasTex->Canvas->Tex = canvasTex;
|
||||
canvasTex->Canvas->Drawer.SetSize(tex->GetTexelWidth(), tex->GetTexelHeight());
|
||||
AllCanvases.Push(canvasTex->Canvas);
|
||||
}
|
||||
return canvasTex->Canvas;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue