diff --git a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
index 3eb8ebd..4b02d8d 100644
--- a/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
+++ b/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
@@ -5,15 +5,13 @@
-
-
-
-
+
+
@@ -27,6 +25,11 @@
+
+
+
+
+
@@ -52,26 +55,26 @@
- {
- "keyToString": {
- "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "C++ Project.enginecustom.executor": "Run",
- "C/C++ Project.KhaoticDemo.executor": "Run",
- "C/C++ Project.enginecustom.executor": "Run",
- "RunOnceActivity.ShowReadmeOnStart": "true",
- "RunOnceActivity.git.unshallow": "true",
- "SHARE_PROJECT_CONFIGURATION_FILES": "true",
- "git-widget-placeholder": "main",
- "ignore.virus.scanning.warn.message": "true",
- "node.js.detected.package.eslint": "true",
- "node.js.detected.package.tslint": "true",
- "node.js.selected.package.eslint": "(autodetect)",
- "node.js.selected.package.tslint": "(autodetect)",
- "nodejs_package_manager_path": "npm",
- "settings.editor.selected.configurable": "preferences.pluginManager",
- "vue.rearranger.settings.migration": "true"
+
+}]]>
@@ -210,7 +213,7 @@
-
+
diff --git a/enginecustom/src/inc/system/application_class.h b/enginecustom/src/inc/system/application_class.h
index 467ed8f..87501ab 100644
--- a/enginecustom/src/inc/system/application_class.h
+++ b/enginecustom/src/inc/system/application_class.h
@@ -160,6 +160,7 @@ public:
ID3D11ShaderResourceView* get_back_buffer_srv() const {return back_buffer_srv_;};
stats* get_stats() const { return stats_; };
+ fps_class* get_fps() const { return fps_; };
private:
bool render(float, float, float, float, float);
diff --git a/enginecustom/src/inc/system/imguiManager.h b/enginecustom/src/inc/system/imguiManager.h
index 2091327..ce16b41 100644
--- a/enginecustom/src/inc/system/imguiManager.h
+++ b/enginecustom/src/inc/system/imguiManager.h
@@ -108,6 +108,14 @@ private:
int current_fps_, min_fps_, max_fps_, draw_calls_, total_vertex_count_, total_triangle_count_, visible_triangle_count_;
float current_frame_time_, min_frame_time_, max_frame_time_ ;
+
+ // gpu information
+ char card_name_[128];
+ int video_memory_ = 0;
+
+ // cpu information
+ std::string cpu_name_;
+ std::string version_driver_;
};
#endif
\ No newline at end of file
diff --git a/enginecustom/src/inc/system/stats.h b/enginecustom/src/inc/system/stats.h
index 0ade979..5b7d9de 100644
--- a/enginecustom/src/inc/system/stats.h
+++ b/enginecustom/src/inc/system/stats.h
@@ -1,8 +1,12 @@
#pragma once
+#include
#include
#include "fps_class.h"
#include "object.h"
+#include // Pour __cpuid
+#include // Pour DXGI
+#pragma comment(lib, "dxgi.lib")
class stats
{
@@ -11,9 +15,9 @@ public:
stats();
~stats();
- bool initialize(fps_class* fps, application_class* app);
- void update_stats();
- void update();
+ bool initialize(application_class* app);
+ void update_geometric_stats();
+ void update_display_stats();
int get_total_vertex_count() const;
int get_total_triangle_count() const;
@@ -28,7 +32,13 @@ public:
void increment_draw_call_count() { drawcalls_++; };
void reset_draw_call_count() { drawcalls_ = 0; };
+ std::string get_cpu_name();
+ std::string get_gpu_driver_version(ID3D11Device* device);
+
private:
+ std::thread update_geometric_thread_;
+ std::thread update_display_thread_;
+
fps_class* fps_;
int drawcalls_;
application_class* app_;
diff --git a/enginecustom/src/src/system/application_class.cpp b/enginecustom/src/src/system/application_class.cpp
index dd7dd6f..6e2293e 100644
--- a/enginecustom/src/src/system/application_class.cpp
+++ b/enginecustom/src/src/system/application_class.cpp
@@ -492,7 +492,7 @@ bool application_class::initialize(int screenWidth, int screenHeight, HWND hwnd,
}
stats_ = new stats();
- if (!stats_->initialize(fps_, this))
+ if (!stats_->initialize(this))
{
Logger::Get().Log("Could not initialize the stats object", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
@@ -1529,6 +1529,8 @@ bool application_class::update_fps()
// Update the fps each frame.
fps_->Frame();
+ stats_->update_display_stats(); // Update the stats display with the latest information from fps class.
+
// Get the current fps.
fps = fps_->GetFps();
diff --git a/enginecustom/src/src/system/imguiManager.cpp b/enginecustom/src/src/system/imguiManager.cpp
index dfdafd8..1004aba 100644
--- a/enginecustom/src/src/system/imguiManager.cpp
+++ b/enginecustom/src/src/system/imguiManager.cpp
@@ -151,9 +151,10 @@ bool imguiManager::Initialize(HWND hwnd, ID3D11Device* device, ID3D11DeviceConte
fontConfig.OversampleV = 2; // Suréchantillonnage vertical
fontConfig.PixelSnapH = true; // Alignement sur la grille de pixels
fontConfig.RasterizerMultiply = 1.2f; // Légère augmentation de l'épaisseur
-
io->Fonts->AddFontDefault(&fontConfig);
+ io->Fonts->Build();
+
// OU charger une police personnalisée (décommenter si vous avez la police)
// io->Fonts->AddFontFromFileTTF("assets/fonts/roboto.ttf", 16.0f, &fontConfig);
@@ -1044,5 +1045,51 @@ void imguiManager::WidgetRenderStats()
ImGui::SameLine();
ImGui::Text("Triangles visibles: %d", visible_triangle_count_);
+ app_->get_direct_3d()->get_video_card_info(card_name_, video_memory_);
+ cpu_name_ = stats_->get_cpu_name();
+ version_driver_ = stats_->get_gpu_driver_version(app_->get_direct_3d()->get_device());
+
+ ImGui::Columns(3, "GPUCPURAMColumns", false);
+ ImGui::SetColumnWidth(0, ImGui::GetWindowWidth() * 0.33f);
+ ImGui::SetColumnWidth(1, ImGui::GetWindowWidth() * 0.33f);
+
+ // Premier collapsing header pour les informations GPU
+ if (ImGui::CollapsingHeader("Informations GPU"))
+ {
+ ImGui::Text("Carte graphique: %s", card_name_);
+ ImGui::Text("Memoire video: %d Mo", video_memory_);
+ ImGui::Text("Pilote: %s", version_driver_.c_str());
+ }
+
+ ImGui::NextColumn();
+
+ // Second collapsing header pour les informations CPU
+ if (ImGui::CollapsingHeader("Informations CPU"))
+ {
+ SYSTEM_INFO sysInfo;
+ GetSystemInfo(&sysInfo);
+ ImGui::Text("Processeur: %s", cpu_name_.c_str());
+ ImGui::Text("Nombre de coeurs: %u", sysInfo.dwNumberOfProcessors);
+ ImGui::Text("Architecture: %s", (sysInfo.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) ? "x64" : "x86");
+ ImGui::Text("Taille de la page: %u octets", sysInfo.dwPageSize);
+ ImGui::Text("Taille du cache: %u octets", sysInfo.dwAllocationGranularity);
+ ImGui::Text("Type de processeur: %u", sysInfo.wProcessorLevel);
+ ImGui::Text("Version du processeur: %u", sysInfo.wProcessorRevision);
+ }
+
+ ImGui::NextColumn();
+
+ if (ImGui::CollapsingHeader("Informations RAM"))
+ {
+ MEMORYSTATUSEX mem_info;
+ mem_info.dwLength = sizeof(MEMORYSTATUSEX);
+ GlobalMemoryStatusEx(&mem_info);
+ ImGui::Text("Memoire totale: %llu Mo", mem_info.ullTotalPhys / (1024 * 1024));
+ ImGui::Text("Memoire disponible: %llu Mo", mem_info.ullAvailPhys / (1024 * 1024));
+ ImGui::Text("Memoire utilisee: %llu Mo", (mem_info.ullTotalPhys - mem_info.ullAvailPhys) / (1024 * 1024));
+ }
+
+ ImGui::Columns(1);
+
ImGui::End();
}
\ No newline at end of file
diff --git a/enginecustom/src/src/system/stats.cpp b/enginecustom/src/src/system/stats.cpp
index 3c6e857..1181618 100644
--- a/enginecustom/src/src/system/stats.cpp
+++ b/enginecustom/src/src/system/stats.cpp
@@ -10,49 +10,58 @@ stats::~stats()
fps_ = nullptr;
}
-bool stats::initialize(fps_class* fps, application_class* app)
+bool stats::initialize(application_class* app)
{
- if (!fps) {
- Logger::Get().Log("FPS pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
+ if (!app) {
+ Logger::Get().Log("Application pointer is null", __FILE__, __LINE__, Logger::LogLevel::Error);
return false;
}
-
- fps_ = fps;
+
drawcalls_ = 0;
app_ = app;
+ fps_ = app_->get_fps();
+
+ if (!fps_) {
+ Logger::Get().Log("FPS object is null", __FILE__, __LINE__, Logger::LogLevel::Error);
+ return false;
+ }
+
// call update() in a separate thread
- std::thread updateThread(&stats::update, this);
- updateThread.detach(); // Detach the thread to run independently
+ std::thread update_geometric_thread(&stats::update_geometric_stats, this);
+ update_geometric_thread_ = std::move(update_geometric_thread); // Move the thread to the member variable
+ update_geometric_thread_.detach(); // Detach the thread to run independently
+
Logger::Get().Log("Stats initialized successfully", __FILE__, __LINE__, Logger::LogLevel::Initialize);
return true;
}
-void stats::update()
+void stats::update_geometric_stats()
{
while (true)
{
+ object_vec_ = app_->get_kobjects();
+ cubes_vec_ = app_->get_cubes();
+ terrain_chunk_vec_ = app_->get_terrain_cubes();
+
+ total_vertex_count_ = get_total_vertex_count();
+ total_triangle_count_ = get_total_triangle_count();
+ visible_triangle_count_ = get_visible_triangle_count();
+
// call update_stats() every second
std::this_thread::sleep_for(std::chrono::seconds(1));
- update_stats();
}
}
-void stats::update_stats()
+void stats::update_display_stats()
{
- object_vec_ = app_->get_kobjects();
- cubes_vec_ = app_->get_cubes();
- terrain_chunk_vec_ = app_->get_terrain_cubes();
-
- current_fps_ = get_current_fps();
- min_fps_ = get_min_fps();
- max_fps_ = get_max_fps();
+
+ current_fps_ = fps_->GetFps();
+ min_fps_ = fps_->GetMinFps();
+ max_fps_ = fps_->GetMaxFps();
drawcalls_ = get_draw_calls();
- total_vertex_count_ = get_total_vertex_count();
- total_triangle_count_ = get_total_triangle_count();
- visible_triangle_count_ = get_visible_triangle_count();
- current_frame_time_ = get_frame_time();
+ current_frame_time_ = fps_->GetFrameTime();
}
int stats::get_total_vertex_count() const
@@ -141,4 +150,79 @@ int stats::get_visible_triangle_count() const
}
}
return visibleTriangles;
+}
+
+std::string stats::get_cpu_name()
+{
+ char CPUBrandString[0x40] = {0};
+ int CPUInfo[4] = {-1};
+
+ // Fonction CPUID pour récupérer le nom du CPU
+ __cpuid(CPUInfo, 0x80000000);
+ unsigned int nExIds = CPUInfo[0];
+
+ for (unsigned int i = 0x80000000; i <= nExIds; ++i)
+ {
+ __cpuid(CPUInfo, i);
+
+ if (i == 0x80000002)
+ memcpy(CPUBrandString, CPUInfo, sizeof(CPUInfo));
+ else if (i == 0x80000003)
+ memcpy(CPUBrandString + 16, CPUInfo, sizeof(CPUInfo));
+ else if (i == 0x80000004)
+ memcpy(CPUBrandString + 32, CPUInfo, sizeof(CPUInfo));
+ }
+
+ std::string result = CPUBrandString;
+
+ // Nettoyer les caractères non-ASCII ou problématiques
+ result.erase(std::remove_if(result.begin(), result.end(),
+ [](unsigned char c) { return c < 32 || c > 126; }),
+ result.end());
+
+ // Supprimer les espaces multiples consécutifs
+ std::string::iterator new_end = std::unique(result.begin(), result.end(),
+ [](char a, char b) { return a == ' ' && b == ' '; });
+ result.erase(new_end, result.end());
+
+ // Supprimer les espaces au début et à la fin
+ result.erase(0, result.find_first_not_of(' '));
+ result.erase(result.find_last_not_of(' ') + 1);
+
+ return result;
+}
+
+std::string stats::get_gpu_driver_version(ID3D11Device* device)
+{
+ IDXGIDevice* dxgiDevice = nullptr;
+ IDXGIAdapter* adapter = nullptr;
+ std::string driverVersion = "Inconnu";
+
+ if (SUCCEEDED(device->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice)))
+ {
+ if (SUCCEEDED(dxgiDevice->GetAdapter(&adapter)))
+ {
+ DXGI_ADAPTER_DESC desc;
+ if (SUCCEEDED(adapter->GetDesc(&desc)))
+ {
+ // Conversion correcte de WCHAR (UTF-16) vers UTF-8
+ int size_needed = WideCharToMultiByte(CP_UTF8, 0, desc.Description, -1, nullptr, 0, nullptr, nullptr);
+ std::string deviceName;
+ if (size_needed > 0) {
+ std::vector buffer(size_needed);
+ WideCharToMultiByte(CP_UTF8, 0, desc.Description, -1, buffer.data(), size_needed, nullptr, nullptr);
+ deviceName = buffer.data();
+ }
+
+ char driverVersionStr[256];
+ sprintf_s(driverVersionStr, "%s (ID: %04X:%04X)", deviceName.c_str(), desc.VendorId, desc.DeviceId);
+
+ driverVersion = driverVersionStr;
+ }
+ adapter->Release();
+ }
+ dxgiDevice->Release();
+ }
+
+ return driverVersion;
}
\ No newline at end of file