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

@@ -24,7 +24,7 @@ NormalMapShaderClass::~NormalMapShaderClass()
bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
{
logger.Log("Initializing normal map shader", __FILE__, __LINE__);
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__);
bool result;
wchar_t vsFilename[128];
@@ -35,7 +35,7 @@ bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
error = wcscpy_s(vsFilename, 128, L"normalmap.vs");
if (error != 0)
{
logger.Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__);
Logger::Get().Log("Failed to set the filename of the vertex shader", __FILE__, __LINE__);
return false;
}
@@ -43,7 +43,7 @@ bool NormalMapShaderClass::Initialize(ID3D11Device* device, HWND hwnd)
error = wcscpy_s(psFilename, 128, L"normalmap.ps");
if (error != 0)
{
logger.Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__);
Logger::Get().Log("Failed to set the filename of the pixel shader", __FILE__, __LINE__);
return false;
}
@@ -51,7 +51,7 @@ bool NormalMapShaderClass::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::Get().Log("Failed to initialize the vertex and pixel shaders", __FILE__, __LINE__);
return false;
}
@@ -77,7 +77,7 @@ bool NormalMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexC
result = SetShaderParameters(deviceContext, worldMatrix, viewMatrix, projectionMatrix, texture1, texture2, lightDirection, diffuseColor);
if (!result)
{
logger.Log("Failed to set the shader parameters that will be used for rendering", __FILE__, __LINE__);
Logger::Get().Log("Failed to set the shader parameters that will be used for rendering", __FILE__, __LINE__);
return false;
}
@@ -90,7 +90,7 @@ bool NormalMapShaderClass::Render(ID3D11DeviceContext* deviceContext, int indexC
bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCHAR* vsFilename, WCHAR* psFilename)
{
logger.Log("Initializing normal map shader", __FILE__, __LINE__);
Logger::Get().Log("Initializing normal map shader", __FILE__, __LINE__);
HRESULT result;
ID3D10Blob* errorMessage;
@@ -121,7 +121,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// 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;
@@ -140,7 +140,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
// 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;
@@ -150,7 +150,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
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;
}
@@ -158,7 +158,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
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;
}
@@ -211,7 +211,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
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;
}
@@ -234,7 +234,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
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;
}
@@ -257,7 +257,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
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;
}
@@ -273,11 +273,11 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
result = device->CreateBuffer(&lightBufferDesc, NULL, &m_lightBuffer);
if (FAILED(result))
{
logger.Log("Failed to create the light constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to create the light constant buffer pointer", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
logger.Log("Successfully initialized normal map shader", __FILE__, __LINE__);
Logger::Get().Log("Successfully initialized normal map shader", __FILE__, __LINE__);
return true;
}
@@ -285,7 +285,7 @@ bool NormalMapShaderClass::InitializeShader(ID3D11Device* device, HWND hwnd, WCH
void NormalMapShaderClass::ShutdownShader()
{
logger.Log("Shutting down normal map shader", __FILE__, __LINE__);
Logger::Get().Log("Shutting down normal map shader", __FILE__, __LINE__);
// Release the light constant buffer.
if (m_lightBuffer)
@@ -329,7 +329,7 @@ void NormalMapShaderClass::ShutdownShader()
m_vertexShader = 0;
}
logger.Log("Successfully shut down normal map shader", __FILE__, __LINE__);
Logger::Get().Log("Successfully shut down normal map shader", __FILE__, __LINE__);
return;
}
@@ -390,7 +390,7 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
result = deviceContext->Map(m_matrixBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
logger.Log("Failed to lock the constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to lock the constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
@@ -419,7 +419,7 @@ bool NormalMapShaderClass::SetShaderParameters(ID3D11DeviceContext* deviceContex
result = deviceContext->Map(m_lightBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
if (FAILED(result))
{
logger.Log("Failed to lock the light constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
Logger::Get().Log("Failed to lock the light constant buffer so it can be written to", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}