mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-03-01 22:41:01 +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;
|
mExpanded = expanded;
|
||||||
|
|
||||||
mTextureLayers.ShrinkToFit();
|
mTextureLayers.ShrinkToFit();
|
||||||
|
|
|
@ -32,13 +32,6 @@ class FMaterial
|
||||||
TArray<FTexture*> mTextureLayers;
|
TArray<FTexture*> mTextureLayers;
|
||||||
int mShaderIndex;
|
int mShaderIndex;
|
||||||
int mLayerFlags = 0;
|
int mLayerFlags = 0;
|
||||||
|
|
||||||
short mLeftOffset;
|
|
||||||
short mTopOffset;
|
|
||||||
short mWidth;
|
|
||||||
short mHeight;
|
|
||||||
short mRenderWidth;
|
|
||||||
short mRenderHeight;
|
|
||||||
bool mExpanded;
|
bool mExpanded;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -48,7 +41,6 @@ public:
|
||||||
FMaterial(FTexture *tex, bool forceexpand);
|
FMaterial(FTexture *tex, bool forceexpand);
|
||||||
~FMaterial();
|
~FMaterial();
|
||||||
int GetLayerFlags() const { return mLayerFlags; }
|
int GetLayerFlags() const { return mLayerFlags; }
|
||||||
void SetSpriteRect();
|
|
||||||
int GetShaderIndex() const { return mShaderIndex; }
|
int GetShaderIndex() const { return mShaderIndex; }
|
||||||
|
|
||||||
FTexture* Source() const
|
FTexture* Source() const
|
||||||
|
@ -60,28 +52,11 @@ public:
|
||||||
// Only for spftpoly!
|
// Only for spftpoly!
|
||||||
return imgtex;
|
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)
|
void AddTextureLayer(FTexture *tex)
|
||||||
{
|
{
|
||||||
ValidateTexture(tex, false);
|
ValidateTexture(tex, false);
|
||||||
mTextureLayers.Push(tex);
|
mTextureLayers.Push(tex);
|
||||||
}
|
}
|
||||||
bool isMasked() const
|
|
||||||
{
|
|
||||||
return sourcetex->bMasked;
|
|
||||||
}
|
|
||||||
bool isExpanded() const
|
bool isExpanded() const
|
||||||
{
|
{
|
||||||
return mExpanded;
|
return mExpanded;
|
||||||
|
@ -92,38 +67,8 @@ public:
|
||||||
return mTextureLayers.Size() + 1;
|
return mTextureLayers.Size() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasCanvas()
|
|
||||||
{
|
|
||||||
return sourcetex->isHardwareCanvas();
|
|
||||||
}
|
|
||||||
|
|
||||||
IHardwareTexture *GetLayer(int i, int translation, FTexture **pLayer = nullptr);
|
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(FTexture * tex, bool expand, bool create = true);
|
||||||
static FMaterial *ValidateTexture(FTextureID no, bool expand, bool trans, 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);
|
FHardwareTexture::Unbind(0);
|
||||||
gl_RenderState.ClearLastMaterial();
|
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.
|
// 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);
|
FMaterial * gltex = FMaterial::ValidateTexture(tex, false);
|
||||||
|
|
||||||
int width = gltex->TextureWidth();
|
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||||
int height = gltex->TextureHeight();
|
|
||||||
|
|
||||||
StartOffscreen();
|
StartOffscreen();
|
||||||
BindToFrameBuffer(gltex);
|
BindToFrameBuffer(gltex);
|
||||||
|
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = bounds.top = 0;
|
bounds.left = bounds.top = 0;
|
||||||
bounds.width = FHardwareTexture::GetTexDimension(gltex->GetWidth());
|
bounds.width = FHardwareTexture::GetTexDimension(tex->GetTexelWidth());
|
||||||
bounds.height = FHardwareTexture::GetTexDimension(gltex->GetHeight());
|
bounds.height = FHardwareTexture::GetTexDimension(tex->GetTexelHeight());
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
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();
|
EndOffscreen();
|
||||||
|
|
||||||
|
|
|
@ -298,7 +298,7 @@ void FGLRenderState::Apply()
|
||||||
|
|
||||||
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translation, int overrideshader)
|
||||||
{
|
{
|
||||||
if (mat->isHardwareCanvas())
|
if (mat->Source()->isHardwareCanvas())
|
||||||
{
|
{
|
||||||
mTempTM = TM_OPAQUE;
|
mTempTM = TM_OPAQUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -380,19 +380,18 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
|
||||||
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
|
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
|
||||||
auto BaseLayer = static_cast<PolyHardwareTexture*>(mat->GetLayer(0, 0));
|
auto BaseLayer = static_cast<PolyHardwareTexture*>(mat->GetLayer(0, 0));
|
||||||
|
|
||||||
int width = mat->TextureWidth();
|
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||||
int height = mat->TextureHeight();
|
|
||||||
DCanvas *image = BaseLayer->GetImage(tex, 0, 0);
|
DCanvas *image = BaseLayer->GetImage(tex, 0, 0);
|
||||||
PolyDepthStencil *depthStencil = BaseLayer->GetDepthStencil(tex);
|
PolyDepthStencil *depthStencil = BaseLayer->GetDepthStencil(tex);
|
||||||
mRenderState->SetRenderTarget(image, depthStencil, false);
|
mRenderState->SetRenderTarget(image, depthStencil, false);
|
||||||
|
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = bounds.top = 0;
|
bounds.left = bounds.top = 0;
|
||||||
bounds.width = MIN(mat->GetWidth(), image->GetWidth());
|
bounds.width = std::min(tex->GetTexelWidth(), image->GetWidth());
|
||||||
bounds.height = MIN(mat->GetHeight(), image->GetHeight());
|
bounds.height = std::min(tex->GetTexelHeight(), image->GetHeight());
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
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();
|
FlushDrawCommands();
|
||||||
DrawerThreads::WaitForWorkers();
|
DrawerThreads::WaitForWorkers();
|
||||||
|
|
|
@ -312,7 +312,7 @@ void PolyRenderState::ApplyMaterial()
|
||||||
{
|
{
|
||||||
if (mMaterial.mChanged && mMaterial.mMaterial)
|
if (mMaterial.mChanged && mMaterial.mMaterial)
|
||||||
{
|
{
|
||||||
mTempTM = mMaterial.mMaterial->isHardwareCanvas() ? TM_OPAQUE : TM_NORMAL;
|
mTempTM = mMaterial.mMaterial->Source()->isHardwareCanvas() ? TM_OPAQUE : TM_NORMAL;
|
||||||
|
|
||||||
FTexture* layer;
|
FTexture* layer;
|
||||||
auto base = static_cast<PolyHardwareTexture*>(mMaterial.mMaterial->GetLayer(0, mMaterial.mTranslation, &layer));
|
auto base = static_cast<PolyHardwareTexture*>(mMaterial.mMaterial->GetLayer(0, mMaterial.mTranslation, &layer));
|
||||||
|
|
|
@ -369,7 +369,7 @@ void VkRenderState::ApplyPushConstants()
|
||||||
}
|
}
|
||||||
|
|
||||||
int tempTM = TM_NORMAL;
|
int tempTM = TM_NORMAL;
|
||||||
if (mMaterial.mMaterial && mMaterial.mMaterial->isHardwareCanvas())
|
if (mMaterial.mMaterial && mMaterial.mMaterial->Source()->isHardwareCanvas())
|
||||||
tempTM = TM_OPAQUE;
|
tempTM = TM_OPAQUE;
|
||||||
|
|
||||||
mPushConstants.uFogEnabled = fogset;
|
mPushConstants.uFogEnabled = fogset;
|
||||||
|
|
|
@ -519,8 +519,7 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint
|
||||||
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
|
FMaterial *mat = FMaterial::ValidateTexture(tex, false);
|
||||||
auto BaseLayer = static_cast<VkHardwareTexture*>(mat->GetLayer(0, 0));
|
auto BaseLayer = static_cast<VkHardwareTexture*>(mat->GetLayer(0, 0));
|
||||||
|
|
||||||
int width = mat->TextureWidth();
|
float ratio = (float)tex->GetDisplayWidthDouble() / (float)tex->GetDisplayHeightDouble();
|
||||||
int height = mat->TextureHeight();
|
|
||||||
VkTextureImage *image = BaseLayer->GetImage(tex, 0, 0);
|
VkTextureImage *image = BaseLayer->GetImage(tex, 0, 0);
|
||||||
VkTextureImage *depthStencil = BaseLayer->GetDepthStencil(tex);
|
VkTextureImage *depthStencil = BaseLayer->GetDepthStencil(tex);
|
||||||
|
|
||||||
|
@ -534,11 +533,11 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint
|
||||||
|
|
||||||
IntRect bounds;
|
IntRect bounds;
|
||||||
bounds.left = bounds.top = 0;
|
bounds.left = bounds.top = 0;
|
||||||
bounds.width = MIN(mat->GetWidth(), image->Image->width);
|
bounds.width = std::min(tex->GetTexelWidth(), image->Image->width);
|
||||||
bounds.height = MIN(mat->GetHeight(), image->Image->height);
|
bounds.height = std::min(tex->GetTexelHeight(), image->Image->height);
|
||||||
|
|
||||||
FRenderViewpoint texvp;
|
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();
|
mRenderState->EndRenderPass();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue