Cogs.Core
SwapChainD3D11.h
1#pragma once
2
3#include "../ISwapChain.h"
4#include "../Base/ResourcePointer.h"
5
6#include <d3d11.h>
7#include <dxgi1_6.h>
8
9namespace Cogs {
10 struct GraphicsDeviceD3D11;
11
12 class SwapChainD3D11 : public ISwapChain {
13 public:
16
17 bool initialize(WindowData* windowData);
18
19 virtual void beginFrame() override;
20 virtual void endFrame(uint32_t syncInterval = 0, uint32_t presentFlags = PresentFlags::None) override;
21
22 virtual void setSize(int newWidth, int newHeight, bool forceIt = false) override;
23 virtual void setFullscreen(bool enabled) override;
24
25 virtual bool isFullscreen() override;
26
27 virtual int getWidth() const override { return width; }
28 virtual int getHeight() const override { return height; }
29 virtual int getSamples() const override { return numSamples; }
30
31 virtual const RenderTargetHandle& getRenderTarget() const override { return renderTarget; }
32 virtual const DepthStencilHandle& getDepthStencil() const override { return depthStencil; }
33 ResourcePointer<ID3D11Texture2D>& getSharedBackBuffer() { return sharedBackBuffer; }
34
35 bool recreateOffscreenBuffers();
36
37 private:
38 GraphicsDeviceD3D11* graphicsDevice = nullptr;
39 TextureFormat colorFormat = TextureFormat::R8G8B8A8_UNORM_SRGB;
40 TextureFormat depthFormat = TextureFormat::D32_FLOAT;
41 int numSamples = 1;
42 int width = 1280;
43 int height = 720;
44 bool inFrame = false;
45 bool needResize = false;
46 ResourcePointer<IDXGISwapChain> swapChain;
47 ResourcePointer<ID3D11Texture2D> backBuffer;
48 ResourcePointer<ID3D11Texture2D> sharedBackBuffer;
49 RenderTargetHandle renderTarget;
50 DepthStencilHandle depthStencil;
51
52 void resize();
55 };
56}
virtual void beginFrame() override
Signal the beginning of a new frame to the graphics device.
bool createDepthStencilView()
Recreates the depth/stencil view used by directx when rendering.
virtual void endFrame(uint32_t syncInterval=0, uint32_t presentFlags=PresentFlags::None) override
Signal the end of a frame to the graphics device.
virtual int getSamples() const override
Returns the number of samples this swap chain has.
virtual void setFullscreen(bool enabled) override
Changes this swapchain's fullscreen state if neccessary.
virtual bool isFullscreen() override
Test whether the current swap chain is fullscreen.
virtual int getWidth() const override
Returns the pixel width of this swap chain.
virtual int getHeight() const override
Returns the pixel height of this swap chain.
virtual const DepthStencilHandle & getDepthStencil() const override
Returns the depth stencil managed by this swap chain.
bool createRenderTargetView()
Recreates the render target view used by directx when selecting render targets prior to rendering.
virtual void setSize(int newWidth, int newHeight, bool forceIt=false) override
Set the size of the main drawing buffer used by the graphics device in pixels.
virtual const RenderTargetHandle & getRenderTarget() const override
Returns the render target managed by this swap chain.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
@ None
No flags.
Definition: Common.h:177