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

34 lines
739 B
C++
Raw Normal View History

2024-03-18 15:41:46 -03:00
#include "rendertarget-dx.hpp"
#include "../graphics/device.hpp"
#include "swapchain-dx.hpp"
#include "device-dx.hpp"
namespace xna {
2024-04-22 11:22:18 -03:00
bool RenderTarget2D::Initialize(GraphicsDevice& device) {
if (!device._device)
return false;
2024-03-18 15:41:46 -03:00
2024-03-21 16:01:47 -03:00
if (_texture2D) {
_texture2D->Release();
_texture2D = nullptr;
2024-03-18 15:41:46 -03:00
}
2024-04-22 11:22:18 -03:00
if (!device._swapChain->GetBackBuffer(_texture2D))
2024-03-18 15:41:46 -03:00
return false;
2024-04-22 11:22:18 -03:00
auto& dxdevice = device._device;
2024-04-07 14:06:12 -03:00
2024-04-22 11:22:18 -03:00
const auto hr = dxdevice->CreateRenderTargetView(_texture2D, NULL, &_renderTargetView);
2024-03-18 15:41:46 -03:00
2024-04-22 11:22:18 -03:00
if (FAILED(hr))
return false;
2024-03-18 15:41:46 -03:00
return true;
}
2024-04-22 11:22:18 -03:00
bool RenderTarget2D::Apply(GraphicsDevice& device) {
auto& context = device._context;
context->OMSetRenderTargets(1, &_renderTargetView, nullptr);
return true;
}
2024-03-18 15:41:46 -03:00
}