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

Corrige RenderTargetView

This commit is contained in:
Danilo 2024-11-16 14:28:29 -03:00
parent f5049cae2a
commit 2a1a94e72b
4 changed files with 20 additions and 22 deletions

View File

@ -59,6 +59,11 @@ namespace xna {
D3D11_RASTERIZER_DESC Description{};
};
struct RenderTarget2DImplementation {
comptr<ID3D11RenderTargetView> RenderTargetView;
D3D11_RENDER_TARGET_VIEW_DESC Description{};
};
struct SamplerStateImplementation {
comptr<ID3D11SamplerState> SamplerState;
D3D11_SAMPLER_DESC Description{};
@ -151,12 +156,7 @@ namespace xna {
return !FAILED(hr);
}
};
struct RenderTarget2D::PlatformImplementation {
comptr<ID3D11RenderTargetView> _renderTargetView = nullptr;
D3D11_RENDER_TARGET_VIEW_DESC _renderTargetDesc{};
};
};
enum class GameWindowMode : UINT {
Fullscreen = WS_POPUP | WS_VISIBLE,

View File

@ -1,7 +1,6 @@
#ifndef XNA_GRAPHICS_RENDERTARGET_HPP
#define XNA_GRAPHICS_RENDERTARGET_HPP
#include "../default.hpp"
#include "texture.hpp"
namespace xna {
@ -11,14 +10,13 @@ namespace xna {
class RenderTarget2D : public Texture2D {
public:
RenderTarget2D();
RenderTarget2D(sptr<GraphicsDevice> const& device);
RenderTarget2D(std::shared_ptr<GraphicsDevice> const& device);
static P_RenderTarget2D FromBackBuffer(P_GraphicsDevice const& device);
static P_RenderTarget2D FromBackBuffer(std::shared_ptr<GraphicsDevice> const& device);
void Initialize();
public:
struct PlatformImplementation;
uptr<PlatformImplementation> impl2 = nullptr;
void Initialize();
std::unique_ptr<RenderTarget2DImplementation> Implementation2;
};
}

View File

@ -175,7 +175,7 @@ namespace xna {
Implementation->RenderTarget2D = RenderTarget2D::FromBackBuffer(_this);
}
const auto& renderView = Implementation->RenderTarget2D->impl2->_renderTargetView;
const auto& renderView = Implementation->RenderTarget2D->Implementation2->RenderTargetView;
Implementation->Context->OMSetRenderTargets(1, renderView.GetAddressOf(), nullptr);
}
@ -184,7 +184,7 @@ namespace xna {
Implementation->Context->OMSetRenderTargets(
1,
Implementation->RenderTarget2D->impl2->_renderTargetView.GetAddressOf(),
Implementation->RenderTarget2D->Implementation2->RenderTargetView.GetAddressOf(),
nullptr);
return result;
@ -201,7 +201,7 @@ namespace xna {
Implementation->backgroundColor[3] = v4.W;
Implementation->Context->ClearRenderTargetView(
Implementation->RenderTarget2D->impl2->_renderTargetView.Get(),
Implementation->RenderTarget2D->Implementation2->RenderTargetView.Get(),
Implementation->backgroundColor);
}

View File

@ -2,18 +2,18 @@
namespace xna {
RenderTarget2D::RenderTarget2D() : Texture2D(nullptr) {
impl2 = unew<PlatformImplementation>();
Implementation2 = unew<RenderTarget2DImplementation>();
}
RenderTarget2D::RenderTarget2D(sptr<GraphicsDevice> const& device) : Texture2D(device) {
impl2 = unew<PlatformImplementation>();
Implementation2 = unew<RenderTarget2DImplementation>();
}
P_RenderTarget2D RenderTarget2D::FromBackBuffer(P_GraphicsDevice const& device) {
auto& swapChain = device->Implementation->SwapChain;
auto rt = snew<RenderTarget2D>(device);
auto& implementation = rt->Implementation;
auto& implementation2 = rt->impl2;
auto& implementation2 = rt->Implementation2;
if (!swapChain->impl->GetBackBuffer(implementation->Texture2D))
{
@ -30,7 +30,7 @@ namespace xna {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
}
if (impl2->_renderTargetView)
if (Implementation2->RenderTargetView)
return;
Implementation->Description.Width = width;
@ -44,12 +44,12 @@ namespace xna {
const auto hr = dxdevice->CreateRenderTargetView(
Implementation->Texture2D.Get(),
NULL,
impl2->_renderTargetView.ReleaseAndGetAddressOf());
Implementation2->RenderTargetView.ReleaseAndGetAddressOf());
if (FAILED(hr)) {
Exception::Throw(Exception::FAILED_TO_CREATE);
}
impl2->_renderTargetView->GetDesc(&impl2->_renderTargetDesc);
Implementation2->RenderTargetView->GetDesc(&Implementation2->Description);
}
}