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

30 lines
651 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-03-21 16:01:47 -03:00
RenderTarget2D::RenderTarget2D(GraphicsDevice* device) {
_device = device;
2024-03-18 15:41:46 -03:00
}
bool RenderTarget2D::Apply() {
2024-03-21 16:01:47 -03:00
if (_texture2D) {
_texture2D->Release();
_texture2D = nullptr;
2024-03-18 15:41:46 -03:00
}
2024-03-21 16:01:47 -03:00
if (!_device->GetSwapChainBackBuffer(_texture2D))
2024-03-18 15:41:46 -03:00
return false;
2024-03-21 16:01:47 -03:00
auto& device = _device->_device;
2024-03-18 15:41:46 -03:00
2024-03-21 16:01:47 -03:00
if FAILED(device->CreateRenderTargetView(_texture2D, NULL, &_renderTargetView))
2024-03-18 15:41:46 -03:00
return false;
2024-03-21 16:01:47 -03:00
auto& context = _device->_context;
context->OMSetRenderTargets(1, &_renderTargetView, nullptr);
2024-03-18 15:41:46 -03:00
return true;
}
}