From 8f203971305e81bc95aa3abbc336057e7bccbdb0 Mon Sep 17 00:00:00 2001 From: CatChow0 Date: Mon, 30 Sep 2024 15:29:49 +0200 Subject: [PATCH] sus --- .vscode/launch.json | 24 +++++++++ .vscode/settings.json | 59 +++++++++++++++++++++++ enginecustom/applicationclass.cpp | 36 +++++++++++--- enginecustom/enginecustom.vcxproj | 20 ++++---- enginecustom/enginecustom.vcxproj.filters | 20 ++++---- enginecustom/imgui.ini | 4 +- 6 files changed, 133 insertions(+), 30 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..d0898ec --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,24 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "C/C++ Runner: Debug Session", + "type": "cppdbg", + "request": "launch", + "args": [], + "stopAtEntry": false, + "externalConsole": true, + "cwd": "c:/Users/arivas/Documents/GitHub/khaotic-engine-Reborn/enginecustom", + "program": "c:/Users/arivas/Documents/GitHub/khaotic-engine-Reborn/enginecustom/build/Debug/outDebug", + "MIMode": "gdb", + "miDebuggerPath": "gdb", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bb879da --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,59 @@ +{ + "C_Cpp_Runner.cCompilerPath": "gcc", + "C_Cpp_Runner.cppCompilerPath": "g++", + "C_Cpp_Runner.debuggerPath": "gdb", + "C_Cpp_Runner.cStandard": "", + "C_Cpp_Runner.cppStandard": "", + "C_Cpp_Runner.msvcBatchPath": "C:/Program Files/Microsoft Visual Studio/VR_NR/Community/VC/Auxiliary/Build/vcvarsall.bat", + "C_Cpp_Runner.useMsvc": false, + "C_Cpp_Runner.warnings": [ + "-Wall", + "-Wextra", + "-Wpedantic", + "-Wshadow", + "-Wformat=2", + "-Wcast-align", + "-Wconversion", + "-Wsign-conversion", + "-Wnull-dereference" + ], + "C_Cpp_Runner.msvcWarnings": [ + "/W4", + "/permissive-", + "/w14242", + "/w14287", + "/w14296", + "/w14311", + "/w14826", + "/w44062", + "/w44242", + "/w14905", + "/w14906", + "/w14263", + "/w44265", + "/w14928" + ], + "C_Cpp_Runner.enableWarnings": true, + "C_Cpp_Runner.warningsAsError": false, + "C_Cpp_Runner.compilerArgs": [], + "C_Cpp_Runner.linkerArgs": [], + "C_Cpp_Runner.includePaths": [], + "C_Cpp_Runner.includeSearch": [ + "*", + "**/*" + ], + "C_Cpp_Runner.excludeSearch": [ + "**/build", + "**/build/**", + "**/.*", + "**/.*/**", + "**/.vscode", + "**/.vscode/**" + ], + "C_Cpp_Runner.useAddressSanitizer": false, + "C_Cpp_Runner.useUndefinedSanitizer": false, + "C_Cpp_Runner.useLeakSanitizer": false, + "C_Cpp_Runner.showCompilationTime": false, + "C_Cpp_Runner.useLinkTimeOptimization": false, + "C_Cpp_Runner.msvcSecureNoWarnings": false +} \ No newline at end of file diff --git a/enginecustom/applicationclass.cpp b/enginecustom/applicationclass.cpp index bd12f77..7fe8233 100644 --- a/enginecustom/applicationclass.cpp +++ b/enginecustom/applicationclass.cpp @@ -1127,7 +1127,17 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t object->Render(m_Direct3D->GetDeviceContext()); if (!m_enableCelShading) { - result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, object->GetTexture(0), + + // check if m_object is null or not + if (object == nullptr) { + + Logger::Get().Log("Object is null", __FILE__, __LINE__, Logger::LogLevel::Error); + return false; + } + + ID3D11ShaderResourceView* ObjTexture = object->GetTexture(0); + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), object->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, + ObjTexture, diffuseColor, lightPosition, ambientColor); if (!result) @@ -1164,13 +1174,12 @@ bool ApplicationClass::Render(float rotation, float x, float y, float z, float t if (!m_enableCelShading) { if (chunk->GetTexture(0) == nullptr) { + Logger::Get().Log("Could not render the terrain model using the light shader, texture is null", __FILE__, __LINE__, Logger::LogLevel::Error); return false; } - - result = m_ShaderManager->RenderSpecMapShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, - chunk->GetTexture(0), chunk->GetTexture(1), chunk->GetTexture(2), m_Lights[0]->GetDirection(), m_Lights[0]->GetDiffuseColor(), - m_Camera->GetPosition(), m_Lights[0]->GetSpecularColor(), m_Lights[0]->GetSpecularPower()); + result = m_ShaderManager->RenderlightShader(m_Direct3D->GetDeviceContext(), chunk->GetIndexCount(), worldMatrix, viewMatrix, projectionMatrix, chunk->GetTexture(0), diffuseColor, lightPosition, ambientColor ); + if (!result) { Logger::Get().Log("Could not render the terrain model using the light shader", __FILE__, __LINE__, Logger::LogLevel::Error); @@ -1661,7 +1670,7 @@ void ApplicationClass::AddKobject(WCHAR* filepath) wcstombs_s(&convertedChars, modelFilename, sizeof(modelFilename), filepath, _TRUNCATE); - /// Liste des fichiers de texture + // Liste des fichiers de texture std::vector kobjTexture = { L"assets/Texture/marble01.png" }; @@ -1674,8 +1683,19 @@ void ApplicationClass::AddKobject(WCHAR* filepath) result = DirectX::CreateWICTextureFromFile(m_Direct3D->GetDevice(), m_Direct3D->GetDeviceContext(), 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); - return; + // Utiliser _com_error pour obtenir des informations détaillées sur l'erreur + _com_error err(result); + LPCTSTR errMsg = err.ErrorMessage(); + + //convertie errMessage en std::wstring + std::wstring ws(errMsg); + std::string str(ws.begin(), ws.end()); + + Logger::Get().Log("Failed to load texture: " + std::string(textureFilename.begin(), textureFilename.end()) + + "\nError: " + std::to_string(result) + + "\nDescription: " + str, + __FILE__, __LINE__, Logger::LogLevel::Error); + return; // Assurez-vous de retourner false ou de gérer l'erreur de manière appropriée } textures.push_back(texture); } diff --git a/enginecustom/enginecustom.vcxproj b/enginecustom/enginecustom.vcxproj index 0b0857a..4e309a8 100644 --- a/enginecustom/enginecustom.vcxproj +++ b/enginecustom/enginecustom.vcxproj @@ -22,11 +22,6 @@ - - - - - @@ -44,6 +39,11 @@ + + + + + @@ -75,11 +75,6 @@ - - - - - @@ -98,6 +93,11 @@ + + + + + diff --git a/enginecustom/enginecustom.vcxproj.filters b/enginecustom/enginecustom.vcxproj.filters index 0ca0635..74e7821 100644 --- a/enginecustom/enginecustom.vcxproj.filters +++ b/enginecustom/enginecustom.vcxproj.filters @@ -192,19 +192,19 @@ Fichiers sources - + Fichiers sources\DirectX Tool Kit - + Fichiers sources\DirectX Tool Kit - + Fichiers sources\DirectX Tool Kit - + Fichiers sources\DirectX Tool Kit - + Fichiers sources\DirectX Tool Kit @@ -356,19 +356,19 @@ Fichiers d%27en-tête - + Fichiers d%27en-tête\DirectX Tool Kit - + Fichiers d%27en-tête\DirectX Tool Kit - + Fichiers d%27en-tête\DirectX Tool Kit - + Fichiers d%27en-tête\DirectX Tool Kit - + Fichiers d%27en-tête\DirectX Tool Kit diff --git a/enginecustom/imgui.ini b/enginecustom/imgui.ini index a954d29..b495d1f 100644 --- a/enginecustom/imgui.ini +++ b/enginecustom/imgui.ini @@ -3,7 +3,7 @@ Pos=60,60 Size=400,400 [Window][Khaotic Engine] -Pos=1128,39 +Pos=1120,51 Size=392,273 [Window][Objects] @@ -19,6 +19,6 @@ Pos=1551,17 Size=358,535 [Window][Shader Manager] -Pos=34,253 +Pos=30,255 Size=172,284