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
|
|
|
}
|
|
|
|
|
2024-04-07 14:06:12 -03:00
|
|
|
bool RenderTarget2D::Bind() {
|
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-04-07 14:06:12 -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;
|
|
|
|
}
|
|
|
|
}
|