Fix render to texture
This commit is contained in:
parent
cef3fd53ab
commit
fdb93309fe
7 changed files with 43 additions and 23 deletions
|
|
@ -97,6 +97,7 @@ void PolyFrameBuffer::CheckCanvas()
|
|||
{
|
||||
if (!mCanvas || mCanvas->GetWidth() != GetWidth() || mCanvas->GetHeight() != GetHeight())
|
||||
{
|
||||
FlushDrawCommands();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
|
||||
mCanvas.reset(new DCanvas(0, 0, true));
|
||||
|
|
@ -104,7 +105,7 @@ void PolyFrameBuffer::CheckCanvas()
|
|||
mDepthStencil.reset();
|
||||
mDepthStencil.reset(new PolyDepthStencil(GetWidth(), GetHeight()));
|
||||
|
||||
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil());
|
||||
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -342,7 +343,7 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
|
|||
int height = mat->TextureHeight();
|
||||
DCanvas *image = BaseLayer->GetImage(tex, 0, 0);
|
||||
PolyDepthStencil *depthStencil = BaseLayer->GetDepthStencil(tex);
|
||||
mRenderState->SetRenderTarget(image, depthStencil);
|
||||
mRenderState->SetRenderTarget(image, depthStencil, false);
|
||||
|
||||
IntRect bounds;
|
||||
bounds.left = bounds.top = 0;
|
||||
|
|
@ -352,8 +353,9 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture *tex, AActor *Viewpoint,
|
|||
FRenderViewpoint texvp;
|
||||
RenderViewpoint(texvp, Viewpoint, &bounds, FOV, (float)width / height, (float)width / height, false, false);
|
||||
|
||||
FlushDrawCommands();
|
||||
DrawerThreads::WaitForWorkers();
|
||||
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil());
|
||||
mRenderState->SetRenderTarget(GetCanvas(), GetDepthStencil(), true);
|
||||
|
||||
tex->SetUpdated(true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ void PolyRenderState::Apply()
|
|||
|
||||
if (mNeedApply)
|
||||
{
|
||||
mDrawCommands->SetViewport(mViewport.x, mViewport.y, mViewport.width, mViewport.height, mRenderTarget.Canvas, mRenderTarget.DepthStencil);
|
||||
mDrawCommands->SetViewport(mViewport.x, mViewport.y, mViewport.width, mViewport.height, mRenderTarget.Canvas, mRenderTarget.DepthStencil, mRenderTarget.TopDown);
|
||||
mDrawCommands->SetScissor(mScissor.x, mScissor.y, mScissor.width, mScissor.height);
|
||||
mDrawCommands->SetViewpointUniforms(mViewpointUniforms);
|
||||
mDrawCommands->SetDepthClamp(mDepthClamp);
|
||||
|
|
@ -282,7 +282,7 @@ void PolyRenderState::ApplyMaterial()
|
|||
if (base)
|
||||
{
|
||||
DCanvas *texcanvas = base->GetImage(mMaterial);
|
||||
mDrawCommands->SetTexture(0, texcanvas->GetPixels(), texcanvas->GetHeight(), texcanvas->GetWidth(), texcanvas->IsBgra());
|
||||
mDrawCommands->SetTexture(0, texcanvas->GetPixels(), texcanvas->GetWidth(), texcanvas->GetHeight(), texcanvas->IsBgra());
|
||||
|
||||
int numLayers = mMaterial.mMaterial->GetLayers();
|
||||
for (int i = 1; i < numLayers; i++)
|
||||
|
|
@ -291,7 +291,7 @@ void PolyRenderState::ApplyMaterial()
|
|||
auto systex = static_cast<PolyHardwareTexture*>(mMaterial.mMaterial->GetLayer(i, 0, &layer));
|
||||
|
||||
texcanvas = systex->GetImage(layer, 0, mMaterial.mMaterial->isExpanded() ? CTF_Expand : 0);
|
||||
mDrawCommands->SetTexture(i, texcanvas->GetPixels(), texcanvas->GetHeight(), texcanvas->GetWidth(), texcanvas->IsBgra());
|
||||
mDrawCommands->SetTexture(i, texcanvas->GetPixels(), texcanvas->GetWidth(), texcanvas->GetHeight(), texcanvas->IsBgra());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,10 +347,11 @@ void PolyRenderState::ApplyMatrices()
|
|||
}
|
||||
}
|
||||
|
||||
void PolyRenderState::SetRenderTarget(DCanvas *canvas, PolyDepthStencil *depthStencil)
|
||||
void PolyRenderState::SetRenderTarget(DCanvas *canvas, PolyDepthStencil *depthStencil, bool topdown)
|
||||
{
|
||||
mRenderTarget.Canvas = canvas;
|
||||
mRenderTarget.DepthStencil = depthStencil;
|
||||
mRenderTarget.TopDown = topdown;
|
||||
}
|
||||
|
||||
void PolyRenderState::Bind(PolyDataBuffer *buffer, uint32_t offset, uint32_t length)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public:
|
|||
void EnableLineSmooth(bool on) override;
|
||||
void EnableDrawBuffers(int count) override;
|
||||
|
||||
void SetRenderTarget(DCanvas *canvas, PolyDepthStencil *depthStencil);
|
||||
void SetRenderTarget(DCanvas *canvas, PolyDepthStencil *depthStencil, bool topdown);
|
||||
void Bind(PolyDataBuffer *buffer, uint32_t offset, uint32_t length);
|
||||
PolyVertexInputAssembly *GetVertexFormat(int numBindingPoints, int numAttributes, size_t stride, const FVertexBufferAttribute *attrs);
|
||||
void EndRenderPass();
|
||||
|
|
@ -69,6 +69,7 @@ private:
|
|||
{
|
||||
DCanvas *Canvas = nullptr;
|
||||
PolyDepthStencil *DepthStencil = nullptr;
|
||||
bool TopDown = true;
|
||||
} mRenderTarget;
|
||||
|
||||
struct Rect
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue