Nui Engine
A game engine framework
Loading...
Searching...
No Matches
D3DManager.h
1#pragma once
2#include "Graphics/Common.h"
3
4namespace Nui::Graphics
5{
10 {
11 public:
15 D3DManager();
16
21
25 bool IsInitialized() const noexcept;
26
31 bool Init(HWND outputWindow);
32
36 void Reset();
37
41 void Present() const;
42
47 [[nodiscard]] inline ID3D11Device1* GetDevice() const noexcept { return m_device.Get(); }
48
53 [[nodiscard]] inline ID3D11DeviceContext1* GetImmediateContext() const noexcept { return m_immediateContext.Get(); }
54
59 [[nodiscard]] inline IDXGISwapChain1* GetSwapChain() const noexcept { return m_swapChain.Get(); }
60
65 [[nodiscard]] inline ID3D11RenderTargetView* GetBackBuffer() const noexcept { return m_bbRTView.Get(); }
66
71 [[nodiscard]] inline ID3D11Texture2D* GetBackBufferTexture() const noexcept { return m_bbTexture.Get(); }
72
77 [[nodiscard]] inline DXGI_FORMAT GetBackBufferFormat() const noexcept { return m_backBufferFormat; }
78
83 [[nodiscard]] inline U32 GetBackBufferWidth() const noexcept { return m_backBufferWidth; }
84
89 [[nodiscard]] inline U32 GetBackBufferHeight() const noexcept { return m_backBufferHeight; }
90
95 [[nodiscard]] inline U32 GetBBMultiSampleCount() const noexcept { return m_multiSampleCount; }
96
101 [[nodiscard]] inline U32 GetBBMultiSampleQuality() const noexcept { return m_multiSampleQuality; }
102
107 [[nodiscard]] bool IsVSyncEnabled() const noexcept { return m_vsync; }
108
113 [[nodiscard]] U32 GetNumVSyncInterval() const noexcept { return m_numVSYNCIntervals; }
114
120 void Resize(U32 width, U32 height) noexcept { m_backBufferWidth = width; m_backBufferHeight = height; }
121
122 inline void SetVSYNC(bool enableVSYNC) { m_vsync = enableVSYNC; }
123
124 private:
128 void CheckForSuitableOutput();
129
133 void AfterReset();
134
135 private:
136 ComPtr<IDXGIFactory2> m_factory;
137 ComPtr<IDXGIAdapter1> m_adapter;
138 ComPtr<IDXGIOutput> m_output;
139
140 ComPtr<ID3D11Device1> m_device;
141 ComPtr<ID3D11DeviceContext1> m_immediateContext;
142 ComPtr<IDXGISwapChain1> m_swapChain;
143 ComPtr<ID3D11Texture2D> m_bbTexture;
144 ComPtr<ID3D11RenderTargetView> m_bbRTView;
145
146 DXGI_FORMAT m_backBufferFormat;
147 U32 m_backBufferWidth;
148 U32 m_backBufferHeight;
149 U32 m_multiSampleCount;
150 U32 m_multiSampleQuality;
151 bool m_vsync;
152 DXGI_RATIONAL m_refreshRate;
153 U32 m_numVSYNCIntervals;
154
155 HWND m_hWnd;
156 D3D_FEATURE_LEVEL m_featureLevel;
157 D3D_FEATURE_LEVEL m_minFeatureLevel;
158 };
159}
Class managing DirectX 11 device resources including device, context, swap chain, and render target.
Definition D3DManager.h:10
bool IsVSyncEnabled() const noexcept
Checks if vertical synchronization is enabled.
Definition D3DManager.h:107
bool Init(HWND outputWindow)
Initializes the device resources.
Definition D3DManager.cpp:46
void Resize(U32 width, U32 height) noexcept
Resizes the back buffer.
Definition D3DManager.h:120
U32 GetBackBufferWidth() const noexcept
Retrieves the width of the back buffer.
Definition D3DManager.h:83
IDXGISwapChain1 * GetSwapChain() const noexcept
Retrieves the swap chain associated with the device.
Definition D3DManager.h:59
void Reset()
Resets the device resources.
Definition D3DManager.cpp:161
void Present() const
Presents the rendered image to the screen.
Definition D3DManager.cpp:180
bool IsInitialized() const noexcept
Checks if the device resources have been initialized.
Definition D3DManager.cpp:38
U32 GetBackBufferHeight() const noexcept
Retrieves the height of the back buffer.
Definition D3DManager.h:89
D3DManager()
Default constructor.
Definition D3DManager.cpp:5
ID3D11RenderTargetView * GetBackBuffer() const noexcept
Retrieves the render target view for the back buffer.
Definition D3DManager.h:65
DXGI_FORMAT GetBackBufferFormat() const noexcept
Retrieves the format of the back buffer.
Definition D3DManager.h:77
ID3D11Device1 * GetDevice() const noexcept
Retrieves the Direct3D device.
Definition D3DManager.h:47
U32 GetBBMultiSampleQuality() const noexcept
Retrieves the multi-sample quality of the back buffer.
Definition D3DManager.h:101
ID3D11DeviceContext1 * GetImmediateContext() const noexcept
Retrieves the immediate context for the device.
Definition D3DManager.h:53
U32 GetNumVSyncInterval() const noexcept
Retrieves the number of vertical synchronization intervals.
Definition D3DManager.h:113
U32 GetBBMultiSampleCount() const noexcept
Retrieves the multi-sample count of the back buffer.
Definition D3DManager.h:95
~D3DManager()
Destructor.
Definition D3DManager.cpp:20
ID3D11Texture2D * GetBackBufferTexture() const noexcept
Retrieves the back buffer texture.
Definition D3DManager.h:71