diff --git a/CMakeLists.txt b/CMakeLists.txt index b0dc26cdd55d0a643d6cced1f1778ad295db91e4..fcaaf83d6e1d8d7458cdfb83486858fc8edd6727 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,7 +72,6 @@ target_include_directories(cuda_static PUBLIC set(COMMON_SOURCES src/spawn_particles.cpp src/Camera.cpp - src/ImGuiManager.cpp src/FluidSimulationApp.cpp src/FluidRenderer.cpp src/FluidSimulation.cpp diff --git a/src/ImGuiManager.cpp b/src/ImGuiManager.cpp deleted file mode 100644 index c44413be47e9487bfd332745b578f1f542ea8d88..0000000000000000000000000000000000000000 --- a/src/ImGuiManager.cpp +++ /dev/null @@ -1,156 +0,0 @@ -// ImGuiManager.cpp -#include "include/ImGuiManager.h" -#include "imgui_impl_glfw.h" -#include "imgui_impl_opengl3.h" - -// Constructor: Initializes ImGui context and sets up backends -ImGuiManager::ImGuiManager(GLFWwindow* window, FluidConfig& config) - : fluidConfig(config) // Initialize the reference -{ - // Setup Dear ImGui context - IMGUI_CHECKVERSION(); - ImGui::CreateContext(); - ImGuiIO& io = ImGui::GetIO(); (void)io; - - // Enable Docking - io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; - - // Optional: Enable Multi-Viewport / Platform Windows - // io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; - - // Setup Dear ImGui style - ImGui::StyleColorsDark(); - // ImGui::StyleColorsClassic(); - - // Setup Platform/Renderer backends - ImGui_ImplGlfw_InitForOpenGL(window, true); - ImGui_ImplOpenGL3_Init("#version 330"); -} - -// Destructor: Cleans up ImGui resources -ImGuiManager::~ImGuiManager() { - // Cleanup ImGui backends - ImGui_ImplOpenGL3_Shutdown(); - ImGui_ImplGlfw_Shutdown(); - - // Destroy ImGui context - ImGui::DestroyContext(); -} - -// Starts a new ImGui frame -void ImGuiManager::newFrame() { - // Start the Dear ImGui frame - ImGui_ImplOpenGL3_NewFrame(); - ImGui_ImplGlfw_NewFrame(); - ImGui::NewFrame(); -} - -// Renders ImGui draw data -void ImGuiManager::render() { - // Rendering - ImGui::Render(); - ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData()); - - // Update and Render additional Platform Windows (if enabled) - /* - ImGuiIO& io = ImGui::GetIO(); - if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable){ - GLFWwindow* backup_current_context = glfwGetCurrentContext(); - ImGui::UpdatePlatformWindows(); - ImGui::RenderPlatformWindowsDefault(); - glfwMakeContextCurrent(backup_current_context); - } - */ -} - -// Provides access to ImGuiIO -ImGuiIO& ImGuiManager::getIO() { - return ImGui::GetIO(); -} - -void ImGuiManager::createControlsWindow() { - ImGui::Begin("Controls"); - - ImGui::Text("Fluid Simulation Parameters"); - ImGui::Separator(); // Draw a horizontal line to separate sections - ImGui::Spacing(); - - // Block: Fluid Properties - ImGui::Text("Fluid Properties:"); - ImGui::Spacing(); - ImGui::Text("Viscosity:"); - ImGui::SliderFloat("##ViscositySlider", &fluidConfig.viscosity, 0.0f, 5.0f, "%.2f"); - ImGui::Spacing(); - ImGui::Text("Particle Mass:"); - ImGui::SliderFloat("##ParticleMassSlider", &fluidConfig.particleMass, 0.0f, 2.0f, "%.2f"); - - ImGui::Spacing(); - ImGui::Separator(); // Separate sections visually - ImGui::Spacing(); - - // Block: Simulation Settings - ImGui::Text("Simulation Settings:"); - ImGui::Spacing(); - ImGui::Text("Rest Density:"); - ImGui::SliderFloat("##RestDensitySlider", &fluidConfig.restDensity, 1000.0f, 5000.0f, "%.0f"); - ImGui::Spacing(); - ImGui::Text("Smoothing Radius:"); - ImGui::SliderFloat("##SmoothingRadiusSlider", &fluidConfig.smoothingRadius, 0.1f, 1.0f, "%.2f"); - - ImGui::Spacing(); - ImGui::Separator(); // Separate sections visually - ImGui::Spacing(); - - // Additional blocks can be added as needed - // For example: - // ImGui::Text("Additional Settings:"); - // ImGui::Spacing(); - // ImGui::SliderFloat("SomeOtherParameter", &someConfigValue, min, max, "%.2f"); - - ImGui::End(); -} - -// Creates the "Frame Stats" window with FPS graphs -void ImGuiManager::createFrameStatsWindow() { - ImGui::Begin("Frame Stats"); - - // Example implementation using plot lines - static float fpsHistory[120] = {0}; - static float frameTimeHistory[120] = {0}; - static int historyIndex = 0; - - // Update history arrays (this should be called each frame) - ImGuiIO& io = ImGui::GetIO(); - float currentFps = io.Framerate; - float currentFrameTime = 1000.0f / currentFps; // in ms - - fpsHistory[historyIndex % 120] = currentFps; - frameTimeHistory[historyIndex % 120] = currentFrameTime; - historyIndex++; - - // Plot FPS - ImGui::Text("FPS"); - ImGui::PlotLines("##FPS", fpsHistory, 120, historyIndex % 120, NULL, 0.0f, 120.0f, ImVec2(0, 80)); - - // Plot Frame Time - ImGui::Text("Frame Time (ms)"); - ImGui::PlotLines("##FrameTime", frameTimeHistory, 120, historyIndex % 120, NULL, 0.0f, 50.0f, ImVec2(0, 80)); - - ImGui::End(); -} - -// Creates the "FBO Selection" window with a dropdown -void ImGuiManager::createFBOSelectionWindow() { - ImGui::Begin("FBO Selection"); - - static int selectedFBO = 0; - const char* fboOptions[] = { "Stage 1", "Stage 2", "Stage 3", "Stage 4" }; - int numFBOs = sizeof(fboOptions) / sizeof(fboOptions[0]); - - ImGui::Combo("Select FBO to Render", &selectedFBO, fboOptions, numFBOs); - - // You can store 'selectedFBO' to use it later for rendering - // For now, as per your request, no functionality is implemented - - ImGui::End(); -}