Minor - Optimise l'accès aux ressources D3D - V14.10.0

Refactorise l'accès aux interfaces Direct3D pour plus de clarté et d'efficacité, en utilisant des accesseurs `const` et en déplaçant certaines fonctions directement dans l'en-tête.

Cela simplifie l'utilisation des ressources D3D et améliore la lisibilité du code.
This commit is contained in:
2025-11-02 01:22:50 +01:00
parent 1a92ac64d7
commit 040d919b69
7 changed files with 31 additions and 79 deletions

View File

@@ -75,20 +75,20 @@ public:
*
* @return Pointer to the ID3D11Device interface.
*/
ID3D11Device* get_device();
ID3D11Device* get_device() const { return device_; };
/**
* @brief Gets the Direct3D device context.
*
* @return Pointer to the ID3D11DeviceContext interface.
*/
ID3D11DeviceContext* get_device_context();
ID3D11DeviceContext* get_device_context() const { return device_context_; };
//XMMATRIX get_projection_matrix(XMMATRIX& projectionMatrix);
IDXGISwapChain* swap_chain;
/**
* Get the swap chain associated with the Direct3D device.
* @return Pointer to the IDXGISwapChain interface.
*/
IDXGISwapChain* get_swap_chain();
IDXGISwapChain* get_swap_chain() const { return swap_chain; };
/**
* Resizes the swap chain to the specified width and height.
* @param width New width of the swap chain.
@@ -100,7 +100,7 @@ public:
*
* @param vsync True to enable vertical sync, false to disable.
*/
void set_vsync(bool vsync);
void set_vsync(bool vsync) { vsync_enabled_ = vsync; };
/**
* Get the projection matrix.
@@ -135,7 +135,10 @@ public:
/**
* Resets the viewport to the default settings.
*/
void reset_viewport();
void reset_viewport() const
{
device_context_->RSSetViewports(1, &viewport_);
}
/**
* Release all Direct3D resources.
@@ -151,11 +154,17 @@ public:
/**
* Turn on the Z-buffer to enable depth.
*/
void turn_z_buffer_on();
void turn_z_buffer_on()const
{
device_context_->OMSetDepthStencilState(depth_stencil_state_, 1);
}
/**
* Turn off the Z-buffer to disable depth.
*/
void turn_z_buffer_off();
void turn_z_buffer_off() const
{
device_context_->OMSetDepthStencilState(depth_disabled_stencil_state_, 1);
}
/**
* Turn on alpha blending for transparency effects.