Minor Update - Logger transformer en Singleton

This commit is contained in:
2024-04-12 17:59:44 +02:00
parent 3bc9eee3cc
commit 25f05fe217
52 changed files with 535 additions and 519 deletions

View File

@@ -26,7 +26,7 @@ MultiTextureShaderClass::~MultiTextureShaderClass()
bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
{
logger.Log("Initializing MultiTextureShaderClass", __FILE__, __LINE__);
Logger::Get().Log("Initializing MultiTextureShaderClass", __FILE__, __LINE__);
bool result;
wchar_t vsFilename[128];
@@ -37,7 +37,7 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
error = wcscpy_s(vsFilename, 128, L"multitexture.vs");
if (error != 0)
{
logger.Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -45,7 +45,7 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
error = wcscpy_s(psFilename, 128, L"multitexture.ps");
if (error != 0)
{
logger.Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -53,7 +53,7 @@ bool MultiTextureShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
result = InitializeShader(device, hwnd, vsFilename, psFilename);
if (!result)
{
logger.Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -78,7 +78,7 @@ bool MultiTextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int ind
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2);
if (!result)
{
logger.Log("Failed to set the shader parameters that it will use for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to set the shader parameters that it will use for rendering", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -90,7 +90,7 @@ bool MultiTextureShaderClass::Render(ID3D11DeviceContext* deviceContext, int ind
bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
logger.Log("Initializing the shader", __FILE__, __LINE__);
Logger::Get().Log("Initializing the shader", __FILE__, __LINE__);
HRESULT result;
ID3D10Blob* errorMessage;
@@ -120,7 +120,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// If there was nothing in the error message then it simply could not find the shader file itself.
else
{
logger.Log("Failed to compile the vertex shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to compile the vertex shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
}
return false;
@@ -139,7 +139,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
// If there was nothing in the error message then it simply could not find the file itself.
else
{
logger.Log("Failed to compile the pixel shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to compile the pixel shader code", __FILE__, __LINE__, Logger::LogLevel::Error);
}
return false;
@@ -149,7 +149,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
result = device->CreateVertexShader(vertexShaderBuffer->GetBufferPointer(), vertexShaderBuffer->GetBufferSize(), NULL, &m_vertexShader);
if (FAILED(result))
{
logger.Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create the vertex shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -157,7 +157,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
result = device->CreatePixelShader(pixelShaderBuffer->GetBufferPointer(), pixelShaderBuffer->GetBufferSize(), NULL, &m_pixelShader);
if (FAILED(result))
{
logger.Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create the pixel shader from the buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -194,7 +194,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
vertexShaderBuffer->GetBufferSize(), &m_layout);
if (FAILED(result))
{
logger.Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create the vertex input layout", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -217,7 +217,7 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
result = device->CreateBuffer(&matrixBufferDesc, NULL, &m_matrixBuffer);
if (FAILED(result))
{
logger.Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create the constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -240,18 +240,18 @@ bool MultiTextureShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd,
result = device->CreateSamplerState(&samplerDesc, &m_sampleState);
if (FAILED(result))
{
logger.Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create the texture sampler state", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
logger.Log("Shader initialized", __FILE__, __LINE__);
Logger::Get().Log("Shader initialized", __FILE__, __LINE__);
return true;
}
void MultiTextureShaderClass::ShutdownShader()
{
logger.Log("Shutting down the shader", __FILE__, __LINE__);
Logger::Get().Log("Shutting down the shader", __FILE__, __LINE__);
// Release the sampler state.
if (m_sampleState)
@@ -288,7 +288,7 @@ void MultiTextureShaderClass::ShutdownShader()
m_vertexShader = 0;
}
logger.Log("Shader shut down", __FILE__, __LINE__);
Logger::Get().Log("Shader shut down", __FILE__, __LINE__);
return;
}
@@ -346,7 +346,7 @@ bool MultiTextureShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceCon
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
logger.Log("Failed to lock the constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to lock the constant buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}