mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
- cleaned out the coordinate code in FMaterial.
This commit is contained in:
parent
c178313da5
commit
31035a6cea
8 changed files with 16 additions and 81 deletions
|
@ -121,13 +121,6 @@ FMaterial::FMaterial(FTexture * tx, bool expanded)
|
|||
}
|
||||
}
|
||||
}
|
||||
mWidth = tx->GetTexelWidth();
|
||||
mHeight = tx->GetTexelHeight();
|
||||
mLeftOffset = tx->GetLeftOffset(0); // These only get used by decals and decals should not use renderer-specific offsets.
|
||||
mTopOffset = tx->GetTopOffset(0);
|
||||
mRenderWidth = tx->GetScaledWidth();
|
||||
mRenderHeight = tx->GetScaledHeight();
|
||||
|
||||
mExpanded = expanded;
|
||||
|
||||
mTextureLayers.ShrinkToFit();
|
||||
|
|
|
@ -32,13 +32,6 @@ class FMaterial
|
|||
TArray<FTexture*> mTextureLayers;
|
||||
int mShaderIndex;
|
||||
int mLayerFlags = 0;
|
||||
|
||||
short mLeftOffset;
|
||||
short mTopOffset;
|
||||
short mWidth;
|
||||
short mHeight;
|
||||
short mRenderWidth;
|
||||
short mRenderHeight;
|
||||
bool mExpanded;
|
||||
|
||||
public:
|
||||
|
@ -48,7 +41,6 @@ public:
|
|||
FMaterial(FTexture *tex, bool forceexpand);
|
||||
~FMaterial();
|
||||
int GetLayerFlags() const { return mLayerFlags; }
|
||||
void SetSpriteRect();
|
||||
int GetShaderIndex() const { return mShaderIndex; }
|
||||
|
||||
FTexture* Source() const
|
||||
|
@ -60,28 +52,11 @@ public:
|
|||
// Only for spftpoly!
|
||||
return imgtex;
|
||||
}
|
||||
bool isFullbright() const
|
||||
{
|
||||
return sourcetex->isFullbright();
|
||||
}
|
||||
bool isHardwareCanvas() const
|
||||
{
|
||||
return sourcetex->isHardwareCanvas();
|
||||
}
|
||||
bool GetTranslucency()
|
||||
{
|
||||
// This queries the master texture to reduce recalculations.
|
||||
return imgtex->GetTranslucency();
|
||||
}
|
||||
void AddTextureLayer(FTexture *tex)
|
||||
{
|
||||
ValidateTexture(tex, false);
|
||||
mTextureLayers.Push(tex);
|
||||
}
|
||||
bool isMasked() const
|
||||
{
|
||||
return sourcetex->bMasked;
|
||||
}
|
||||
bool isExpanded() const
|
||||
{
|
||||
return mExpanded;
|
||||
|
@ -91,39 +66,9 @@ public:
|
|||
{
|
||||
return mTextureLayers.Size() + 1;
|
||||
}
|
||||
|
||||
bool hasCanvas()
|
||||
{
|
||||
return sourcetex->isHardwareCanvas();
|
||||
}
|
||||
|
||||
IHardwareTexture *GetLayer(int i, int translation, FTexture **pLayer = nullptr);
|
||||
|
||||
// Patch drawing utilities
|
||||
|
||||
// This is scaled size in integer units as needed by walls and flats
|
||||
int TextureHeight() const { return mRenderHeight; }
|
||||
int TextureWidth() const { return mRenderWidth; }
|
||||
|
||||
int GetWidth() const
|
||||
{
|
||||
return mWidth;
|
||||
}
|
||||
|
||||
int GetHeight() const
|
||||
{
|
||||
return mHeight;
|
||||
}
|
||||
|
||||
int GetLeftOffset() const
|
||||
{
|
||||
return mLeftOffset;
|
||||
}
|
||||
|
||||
int GetTopOffset() const
|
||||
{
|
||||
return mTopOffset;
|
||||
}
|
||||
|
||||
static FMaterial *ValidateTexture(FTexture * tex, bool expand, bool create = true);
|
||||
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans, bool create = true);
|
||||
|
|
|
@ -306,7 +306,7 @@ void FGLRenderer::BindToFrameBuffer(FMaterial *mat)
|
|||
FHardwareTexture::Unbind(0);
|
||||
gl_RenderState.ClearLastMaterial();
|
||||
}
|
||||
BaseLayer->BindToFrameBuffer(mat->GetWidth(), mat->GetHeight());
|
||||
BaseLayer->BindToFrameBuffer(mat->Source()->GetTexelWidth(), mat->Source()->GetTexelHeight());
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
@ -320,19 +320,18 @@ void FGLRenderer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint, doub
|
|||
// This doesn't need to clear the fake flat cache. It can be shared between camera textures and the main view of a scene.
|
||||
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
||||
|
||||
int width = gltex->TextureWidth();
|
||||
int height = gltex->TextureHeight();
|
||||
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||
|
||||
StartOffscreen();
|
||||
BindToFrameBuffer(gltex);
|
||||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
bounds.width = FHardwareTexture::GetTexDimension(gltex->GetWidth());
|
||||
bounds.height = FHardwareTexture::GetTexDimension(gltex->GetHeight());
|
||||
bounds.width = FHardwareTexture::GetTexDimension(tex->GetTexelWidth());
|
||||
bounds.height = FHardwareTexture::GetTexDimension(tex->GetTexelHeight());
|
||||
|
||||
FRenderViewpoint texvp;
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
||||
|
||||
EndOffscreen();
|
||||
|
||||
|
|
|
@ -298,7 +298,7 @@ void FGLRenderState::Apply()
|
|||
|
||||
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
||||
{
|
||||
if (mat->isHardwareCanvas())
|
||||
if (mat->Source()->isHardwareCanvas())
|
||||
{
|
||||
mTempTM = TM_OPAQUE;
|
||||
}
|
||||
|
|
|
@ -380,19 +380,18 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
|
|||
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
|
||||
auto BaseLayer = static_cast<PolyHardwareTexture*>(mat->GetLayer(0, 0));
|
||||
|
||||
int width = mat->TextureWidth();
|
||||
int height = mat->TextureHeight();
|
||||
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||
DCanvas *image = BaseLayer->GetImage(tex, 0, 0);
|
||||
PolyDepthStencil *depthStencil = BaseLayer->GetDepthStencil(tex);
|
||||
mRenderState->SetRenderTarget(image, depthStencil, false);
|
||||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
bounds.width = MIN(mat->GetWidth(), image->GetWidth());
|
||||
bounds.height = MIN(mat->GetHeight(), image->GetHeight());
|
||||
bounds.width = std::min(tex->GetTexelWidth(), image->GetWidth());
|
||||
bounds.height = std::min(tex->GetTexelHeight(), image->GetHeight());
|
||||
|
||||
FRenderViewpoint texvp;
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
||||
|
||||
FlushDrawCommands();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
|
|
@ -312,7 +312,7 @@ void PolyRenderState::ApplyMaterial()
|
|||
{
|
||||
if (mMaterial.mChanged && mMaterial.mMaterial)
|
||||
{
|
||||
mTempTM = mMaterial.mMaterial->isHardwareCanvas() ? TM_OPAQUE : TM_NORMAL;
|
||||
mTempTM = mMaterial.mMaterial->Source()->isHardwareCanvas() ? TM_OPAQUE : TM_NORMAL;
|
||||
|
||||
FTexture* layer;
|
||||
auto base = static_cast<PolyHardwareTexture*>(mMaterial.mMaterial->GetLayer(0, mMaterial.mTranslation, &layer));
|
||||
|
|
|
@ -369,7 +369,7 @@ void VkRenderState::ApplyPushConstants()
|
|||
}
|
||||
|
||||
int tempTM = TM_NORMAL;
|
||||
if (mMaterial.mMaterial && mMaterial.mMaterial->isHardwareCanvas())
|
||||
if (mMaterial.mMaterial && mMaterial.mMaterial->Source()->isHardwareCanvas())
|
||||
tempTM = TM_OPAQUE;
|
||||
|
||||
mPushConstants.uFogEnabled = fogset;
|
||||
|
|
|
@ -519,8 +519,7 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint
|
|||
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
|
||||
auto BaseLayer = static_cast<VkHardwareTexture*>(mat->GetLayer(0, 0));
|
||||
|
||||
int width = mat->TextureWidth();
|
||||
int height = mat->TextureHeight();
|
||||
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||
VkTextureImage *image = BaseLayer->GetImage(tex, 0, 0);
|
||||
VkTextureImage *depthStencil = BaseLayer->GetDepthStencil(tex);
|
||||
|
||||
|
@ -534,11 +533,11 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint
|
|||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
bounds.width = MIN(mat->GetWidth(), image->Image->width);
|
||||
bounds.height = MIN(mat->GetHeight(), image->Image->height);
|
||||
bounds.width = std::min(tex->GetTexelWidth(), image->Image->width);
|
||||
bounds.height = std::min(tex->GetTexelHeight(), image->Image->height);
|
||||
|
||||
FRenderViewpoint texvp;
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, ratio, ratio, false, false);
|
||||
|
||||
mRenderState->EndRenderPass();
|
||||
|
||||
|
|
Loading…
Reference in a new issue