Blamite Game Engine - blam!  00296.01.12.21.0102.blamite
The core library for the Blamite Game Engine.
BlamRendering::DirectX Namespace Reference

Namespace containing functions exclusive to DirectX. More...

Namespaces

 D2D
 Namespace containing functions relating to Direct2D.
 
 Drawing
 Namespace containing functions to handle the drawing of Direct2D primitives.
 
 Utils
 Namespace containing various utilities related to rendering.
 
 WIC
 Namespace containing functions relating to the Windows Imaging Component (WIC).
 

Functions

BLAM ID3D11Device * GetD3DDevice ()
 Retrieves the current Direct3D device. More...
 
BLAM ID3D11DeviceContext * GetD3DContext ()
 Retrieves the current Direct3D context. More...
 
BLAM IDXGISwapChain * GetDXGISwapChain ()
 Retrieves the current DXGI Swap Chain. More...
 
BLAM ID3D11RenderTargetView * GetD3DRenderTargetView ()
 Retrieves the current Direct3D Render Target. More...
 
BLAM DXGI_SWAP_CHAIN_DESC GetSwapChainDesc ()
 Retrieves the current Direct3D Swap Chain description. More...
 
BLAM HRESULT Initialize (HWND hWnd)
 Initializes DirectX 11. More...
 
BLAM void Cleanup ()
 Cleans up all DirectX data. More...
 
BLAM HRESULT HandleWindowResize (LPARAM lParam)
 Handles a window resize event. More...
 
BLAM bool * RenderTargetClearing ()
 Retrieves whether or not to enable render target clearing. More...
 
BLAM void RenderLoop (bool debug)
 Renders everything to the screen. More...
 
BLAM void ShutdownRenderThread ()
 Instructs the rendering thread to stop running. More...
 
BLAM void RenderThread (bool debug)
 Instructs the engine to start rendering on a separate thread. More...
 
BLAM bool HasRenderThreadStopped ()
 Determines whether or not the render thread has finished stopping. More...
 
BLAM void SetClearColor (ImVec4 color)
 Changes the color to used to clear the render target. More...
 
BLAM ImVec4 * GetClearColor ()
 Retrieves the current color used to clear the render target. More...
 
BLAM HRESULT UpdateResolution (int x, int y)
 Changes the DirectX render target resolution. More...
 
BLAM ID3D11Texture2D ** GetLastFrameTexture ()
 Retrieves the last frame that was rendered. More...
 
BLAM HRESULT GetLastFrameTextureAlt (ID3D11Texture2D *texture)
 Retrieves the last frame that was rendered. More...
 
BLAM void ScreenshotDone ()
 Informs DirectX that the screenshot has finished being captured. More...
 
BLAM HRESULT GetLastFrameHResult ()
 Unused. More...
 
BLAM void DisplayDetailedCrashScreen (const char *expression, const char *file, int line, std::string details)
 Displays a detailed engine crash screen. More...
 
BLAM void DisplayBasicCrashScreen ()
 Displays a basic engine crash screen. More...
 
BLAM void DisplaySignalCrashScreen (int signal)
 Displays a signal-based engine crash screen. More...
 

Detailed Description

Namespace containing functions exclusive to DirectX.

Deprecated:
No new DirectX code should be written (if possible). Please continue all rendering work under Vulkan.

Function Documentation

◆ Cleanup()

void BlamRendering::DirectX::Cleanup ( )

Cleans up all DirectX data.

Cleanup the Direct3D device.

This function will call all needed functions to clean up Direct3D, Direct2D, and WIC data. As such, calling the other cleanup functions directly is not required.

◆ DisplayBasicCrashScreen()

void BlamRendering::DirectX::DisplayBasicCrashScreen ( )

Displays a basic engine crash screen.

After being displayed, the engine will try to upload files to Sentry and then exit.

◆ DisplayDetailedCrashScreen()

void BlamRendering::DirectX::DisplayDetailedCrashScreen ( const char *  expression,
const char *  file,
int  line,
std::string  details 
)

Displays a detailed engine crash screen.

After being displayed, the engine will try to upload files to Sentry and then exit.

Parameters
expression- The expression that caused the assertion failure.
file- The file that caused the assertion failure.
line- The line number in the file that caused the failure.
details- Additional details regarding the crash.

◆ DisplaySignalCrashScreen()

void BlamRendering::DirectX::DisplaySignalCrashScreen ( int  signal)

Displays a signal-based engine crash screen.

After being displayed, the engine will try to upload files to Sentry and then exit.

◆ GetClearColor()

ImVec4 * BlamRendering::DirectX::GetClearColor ( )

Retrieves the current color used to clear the render target.

Returns
A pointer to the render target clear color.

◆ GetD3DContext()

ID3D11DeviceContext * BlamRendering::DirectX::GetD3DContext ( )

Retrieves the current Direct3D context.

Returns
A pointer to the Direct3D 11 Device Context.

◆ GetD3DDevice()

ID3D11Device * BlamRendering::DirectX::GetD3DDevice ( )

Retrieves the current Direct3D device.

Returns
A pointer to the Direct3D 11 Device.

◆ GetD3DRenderTargetView()

ID3D11RenderTargetView * BlamRendering::DirectX::GetD3DRenderTargetView ( )

Retrieves the current Direct3D Render Target.

Returns
A pointer to the Direct3D Render Target View.

◆ GetDXGISwapChain()

IDXGISwapChain * BlamRendering::DirectX::GetDXGISwapChain ( )

Retrieves the current DXGI Swap Chain.

The swap chain contains two buffers, that alternate back and forth between being written to and being presented onscreen. While one buffer is being displayed, the other is written to. When the buffer being written is finished being modified, it is displayed - and the other buffer starts being written to.

Returns
A pointer to the DXGI Swap Chain.

◆ GetLastFrameHResult()

HRESULT BlamRendering::DirectX::GetLastFrameHResult ( )

Unused.

Deprecated:
This shit is broken but also not used, was used to try and copy the rendered frame. Will be removed soon.

◆ GetLastFrameTexture()

ID3D11Texture2D ** BlamRendering::DirectX::GetLastFrameTexture ( )

Retrieves the last frame that was rendered.

Returns
A pointer to the Direct3D 11 2D Texture representing the most recently rendered frame.

◆ GetLastFrameTextureAlt()

HRESULT BlamRendering::DirectX::GetLastFrameTextureAlt ( ID3D11Texture2D *  texture)

Retrieves the last frame that was rendered.

Deprecated:
This shit is broken but also not used, was used to try and copy the rendered frame. Will be removed soon.

◆ GetSwapChainDesc()

DXGI_SWAP_CHAIN_DESC BlamRendering::DirectX::GetSwapChainDesc ( )

Retrieves the current Direct3D Swap Chain description.

Returns
The Direct3D Swap Chain description.

◆ HandleWindowResize()

HRESULT BlamRendering::DirectX::HandleWindowResize ( LPARAM  lParam)

Handles a window resize event.

This function will resize the DirectX render target to match the window size upon resizing.

Parameters
lParam- The LPARAM from the WM_RESIZE message. Contains the new information for the window size.
Returns
S_OK if the render target was resized successfully, otherwise will return an error code.

◆ HasRenderThreadStopped()

bool BlamRendering::DirectX::HasRenderThreadStopped ( )

Determines whether or not the render thread has finished stopping.

This should always be checked against before beginning DirectX shutdown, otherwise resources will be disposed while still in use.

Returns
Whether or not the render thread has stopped.

◆ Initialize()

HRESULT BlamRendering::DirectX::Initialize ( HWND  hWnd)

Initializes DirectX 11.

This function will call all needed functions to load Direct3D, Direct2D, and the Windows Imaging Component. As such, calling those initialize functions directly is not required.

Parameters
hWnd- The window handle for DirectX to render to.
Returns
S_OK if DirectX initialized successfully, otherwise will return an error code.

◆ RenderLoop()

void BlamRendering::DirectX::RenderLoop ( bool  debug)

Renders everything to the screen.

Note
This function SHOULD NOT be called outside of the main applicaton loop. Additionally, this should never be directly called when handling rendering on a separate thread.
Parameters
debug- Legcay parameter enabling or disabling the crash screen display.
Todo:
Remove some of these commented out code (rn im keeping them because i may need them later)

◆ RenderTargetClearing()

bool * BlamRendering::DirectX::RenderTargetClearing ( )

Retrieves whether or not to enable render target clearing.

Todo:
Migrate this to an engine global.
Returns
A pointer to the boolean enabling or disabling render target clearing.

◆ RenderThread()

void BlamRendering::DirectX::RenderThread ( bool  debug)

Instructs the engine to start rendering on a separate thread.

This function replaecs the BlamRendering::DirectX::RenderLoop function entirely.

Note
Do NOT call this function outside of a thread, ever. It uses a while() loop, and will block the thread it is called on until BlamRendering::DirectX::ShutdownRenderThread is called.
Parameters
debug- Legcay parameter enabling or disabling the crash screen display.

◆ ScreenshotDone()

void BlamRendering::DirectX::ScreenshotDone ( )

Informs DirectX that the screenshot has finished being captured.

For screenshots, the entire rendering process must be halted to avoid the saved screenshot being incomplete. This function is used at the end of the screenshot function to unlock the render loop.

◆ SetClearColor()

void BlamRendering::DirectX::SetClearColor ( ImVec4  color)

Changes the color to used to clear the render target.

Parameters
color- The new color to use for render target clearing.

◆ ShutdownRenderThread()

void BlamRendering::DirectX::ShutdownRenderThread ( )

Instructs the rendering thread to stop running.

Note
This will not stop the rendering thread instantly. If we are in the middle of drawing a frame, the frame will finish rendering before the thread is stopped. This sets an internal boolean to false, a boolean which is used in a while loop for the thread.

◆ UpdateResolution()

HRESULT BlamRendering::DirectX::UpdateResolution ( int  x,
int  y 
)

Changes the DirectX render target resolution.

Parameters
x- The new width to render the screen at.
y- The new height to render the screen at.
Returns
S_OK if the resolution was updated, otherwise will contain an error code.