1
0
mirror of https://github.com/borgesdan/xn65 synced 2024-12-29 21:54:47 +01:00

Implementa GraphicsDevice::SetRenderTarget

This commit is contained in:
Danilo 2024-08-05 17:32:28 -03:00
parent 491626d654
commit b27b04388a
3 changed files with 15 additions and 3 deletions

View File

@ -101,13 +101,19 @@ namespace xna {
//Render Target
//
impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this);
if (renderTarget) {
renderTarget->Initialize();
impl->_renderTarget2D = renderTarget;
}
else {
impl->_renderTarget2D = RenderTarget2D::FromBackBuffer(_this);
}
const auto& renderView = impl->_renderTarget2D->impl2->_renderTargetView;
impl->_context->OMSetRenderTargets(1, renderView.GetAddressOf(), nullptr);
}
bool GraphicsDevice::Present() const {
const auto currentPresenInterval = presentationParameters->PresentationInterval;
bool result = impl->_swapChain->Present(impl->vSyncValue != 0);
impl->_context->OMSetRenderTargets(

View File

@ -30,6 +30,9 @@ namespace xna {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
}
if (impl2->_renderTargetView)
return;
impl->dxDescription.Width = width;
impl->dxDescription.Height = height;
impl->dxDescription.BindFlags = D3D11_BIND_FLAG::D3D11_BIND_RENDER_TARGET;

View File

@ -45,7 +45,9 @@ namespace xna {
constexpr xna::Viewport Viewport() const { return viewport; }
//Gets or sets a viewport identifying the portion of the render target to receive draw calls.
void Viewport(xna::Viewport const& viewport);
//Sets a new render target for this GraphicsDevice.
void SetRenderTarget(P_RenderTarget2D const& renderTarget) { this->renderTarget = renderTarget; }
void Initialize();
private:
@ -55,6 +57,7 @@ namespace xna {
P_RasterizerState rasterizerState{ nullptr };
P_SamplerStateCollection samplerStateCollection{ nullptr };
P_PresentationParameters presentationParameters{ nullptr };
P_RenderTarget2D renderTarget{ nullptr };
GraphicsProfile graphicsProfile{ GraphicsProfile::HiDef };
xna::Viewport viewport{};