mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Corrige RenderTargetView
This commit is contained in:
parent
f5049cae2a
commit
2a1a94e72b
@ -59,6 +59,11 @@ namespace xna {
|
|||||||
D3D11_RASTERIZER_DESC Description{};
|
D3D11_RASTERIZER_DESC Description{};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RenderTarget2DImplementation {
|
||||||
|
comptr<ID3D11RenderTargetView> RenderTargetView;
|
||||||
|
D3D11_RENDER_TARGET_VIEW_DESC Description{};
|
||||||
|
};
|
||||||
|
|
||||||
struct SamplerStateImplementation {
|
struct SamplerStateImplementation {
|
||||||
comptr<ID3D11SamplerState> SamplerState;
|
comptr<ID3D11SamplerState> SamplerState;
|
||||||
D3D11_SAMPLER_DESC Description{};
|
D3D11_SAMPLER_DESC Description{};
|
||||||
@ -151,12 +156,7 @@ namespace xna {
|
|||||||
|
|
||||||
return !FAILED(hr);
|
return !FAILED(hr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RenderTarget2D::PlatformImplementation {
|
|
||||||
comptr<ID3D11RenderTargetView> _renderTargetView = nullptr;
|
|
||||||
D3D11_RENDER_TARGET_VIEW_DESC _renderTargetDesc{};
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class GameWindowMode : UINT {
|
enum class GameWindowMode : UINT {
|
||||||
Fullscreen = WS_POPUP | WS_VISIBLE,
|
Fullscreen = WS_POPUP | WS_VISIBLE,
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#ifndef XNA_GRAPHICS_RENDERTARGET_HPP
|
#ifndef XNA_GRAPHICS_RENDERTARGET_HPP
|
||||||
#define XNA_GRAPHICS_RENDERTARGET_HPP
|
#define XNA_GRAPHICS_RENDERTARGET_HPP
|
||||||
|
|
||||||
#include "../default.hpp"
|
|
||||||
#include "texture.hpp"
|
#include "texture.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
@ -11,14 +10,13 @@ namespace xna {
|
|||||||
class RenderTarget2D : public Texture2D {
|
class RenderTarget2D : public Texture2D {
|
||||||
public:
|
public:
|
||||||
RenderTarget2D();
|
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();
|
void Initialize();
|
||||||
public:
|
|
||||||
struct PlatformImplementation;
|
std::unique_ptr<RenderTarget2DImplementation> Implementation2;
|
||||||
uptr<PlatformImplementation> impl2 = nullptr;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ namespace xna {
|
|||||||
Implementation->RenderTarget2D = RenderTarget2D::FromBackBuffer(_this);
|
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);
|
Implementation->Context->OMSetRenderTargets(1, renderView.GetAddressOf(), nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ namespace xna {
|
|||||||
|
|
||||||
Implementation->Context->OMSetRenderTargets(
|
Implementation->Context->OMSetRenderTargets(
|
||||||
1,
|
1,
|
||||||
Implementation->RenderTarget2D->impl2->_renderTargetView.GetAddressOf(),
|
Implementation->RenderTarget2D->Implementation2->RenderTargetView.GetAddressOf(),
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@ -201,7 +201,7 @@ namespace xna {
|
|||||||
Implementation->backgroundColor[3] = v4.W;
|
Implementation->backgroundColor[3] = v4.W;
|
||||||
|
|
||||||
Implementation->Context->ClearRenderTargetView(
|
Implementation->Context->ClearRenderTargetView(
|
||||||
Implementation->RenderTarget2D->impl2->_renderTargetView.Get(),
|
Implementation->RenderTarget2D->Implementation2->RenderTargetView.Get(),
|
||||||
Implementation->backgroundColor);
|
Implementation->backgroundColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
RenderTarget2D::RenderTarget2D() : Texture2D(nullptr) {
|
RenderTarget2D::RenderTarget2D() : Texture2D(nullptr) {
|
||||||
impl2 = unew<PlatformImplementation>();
|
Implementation2 = unew<RenderTarget2DImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderTarget2D::RenderTarget2D(sptr<GraphicsDevice> const& device) : Texture2D(device) {
|
RenderTarget2D::RenderTarget2D(sptr<GraphicsDevice> const& device) : Texture2D(device) {
|
||||||
impl2 = unew<PlatformImplementation>();
|
Implementation2 = unew<RenderTarget2DImplementation>();
|
||||||
}
|
}
|
||||||
|
|
||||||
P_RenderTarget2D RenderTarget2D::FromBackBuffer(P_GraphicsDevice const& device) {
|
P_RenderTarget2D RenderTarget2D::FromBackBuffer(P_GraphicsDevice const& device) {
|
||||||
auto& swapChain = device->Implementation->SwapChain;
|
auto& swapChain = device->Implementation->SwapChain;
|
||||||
auto rt = snew<RenderTarget2D>(device);
|
auto rt = snew<RenderTarget2D>(device);
|
||||||
auto& implementation = rt->Implementation;
|
auto& implementation = rt->Implementation;
|
||||||
auto& implementation2 = rt->impl2;
|
auto& implementation2 = rt->Implementation2;
|
||||||
|
|
||||||
if (!swapChain->impl->GetBackBuffer(implementation->Texture2D))
|
if (!swapChain->impl->GetBackBuffer(implementation->Texture2D))
|
||||||
{
|
{
|
||||||
@ -30,7 +30,7 @@ namespace xna {
|
|||||||
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (impl2->_renderTargetView)
|
if (Implementation2->RenderTargetView)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Implementation->Description.Width = width;
|
Implementation->Description.Width = width;
|
||||||
@ -44,12 +44,12 @@ namespace xna {
|
|||||||
const auto hr = dxdevice->CreateRenderTargetView(
|
const auto hr = dxdevice->CreateRenderTargetView(
|
||||||
Implementation->Texture2D.Get(),
|
Implementation->Texture2D.Get(),
|
||||||
NULL,
|
NULL,
|
||||||
impl2->_renderTargetView.ReleaseAndGetAddressOf());
|
Implementation2->RenderTargetView.ReleaseAndGetAddressOf());
|
||||||
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
Exception::Throw(Exception::FAILED_TO_CREATE);
|
Exception::Throw(Exception::FAILED_TO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl2->_renderTargetView->GetDesc(&impl2->_renderTargetDesc);
|
Implementation2->RenderTargetView->GetDesc(&Implementation2->Description);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user