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

52 lines
1.3 KiB
C++
Raw Normal View History

2024-07-13 22:55:36 -03:00
#include "xna/xna-dx.hpp"
2024-03-18 15:41:46 -03:00
namespace xna {
RenderTarget2D::RenderTarget2D() : Texture2D(nullptr) {
impl2 = unew<PlatformImplementation>();
}
2024-05-23 14:38:16 -03:00
RenderTarget2D::RenderTarget2D(sptr<GraphicsDevice> const& device) : Texture2D(device) {
impl2 = unew<PlatformImplementation>();
}
2024-05-23 14:38:16 -03:00
P_RenderTarget2D RenderTarget2D::FromBackBuffer(P_GraphicsDevice const& device) {
auto& swapChain = device->impl->_swapChain;
auto rt = snew<RenderTarget2D>(device);
auto& implementation = rt->impl;
auto& implementation2 = rt->impl2;
2024-03-18 15:41:46 -03:00
if (!swapChain->impl->GetBackBuffer(implementation->dxTexture2D))
{
Exception::Throw(Exception::FAILED_TO_CREATE);
}
rt->Initialize();
return rt;
}
void RenderTarget2D::Initialize() {
if (!impl || !m_device || !m_device->impl->_device) {
Exception::Throw(Exception::UNABLE_TO_INITIALIZE);
}
impl->dxDescription.Width = width;
impl->dxDescription.Height = height;
impl->dxDescription.BindFlags = D3D11_BIND_FLAG::D3D11_BIND_RENDER_TARGET;
Texture2D::Initialize();
2024-05-24 22:26:10 -03:00
auto& dxdevice = m_device->impl->_device;
2024-04-07 14:06:12 -03:00
const auto hr = dxdevice->CreateRenderTargetView(
impl->dxTexture2D.Get(),
NULL,
impl2->_renderTargetView.ReleaseAndGetAddressOf());
2024-03-18 15:41:46 -03:00
2024-05-04 21:07:39 -03:00
if (FAILED(hr)) {
2024-07-06 12:20:54 -03:00
Exception::Throw(Exception::FAILED_TO_CREATE);
2024-05-04 21:07:39 -03:00
}
2024-03-18 15:41:46 -03:00
impl2->_renderTargetView->GetDesc(&impl2->_renderTargetDesc);
2024-03-18 15:41:46 -03:00
}
}