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

38 lines
816 B
C++
Raw Normal View History

2024-03-18 15:41:46 -03:00
#ifndef XNA_PLATFORM_SWAPCHAIN_DX_HPP
#define XNA_PLATFORM_SWAPCHAIN_DX_HPP
#include "../graphics/swapchain.hpp"
#include "window-dx.hpp"
#include "dxgi.h"
#include "d3d11.h"
namespace xna {
2024-03-21 16:01:47 -03:00
class SwapChain : public ISwapChain{
2024-03-18 15:41:46 -03:00
public:
2024-03-21 16:01:47 -03:00
SwapChain(GraphicsDevice* device);
2024-03-18 15:41:46 -03:00
2024-03-21 16:01:47 -03:00
virtual ~SwapChain() override {
2024-03-18 15:41:46 -03:00
if (_swapChain) {
_swapChain->Release();
_swapChain = nullptr;
}
}
2024-03-21 16:01:47 -03:00
virtual bool Initialize(GameWindow const& gameWindow) override;
virtual bool Apply() override;
2024-03-18 15:41:46 -03:00
bool GetBackBuffer(ID3D11Texture2D*& texture2D) {
if FAILED(_swapChain->GetBuffer(0, __uuidof(texture2D), (void**)(&texture2D)))
return false;
return true;
}
2024-03-21 16:01:47 -03:00
public:
IDXGISwapChain* _swapChain{ nullptr };
DXGI_SWAP_CHAIN_DESC _swapDescription{};
GraphicsDevice* _device{ nullptr };
};
2024-03-18 15:41:46 -03:00
}
#endif