Small cleanup

This commit is contained in:
2025-01-16 17:07:59 +01:00
parent 071caf51b6
commit 1457450fef
4 changed files with 61 additions and 12 deletions

View File

@@ -0,0 +1,5 @@
//
// Created by Bram on 16/01/2025.
//
#include "DX11Viewport.h"

View File

@@ -0,0 +1,51 @@
#ifndef GP1_DIRECTX_DX11VIEWPORT_H
#define GP1_DIRECTX_DX11VIEWPORT_H
#include <d3d11.h>
class DX11Viewport
{
public:
DX11Viewport(float width, float height, float topLeftX = 0.0f, float topLeftY = 0.0f, float minDepth = 0.0f, float maxDepth = 1.0f)
{
viewport.Width = width;
viewport.Height = height;
viewport.TopLeftX = topLeftX;
viewport.TopLeftY = topLeftY;
viewport.MinDepth = minDepth;
viewport.MaxDepth = maxDepth;
}
void Apply(ID3D11DeviceContext* context)
{
if (context)
{
context->RSSetViewports(1, &viewport);
}
}
void SetDimensions(float width, float height)
{
viewport.Width = width;
viewport.Height = height;
}
void SetPosition(float topLeftX, float topLeftY)
{
viewport.TopLeftX = topLeftX;
viewport.TopLeftY = topLeftY;
}
void SetDepthRange(float minDepth, float maxDepth)
{
viewport.MinDepth = minDepth;
viewport.MaxDepth = maxDepth;
}
const D3D11_VIEWPORT& GetViewport() const { return viewport; }
private:
D3D11_VIEWPORT viewport;
};
#endif //GP1_DIRECTX_DX11VIEWPORT_H

View File

@@ -9,7 +9,6 @@ public:
SamplerState(ID3D11Device* device);
~SamplerState();
bool Initialize();
ID3D11SamplerState* GetSamplerState() const { return m_samplerState; }
private: