Patch - Refactors logging and adds macro header - V14.5.29
This commit refactors the logging system by replacing direct calls to the Logger class with macros. This improves code readability and maintainability by providing a consistent and concise way to log messages throughout the engine. The 'macro.h' header file is added and included in multiple system classes to define these logging macros, centralizing logging functionality. Additionally, error handling is improved in imguiManager::IncrementBuildVersionInConfig by logging specific errors during file operations.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
#include <dinput.h>
|
||||
#include "macro.h"
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Class name: input_class
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include <directxmath.h>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// INCLUDES //
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
#include "macro.h"
|
||||
|
||||
#include <d3d11.h>
|
||||
#include <directxmath.h>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "Logger.h"
|
||||
#include <d3d11.h>
|
||||
#include <directxmath.h>
|
||||
#include "macro.h"
|
||||
using namespace DirectX;
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <filesystem>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "macro.h"
|
||||
|
||||
#include "ecs/entity.h"
|
||||
#include "ecs/ComponentFactory.h"
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "Logger.h"
|
||||
#include <d3d11.h>
|
||||
#include <stdio.h>
|
||||
#include "macro.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//////////////
|
||||
#include "Logger.h"
|
||||
#include <windows.h>
|
||||
#include "macro.h"
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "system_class.h"
|
||||
|
||||
#include "macro.h"
|
||||
|
||||
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline, int iCmdshow)
|
||||
{
|
||||
@@ -23,7 +23,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR pScmdline,
|
||||
result = System->initialize();
|
||||
if (result)
|
||||
{
|
||||
Logger::Get().Log("System initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("System initialized");
|
||||
System->send_path(path,WFolder);
|
||||
System->run();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ void Skybox::Initialize(d_3d_class* d3dClassRef)
|
||||
|
||||
object* Skybox::ConstructSkybox(application_class* app)
|
||||
{
|
||||
Logger::Get().Log("Construct skybox", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INFO("Construct skybox");
|
||||
|
||||
char modelFilename[128];
|
||||
strcpy_s(modelFilename, "assets/Model/OBJ/skysphere.obj");
|
||||
@@ -43,7 +43,7 @@ object* Skybox::ConstructSkybox(application_class* app)
|
||||
HRESULT result = DirectX::CreateWICTextureFromFile(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), textureFilename.c_str(), nullptr, &texture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()));
|
||||
return nullptr;
|
||||
}
|
||||
SkyboxTextures.diffuse.push_back(texture);
|
||||
@@ -55,7 +55,7 @@ object* Skybox::ConstructSkybox(application_class* app)
|
||||
HRESULT result = m_Skybox->Initialize(m_d3dClassRef->get_device(), m_d3dClassRef->get_device_context(), modelFilename, SkyboxTextures);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Could not initialize the skybox model object", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Could not initialize the skybox model object");
|
||||
delete m_Skybox;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
|
||||
line = "VER=" + std::to_string(BUILD_VERSION_VER);
|
||||
}
|
||||
} catch (...) {
|
||||
LOG_ERROR("Error converting VER to integer");
|
||||
return false; // erreur conversion
|
||||
}
|
||||
}
|
||||
@@ -82,7 +83,11 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
|
||||
|
||||
// Réécrire tout le fichier
|
||||
std::ofstream file_out(filepath, std::ios::trunc);
|
||||
if (!file_out) return false;
|
||||
if (!file_out)
|
||||
{
|
||||
LOG_ERROR("Error writing to file");
|
||||
return false;
|
||||
}
|
||||
|
||||
for (const auto& l : lines) {
|
||||
file_out << l << "\n";
|
||||
@@ -93,7 +98,7 @@ bool imguiManager::IncrementBuildVersionInConfig(const std::string& filepath) {
|
||||
|
||||
bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceContext* deviceContext)
|
||||
{
|
||||
Logger::Get().Log("Initializing imgui", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing imgui");
|
||||
|
||||
m_device = device;
|
||||
m_deviceContext = deviceContext;
|
||||
@@ -218,7 +223,7 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
// initialize the scene manager
|
||||
scene_manager_ = new scene_manager;
|
||||
if (!scene_manager_->initialize(app_.get())) {
|
||||
Logger::Get().Log("Failed to initialize scene manager", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to initialize scene manager");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -252,35 +257,35 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
|
||||
std::string configPath = "config.txt"; // ou chemin complet
|
||||
configPath = exeDir + BUILD_VERSION_TYPE + "\\" + configPath;
|
||||
if (!IncrementBuildVersionInConfig(configPath)) {
|
||||
Logger::Get().Log("Failed to increment build version in config.txt", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("Failed to increment build version in config.txt");
|
||||
}
|
||||
|
||||
// update the build version text in the inverse build type folder
|
||||
configPath = "config.txt";
|
||||
configPath = exeDir + BUILD_VERSION_INVERSE + "\\" + configPath;
|
||||
Logger::Get().Log("Inverse build type config path: " + configPath, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Inverse build type config path: " + configPath);
|
||||
if (!IncrementBuildVersionInConfig(configPath)) {
|
||||
Logger::Get().Log("Failed to increment build version in config.txt of inverse build type", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("Failed to increment build version in config.txt of inverse build type");
|
||||
}
|
||||
|
||||
// get the sky entity shared ptr from the application
|
||||
sky_entity_shared_ptr_ = app_->get_sky_entity_shared_ptr();
|
||||
if (!sky_entity_shared_ptr_) {
|
||||
Logger::Get().Log("Sky entity shared ptr is null", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("Sky entity shared ptr is null");
|
||||
}
|
||||
|
||||
Logger::Get().Log("imgui initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("imgui initialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void imguiManager::Shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down imgui", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down imgui");
|
||||
ImGui_ImplDX11_Shutdown();
|
||||
ImGui_ImplWin32_Shutdown();
|
||||
ImGui::DestroyContext();
|
||||
Logger::Get().Log("imgui shutdown", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("imgui shutdown");
|
||||
}
|
||||
|
||||
void imguiManager::Render()
|
||||
|
||||
@@ -21,7 +21,7 @@ input_class::~input_class()
|
||||
|
||||
bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, int screenHeight)
|
||||
{
|
||||
Logger::Get().Log("Initializing input class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing input class");
|
||||
|
||||
HRESULT result;
|
||||
int i;
|
||||
@@ -44,7 +44,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = DirectInput8Create(hinstance, DIRECTINPUT_VERSION, IID_IDirectInput8, (void**)&m_directInput, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create direct input interface", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create direct input interface");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_directInput->CreateDevice(GUID_SysKeyboard, &m_keyboard, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create direct input interface for the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create direct input interface for the keyboard");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_keyboard->SetDataFormat(&c_dfDIKeyboard);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set data format for the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to set data format for the keyboard");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_keyboard->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set cooperative level of the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to set cooperative level of the keyboard");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_keyboard->Acquire();
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to acquire the keyboard", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to acquire the keyboard");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_directInput->CreateDevice(GUID_SysMouse, &m_mouse, NULL);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create direct input interface for the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create direct input interface for the mouse");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_mouse->SetDataFormat(&c_dfDIMouse);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set data format for the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to set data format for the mouse");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_mouse->SetCooperativeLevel(hwnd, DISCL_FOREGROUND | DISCL_NONEXCLUSIVE);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to set cooperative level of the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to set cooperative level of the mouse");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -108,11 +108,11 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
result = m_mouse->Acquire();
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to acquire the mouse", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to acquire the mouse");
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Input class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Input class initialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -121,7 +121,7 @@ bool input_class::Initialize(HINSTANCE hinstance, HWND hwnd, int screenWidth, in
|
||||
void input_class::KeyDown(unsigned int input)
|
||||
{
|
||||
// If a key is pressed then save that state in the key array.
|
||||
Logger::Get().Log("Key down: " + std::to_string(input), __FILE__, __LINE__, Logger::LogLevel::Input);
|
||||
LOG("Key down: " + std::to_string(input), Logger::LogLevel::Input);
|
||||
m_keys[input] = true;
|
||||
return;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ bool input_class::IsKeyDown(unsigned int key) const
|
||||
|
||||
void input_class::Shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down input class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down input class");
|
||||
|
||||
// Release the mouse.
|
||||
if (m_mouse)
|
||||
@@ -168,7 +168,7 @@ void input_class::Shutdown()
|
||||
m_directInput = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Input class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Input class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -177,12 +177,11 @@ bool input_class::Frame()
|
||||
{
|
||||
bool result;
|
||||
|
||||
|
||||
// Read the current state of the keyboard.
|
||||
result = ReadKeyboard();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to read keyboard state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to read keyboard state");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -190,7 +189,7 @@ bool input_class::Frame()
|
||||
result = ReadMouse();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to read mouse state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to read mouse state");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -216,7 +215,7 @@ bool input_class::ReadKeyboard()
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to get keyboard device state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to get keyboard device state");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -240,7 +239,7 @@ bool input_class::ReadMouse()
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Failed to get mouse device state", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to get mouse device state");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
// Load in the model data.
|
||||
result = LoadModel(modelFilename);
|
||||
if (!result) {
|
||||
Logger::Get().Log("Failed to load model data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to load model data");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ bool model_class::Initialize(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
// Initialize the vertex and index buffers.
|
||||
result = InitializeBuffers(device);
|
||||
if (!result) {
|
||||
Logger::Get().Log("Failed to initialize buffers", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to initialize buffers");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&vertexBufferDesc, &vertexData, &m_vertexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create vertex buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create vertex buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ bool model_class::InitializeBuffers(ID3D11Device* device)
|
||||
result = device->CreateBuffer(&indexBufferDesc, &indexData, &m_indexBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create index buffer", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create index buffer");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -227,7 +227,7 @@ bool model_class::LoadModel(char* filename)
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Unsupported file format", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Unsupported file format");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -238,7 +238,7 @@ bool model_class::LoadObjModel(char* filename)
|
||||
std::ifstream fin(filename, std::ios::in | std::ios::binary);
|
||||
if (!fin)
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec d'ouverture du fichier mod<6F>le", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec d'ouverture du fichier mod<6F>le");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ bool model_class::LoadTxtModel(char* filename)
|
||||
// If it could not open the file then exit.
|
||||
if (fin.fail())
|
||||
{
|
||||
Logger::Get().Log("Failed to open model file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to open model file");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -535,7 +535,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture diffuse: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
return false;
|
||||
}
|
||||
textureContainer.diffuse.push_back(texture);
|
||||
@@ -548,7 +548,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture normale: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
return false;
|
||||
}
|
||||
textureContainer.normal.push_back(texture);
|
||||
@@ -561,7 +561,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture sp<73>culaire: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture sp<73>culaire: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
return false;
|
||||
}
|
||||
textureContainer.specular.push_back(texture);
|
||||
@@ -574,7 +574,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
hResult = DirectX::CreateWICTextureFromFile(device, deviceContext, texturePath.c_str(), nullptr, &texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("<EFBFBD>chec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec du chargement de la texture alpha: " + std::string(texturePath.begin(), texturePath.end()));
|
||||
return false;
|
||||
}
|
||||
textureContainer.alpha.push_back(texture);
|
||||
@@ -584,7 +584,7 @@ bool model_class::PreloadTextures(ID3D11Device* device, ID3D11DeviceContext* dev
|
||||
}
|
||||
|
||||
bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type, int index) {
|
||||
Logger::Get().Log("Changing texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Changing texture");
|
||||
|
||||
HRESULT result;
|
||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||
@@ -592,7 +592,7 @@ bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
// Charger la nouvelle texture
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||
if (FAILED(result)) {
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to load texture: " + std::string(filename.begin(), filename.end()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -640,12 +640,12 @@ bool model_class::ChangeTexture(ID3D11Device* device, ID3D11DeviceContext* devic
|
||||
break;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture changed successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Texture changed successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceContext, std::wstring filename, TextureType type) {
|
||||
Logger::Get().Log("Adding texture", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Adding texture");
|
||||
|
||||
HRESULT result;
|
||||
ID3D11ShaderResourceView* newTexture = nullptr;
|
||||
@@ -653,7 +653,7 @@ bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
// Charger la nouvelle texture
|
||||
result = DirectX::CreateWICTextureFromFile(device, deviceContext, filename.c_str(), nullptr, &newTexture);
|
||||
if (FAILED(result)) {
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(filename.begin(), filename.end()), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to load texture: " + std::string(filename.begin(), filename.end()));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -677,13 +677,13 @@ bool model_class::AddTexture(ID3D11Device* device, ID3D11DeviceContext* deviceCo
|
||||
break;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture added successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Texture added successfully");
|
||||
return true;
|
||||
}
|
||||
|
||||
bool model_class::AddTexture(ID3D11ShaderResourceView* texture, TextureType type) {
|
||||
if (!texture) {
|
||||
Logger::Get().Log("Cannot add null texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Cannot add null texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -421,10 +421,9 @@ bool object::LoadTexturesFromPath(std::vector<std::wstring>& texturePaths, Textu
|
||||
std::wstring ws(errMsg);
|
||||
std::string str(ws.begin(), ws.end());
|
||||
|
||||
Logger::Get().Log("Failed to load texture: " + std::string(texturePath.begin(), texturePath.end()) +
|
||||
LOG_ERROR("Failed to load texture: " + std::string(texturePath.begin(), texturePath.end()) +
|
||||
"\nError: " + std::to_string(result) +
|
||||
"\nDescription: " + str,
|
||||
__FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
"\nDescription: " + str);
|
||||
return false; // Assurez-vous de retourner false ou de g<>rer l'erreur de mani<6E>re appropri<72>e
|
||||
}
|
||||
texturesContainer.AssignTexture(texturesContainer, texture,texturePath , i);
|
||||
|
||||
@@ -21,7 +21,7 @@ render_texture_class::~render_texture_class()
|
||||
|
||||
bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, int textureHeight, float screenDepth, float screenNear, int format)
|
||||
{
|
||||
Logger::Get().Log("Initializing render_texture_class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing render_texture_class");
|
||||
|
||||
D3D11_TEXTURE2D_DESC textureDesc;
|
||||
HRESULT result;
|
||||
@@ -70,7 +70,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateTexture2D(&textureDesc, NULL, &m_renderTargetTexture);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create render target texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create render target texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateRenderTargetView(m_renderTargetTexture, &renderTargetViewDesc, &m_renderTargetView);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create render target view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create render target view");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateShaderResourceView(m_renderTargetTexture, &shaderResourceViewDesc, &m_shaderResourceView);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create shader resource view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create shader resource view");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateTexture2D(&depthBufferDesc, NULL, &m_depthStencilBuffer);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth buffer texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create depth buffer texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
result = device->CreateDepthStencilView(m_depthStencilBuffer, &depthStencilViewDesc, &m_depthStencilView);
|
||||
if (FAILED(result))
|
||||
{
|
||||
Logger::Get().Log("Failed to create depth stencil view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to create depth stencil view");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -155,14 +155,14 @@ bool render_texture_class::Initialize(ID3D11Device * device, int textureWidth, i
|
||||
// Create an orthographic projection matrix for 2D rendering.
|
||||
m_orthoMatrix = XMMatrixOrthographicLH((float)textureWidth, (float)textureHeight, screenNear, screenDepth);
|
||||
|
||||
Logger::Get().Log("render_texture_class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("render_texture_class initialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void render_texture_class::Shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down render_texture_class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down render_texture_class");
|
||||
|
||||
if (m_depthStencilView)
|
||||
{
|
||||
@@ -194,7 +194,7 @@ void render_texture_class::Shutdown()
|
||||
m_renderTargetTexture = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("render_texture_class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("render_texture_class shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -13,20 +13,20 @@ scene_manager::~scene_manager()
|
||||
bool scene_manager::initialize(application_class* app)
|
||||
{
|
||||
if (!app) {
|
||||
Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Application pointer is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
app_ = app;
|
||||
|
||||
if (app_ == nullptr) {
|
||||
Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Application pointer is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
direct_3d_ = app_->get_direct_3d();
|
||||
if (!direct_3d_) {
|
||||
Logger::Get().Log("Direct3D pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Direct3D pointer is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -40,8 +40,7 @@ bool scene_manager::shutdown()
|
||||
}
|
||||
|
||||
bool scene_manager::save_scene_as() {
|
||||
|
||||
Logger::Get().Log("Saving scene as...", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Saving scene as...");
|
||||
|
||||
OPENFILENAME ofn;
|
||||
wchar_t szFile[260] = { 0 };
|
||||
@@ -68,8 +67,7 @@ bool scene_manager::save_scene_as() {
|
||||
|
||||
// Sauvegarder la sc<73>ne avec le nouveau chemin
|
||||
save_scene();
|
||||
|
||||
Logger::Get().Log("Scene saved as: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Scene saved as: " + scene_path_);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -94,16 +92,16 @@ bool scene_manager::load_scene() {
|
||||
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
|
||||
ofn.lpstrDefExt = L"ker";
|
||||
if (GetOpenFileName(&ofn) != TRUE) {
|
||||
Logger::Get().Log("Load scene canceled or failed", __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("Load scene canceled or failed");
|
||||
return false; // L'utilisateur a annul<75> la bo<62>te de dialogue
|
||||
}
|
||||
std::filesystem::path filepath = ofn.lpstrFile;
|
||||
scene_path_ = convert_w_string_to_string(filepath.wstring());
|
||||
if (scene_path_.empty()) {
|
||||
Logger::Get().Log("Invalid scene path", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Invalid scene path");
|
||||
return false;
|
||||
}
|
||||
Logger::Get().Log("Loading scene from: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Loading scene from: " + scene_path_);
|
||||
|
||||
|
||||
w_folder_ = app_->get_w_folder();
|
||||
@@ -115,7 +113,7 @@ bool scene_manager::load_scene() {
|
||||
|
||||
std::ifstream inFile(scene_path_);
|
||||
if (!inFile.is_open()) {
|
||||
Logger::Get().Log("<EFBFBD>chec de l'ouverture du fichier", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec de l'ouverture du fichier");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -155,18 +153,18 @@ bool scene_manager::load_scene() {
|
||||
auto modelPathComponent = currentEntity->GetComponent<ecs::ModelPathComponent>();
|
||||
|
||||
if (!modelPathComponent) {
|
||||
Logger::Get().Log("ModelPathComponent missing for entity ID: " + std::to_string(currentEntity->GetID()), __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("ModelPathComponent missing for entity ID: " + std::to_string(currentEntity->GetID()));
|
||||
}
|
||||
|
||||
if (!modelPathComponent || modelPathComponent->GetPath().empty()) {
|
||||
Logger::Get().Log("No model path specified for entity ID: " + std::to_string(currentEntity->GetID()), __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("No model path specified for entity ID: " + std::to_string(currentEntity->GetID()));
|
||||
}
|
||||
|
||||
auto renderComponent = currentEntity->GetComponent<ecs::RenderComponent>();
|
||||
|
||||
if (!renderComponent)
|
||||
{
|
||||
Logger::Get().Log("RenderComponent missing for entity ID: " + std::to_string(currentEntity->GetID()), __FILE__, __LINE__, Logger::LogLevel::Warning);
|
||||
LOG_WARNING("RenderComponent missing for entity ID: " + std::to_string(currentEntity->GetID()));
|
||||
}
|
||||
|
||||
currentTextures = renderComponent->GetTextureContainerBuffer();
|
||||
@@ -185,7 +183,7 @@ bool scene_manager::load_scene() {
|
||||
|
||||
// Pr<50>charger les textures
|
||||
if (!model->PreloadTextures(direct_3d_->get_device(), direct_3d_->get_device_context(), currentTextures)) {
|
||||
Logger::Get().Log("<EFBFBD>chec du pr<70>chargement des textures", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec du pr<70>chargement des textures");
|
||||
}
|
||||
|
||||
char modelFilename[256];
|
||||
@@ -193,7 +191,7 @@ bool scene_manager::load_scene() {
|
||||
wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), modelPath.c_str(), _TRUNCATE);
|
||||
|
||||
if (!model->Initialize(direct_3d_->get_device(), direct_3d_->get_device_context(), modelFilename, currentTextures)) {
|
||||
Logger::Get().Log("<EFBFBD>chec d'initialisation du mod<6F>le", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec d'initialisation du mod<6F>le");
|
||||
} else {
|
||||
// Ajouter au cache
|
||||
modelCache[modelKey] = model;
|
||||
@@ -221,7 +219,7 @@ bool scene_manager::load_scene() {
|
||||
}
|
||||
}
|
||||
|
||||
Logger::Get().Log("Sc<EFBFBD>ne charg<72>e avec succ<63>s", __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Sc<EFBFBD>ne charg<72>e avec succ<63>s");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -232,10 +230,9 @@ bool scene_manager::save_scene() {
|
||||
if (scene_path_.empty() && !save_scene_as()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::ofstream outFile(scene_path_);
|
||||
if (!outFile.is_open()) {
|
||||
Logger::Get().Log("<EFBFBD>chec de l'ouverture du fichier", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("<EFBFBD>chec de l'ouverture du fichier");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -259,7 +256,7 @@ bool scene_manager::save_scene() {
|
||||
}
|
||||
|
||||
outFile.close();
|
||||
Logger::Get().Log("Sc<EFBFBD>ne sauvegard<72>e avec succ<63>s: " + scene_path_, __FILE__, __LINE__, Logger::LogLevel::Info);
|
||||
LOG_INFO("Sc<EFBFBD>ne sauvegard<72>e avec succ<63>s: " + scene_path_);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -298,4 +295,3 @@ std::string scene_manager::convert_w_string_to_string(const std::wstring& wstr)
|
||||
WideCharToMultiByte(CP_UTF8, 0, &wstr[0], (int)wstr.size(), &str[0], size_needed, NULL, NULL);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ stats::~stats()
|
||||
bool stats::initialize(application_class* app)
|
||||
{
|
||||
if (!app) {
|
||||
Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Application pointer is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -25,11 +25,11 @@ bool stats::initialize(application_class* app)
|
||||
fps_ = app_->get_fps();
|
||||
|
||||
if (!fps_) {
|
||||
Logger::Get().Log("FPS object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("FPS object is null");
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Stats initialized successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Stats initialized successfully");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -44,7 +44,7 @@ void stats::update_geometric_stats()
|
||||
|
||||
update_visible_count();
|
||||
|
||||
Logger::Get().Log("Statistics updated: " + std::to_string(*total_vertex_count_) + " vertices, " + std::to_string(*total_triangle_count_) + " triangles", __FILE__, __LINE__, Logger::LogLevel::Debug);
|
||||
LOG_DEBUG("Statistics updated: " + std::to_string(*total_vertex_count_) + " vertices, " + std::to_string(*total_triangle_count_) + " triangles");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ bool system_class::initialize()
|
||||
int screenHeight, screenWidth = 0;
|
||||
bool result;
|
||||
|
||||
Logger::Get().Log("Initializing system class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing system class");
|
||||
|
||||
try
|
||||
{
|
||||
@@ -40,7 +40,7 @@ bool system_class::initialize()
|
||||
result = input_->Initialize(hinstance_, hwnd_, screenWidth, screenHeight);
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to initialize input class", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to initialize input class");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -76,25 +76,25 @@ bool system_class::initialize()
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
Logger::Get().Log(std::string("Exception caught during initialization: ") + e.what(), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR(std::string("Exception caught during initialization: ") + e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
Logger::Get().Log("System class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("System class initialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void system_class::shutdown()
|
||||
{
|
||||
Logger::Get().Log("Shutting down system class", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down system class");
|
||||
|
||||
std::lock_guard<std::mutex> guard(render_mutex_);
|
||||
|
||||
// shutdown the window.
|
||||
shutdown_windows();
|
||||
|
||||
Logger::Get().Log("System class shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("System class shut down");
|
||||
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ void system_class::run()
|
||||
MSG msg;
|
||||
bool done, result;
|
||||
|
||||
Logger::Get().Log("Running the system", __FILE__, __LINE__);
|
||||
LOG_INFO("Running the system", __FILE__, __LINE__);
|
||||
|
||||
// initialize the message structure.
|
||||
ZeroMemory(&msg, sizeof(MSG));
|
||||
@@ -130,7 +130,7 @@ void system_class::run()
|
||||
// If windows signals to end the application then exit out.
|
||||
if (application_ != nullptr && application_->get_should_quit())
|
||||
{
|
||||
Logger::Get().Log("Received quit signal from application", __FILE__, __LINE__);
|
||||
LOG_INFO("Received quit signal from application", __FILE__, __LINE__);
|
||||
done = true;
|
||||
}
|
||||
else
|
||||
@@ -141,7 +141,7 @@ void system_class::run()
|
||||
result = frame();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to process frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to process frame");
|
||||
done = true;
|
||||
}
|
||||
fps_limiter_->set_target_fps(application_->get_target_fps());
|
||||
@@ -165,7 +165,7 @@ bool system_class::frame()
|
||||
result = input_->Frame();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to process input frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to process input frame");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ bool system_class::frame()
|
||||
result = application_->frame(input_.get());
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to process application frame", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to process application frame");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ bool system_class::frame()
|
||||
result = imgui_manager_->ImGuiWidgetRenderer();
|
||||
if (!result)
|
||||
{
|
||||
Logger::Get().Log("Failed to render ImGui widgets", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("Failed to render ImGui widgets");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ LRESULT CALLBACK system_class::message_handler(HWND hwnd, UINT umsg, WPARAM wpar
|
||||
}
|
||||
case WM_CLOSE:
|
||||
{
|
||||
Logger::Get().Log("WM_CLOSE message received", __FILE__, __LINE__);
|
||||
LOG_INFO("WM_CLOSE message received", __FILE__, __LINE__);
|
||||
application_->set_should_quit(true);
|
||||
return 0;
|
||||
}
|
||||
@@ -312,7 +312,7 @@ void system_class::initialize_windows(int& screenWidth, int& screenHeight)
|
||||
DEVMODE dmScreenSettings;
|
||||
int posX, posY;
|
||||
|
||||
Logger::Get().Log("Initializing windows", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing windows");
|
||||
// Get an external pointer to this object.
|
||||
application_handle = this;
|
||||
|
||||
@@ -392,7 +392,7 @@ void system_class::initialize_windows(int& screenWidth, int& screenHeight)
|
||||
|
||||
void system_class::shutdown_windows()
|
||||
{
|
||||
Logger::Get().Log("Shutting down the windows", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Shutting down the windows");
|
||||
// Show the mouse cursor.
|
||||
ShowCursor(true);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ texture_class::~texture_class()
|
||||
|
||||
bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * deviceContext, std::string filename)
|
||||
{
|
||||
Logger::Get().Log(("Iinitializing texture: %s", filename), __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initializing texture: " + filename);
|
||||
|
||||
bool result;
|
||||
D3D11_TEXTURE2D_DESC textureDesc;
|
||||
@@ -46,13 +46,13 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
|
||||
textureDesc.CPUAccessFlags = 0;
|
||||
textureDesc.MiscFlags = D3D11_RESOURCE_MISC_GENERATE_MIPS;
|
||||
|
||||
// Create the empty texture.
|
||||
hResult = device->CreateTexture2D(&textureDesc, NULL, &m_texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("Failed to create texture", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the empty texture.
|
||||
hResult = device->CreateTexture2D(&textureDesc, NULL, &m_texture);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
LOG_ERROR("Failed to create texture");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set the row pitch of the targa image data.
|
||||
rowPitch = (m_width * 4) * sizeof(unsigned char);
|
||||
@@ -64,13 +64,13 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
|
||||
srvDesc.Texture2D.MostDetailedMip = 0;
|
||||
srvDesc.Texture2D.MipLevels = -1;
|
||||
|
||||
// Create the shader resource view for the texture.
|
||||
hResult = device->CreateShaderResourceView(m_texture, &srvDesc, &m_textureView);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
Logger::Get().Log("Failed to create shader resource view", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Create the shader resource view for the texture.
|
||||
hResult = device->CreateShaderResourceView(m_texture, &srvDesc, &m_textureView);
|
||||
if (FAILED(hResult))
|
||||
{
|
||||
LOG_ERROR("Failed to create shader resource view");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Generate mipmaps for this texture.
|
||||
deviceContext->GenerateMips(m_textureView);
|
||||
@@ -79,21 +79,20 @@ bool texture_class::Initialize(ID3D11Device * device, ID3D11DeviceContext * devi
|
||||
delete[] m_targaData;
|
||||
m_targaData = 0;
|
||||
|
||||
Logger::Get().Log("Texture initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Texture initialized");
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void texture_class::Shutdown()
|
||||
{
|
||||
|
||||
Logger::Get().Log("Shutting down texture", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
// Release the texture view resource.
|
||||
if (m_textureView)
|
||||
{
|
||||
m_textureView->Release();
|
||||
m_textureView = 0;
|
||||
}
|
||||
LOG_SHUTDOWN("Shutting down texture");
|
||||
// Release the texture view resource.
|
||||
if (m_textureView)
|
||||
{
|
||||
m_textureView->Release();
|
||||
m_textureView = 0;
|
||||
}
|
||||
|
||||
// Release the texture.
|
||||
if (m_texture)
|
||||
@@ -109,7 +108,7 @@ void texture_class::Shutdown()
|
||||
m_targaData = 0;
|
||||
}
|
||||
|
||||
Logger::Get().Log("Texture shut down", __FILE__, __LINE__, Logger::LogLevel::Shutdown);
|
||||
LOG_SHUTDOWN("Texture shut down");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -121,42 +120,41 @@ ID3D11ShaderResourceView* texture_class::GetTexture()
|
||||
|
||||
bool texture_class::LoadTarga(std::string filename)
|
||||
{
|
||||
|
||||
Logger::Get().Log(("Loading targa file: %s", filename), __FILE__, __LINE__);
|
||||
int error, bpp, imageSize, index, i, j, k;
|
||||
FILE* filePtr;
|
||||
unsigned int count;
|
||||
TargaHeader targaFileHeader;
|
||||
unsigned char* targaImage;
|
||||
LOG_INFO("Loading targa file: " + filename);
|
||||
int error, bpp, imageSize, index, i, j, k;
|
||||
FILE* filePtr;
|
||||
unsigned int count;
|
||||
TargaHeader targaFileHeader;
|
||||
unsigned char* targaImage;
|
||||
|
||||
|
||||
// Open the targa file for reading in binary.
|
||||
error = fopen_s(&filePtr, filename.c_str(), "rb");
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to open targa file. Working directory: " + std::filesystem::current_path().string(), __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Open the targa file for reading in binary.
|
||||
error = fopen_s(&filePtr, filename.c_str(), "rb");
|
||||
if (error != 0)
|
||||
{
|
||||
LOG_ERROR("Failed to open targa file. Working directory: " + std::filesystem::current_path().string());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read in the file header.
|
||||
count = (unsigned int)fread(&targaFileHeader, sizeof(TargaHeader), 1, filePtr);
|
||||
if (count != 1)
|
||||
{
|
||||
Logger::Get().Log("Failed to read targa file header", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Read in the file header.
|
||||
count = (unsigned int)fread(&targaFileHeader, sizeof(TargaHeader), 1, filePtr);
|
||||
if (count != 1)
|
||||
{
|
||||
LOG_ERROR("Failed to read targa file header");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get the important information from the header.
|
||||
m_height = (int)targaFileHeader.height;
|
||||
m_width = (int)targaFileHeader.width;
|
||||
bpp = (int)targaFileHeader.bpp;
|
||||
|
||||
// Check that it is 32 bit and not 24 bit.
|
||||
if (bpp != 32 && bpp != 24)
|
||||
{
|
||||
Logger::Get().Log("Targa file is not 32 or 24 bit", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Check that it is 32 bit and not 24 bit.
|
||||
if (bpp != 32 && bpp != 24)
|
||||
{
|
||||
LOG_ERROR("Targa file is not 32 or 24 bit");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calculate the size of the 32 bit image data.
|
||||
imageSize = m_width * m_height * (bpp / 8);
|
||||
@@ -164,21 +162,21 @@ bool texture_class::LoadTarga(std::string filename)
|
||||
// Allocate memory for the targa image data.
|
||||
targaImage = new unsigned char[imageSize];
|
||||
|
||||
// Read in the targa image data.
|
||||
count = (unsigned int)fread(targaImage, 1, imageSize, filePtr);
|
||||
if (count != imageSize)
|
||||
{
|
||||
Logger::Get().Log("Failed to read targa image data", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Read in the targa image data.
|
||||
count = (unsigned int)fread(targaImage, 1, imageSize, filePtr);
|
||||
if (count != imageSize)
|
||||
{
|
||||
LOG_ERROR("Failed to read targa image data");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Close the file.
|
||||
error = fclose(filePtr);
|
||||
if (error != 0)
|
||||
{
|
||||
Logger::Get().Log("Failed to close targa file", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Close the file.
|
||||
error = fclose(filePtr);
|
||||
if (error != 0)
|
||||
{
|
||||
LOG_ERROR("Failed to close targa file");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allocate memory for the targa destination data.
|
||||
m_targaData = new unsigned char[imageSize];
|
||||
@@ -189,44 +187,44 @@ bool texture_class::LoadTarga(std::string filename)
|
||||
// Initialize the index into the targa image data.
|
||||
k = (m_width * m_height * (bpp / 8)) - (m_width * (bpp / 8));
|
||||
|
||||
// Now copy the targa image data into the targa destination array in the correct order since the targa format is stored upside down and also is not in RGBA order.
|
||||
for (j = 0; j < m_height; j++)
|
||||
{
|
||||
for (i = 0; i < m_width; i++)
|
||||
{
|
||||
if (index + 3 < imageSize) // Ajout de la v<>rification ici
|
||||
{
|
||||
m_targaData[index + 0] = targaImage[k + 2]; // Red.
|
||||
m_targaData[index + 1] = targaImage[k + 1]; // Green.
|
||||
m_targaData[index + 2] = targaImage[k + 0]; // Blue
|
||||
if (bpp == 32)
|
||||
{
|
||||
m_targaData[index + 3] = targaImage[k + 3]; // Alpha
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger::Get().Log("Index out of bounds", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
return false;
|
||||
}
|
||||
// Now copy the targa image data into the targa destination array in the correct order since the targa format is stored upside down and also is not in RGBA order.
|
||||
for (j = 0; j < m_height; j++)
|
||||
{
|
||||
for (i = 0; i < m_width; i++)
|
||||
{
|
||||
if (index + 3 < imageSize) // Ajout de la v<>rification ici
|
||||
{
|
||||
m_targaData[index + 0] = targaImage[k + 2]; // Red.
|
||||
m_targaData[index + 1] = targaImage[k + 1]; // Green.
|
||||
m_targaData[index + 2] = targaImage[k + 0]; // Blue
|
||||
if (bpp == 32)
|
||||
{
|
||||
m_targaData[index + 3] = targaImage[k + 3]; // Alpha
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Index out of bounds");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Increment the indexes into the targa data.
|
||||
k += (bpp / 8);
|
||||
index += (bpp / 8);
|
||||
}
|
||||
// Increment the indexes into the targa data.
|
||||
k += (bpp / 8);
|
||||
index += (bpp / 8);
|
||||
}
|
||||
|
||||
// Set the targa image data index back to the preceding row at the beginning of the column since its reading it in upside down.
|
||||
k -= (m_width * (bpp / 8) * 2);
|
||||
}
|
||||
// Set the targa image data index back to the preceding row at the beginning of the column since its reading it in upside down.
|
||||
k -= (m_width * (bpp / 8) * 2);
|
||||
}
|
||||
|
||||
|
||||
// Release the targa image data now that it was copied into the destination array.
|
||||
delete[] targaImage;
|
||||
targaImage = 0;
|
||||
// Release the targa image data now that it was copied into the destination array.
|
||||
delete[] targaImage;
|
||||
targaImage = 0;
|
||||
|
||||
Logger::Get().Log(("targa file %s loaded", filename), __FILE__, __LINE__);
|
||||
LOG_INFO("targa file " + filename + " loaded");
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ timer_class::~timer_class()
|
||||
|
||||
bool timer_class::Initialize()
|
||||
{
|
||||
Logger::Get().Log("Initilazing timer class", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Initilazing timer class");
|
||||
|
||||
INT64 frequency;
|
||||
|
||||
@@ -26,7 +26,7 @@ bool timer_class::Initialize()
|
||||
QueryPerformanceFrequency((LARGE_INTEGER*)&frequency);
|
||||
if (frequency == 0)
|
||||
{
|
||||
Logger::Get().Log("QueryPerformanceFrequency failed", __FILE__, __LINE__, Logger::LogLevel::Error);
|
||||
LOG_ERROR("QueryPerformanceFrequency failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ bool timer_class::Initialize()
|
||||
// Get the initial start time.
|
||||
QueryPerformanceCounter((LARGE_INTEGER*)&m_startTime);
|
||||
|
||||
Logger::Get().Log("Timer class initialized", __FILE__, __LINE__, Logger::LogLevel::Initialize);
|
||||
LOG_INIT("Timer class initialized");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user