StudioCherno / Walnut

Walnut is a simple application framework for Vulkan and Dear ImGui apps
MIT License
2.06k stars 378 forks source link

Feature Request: Expose GLFWwindow handle or otherwise allow means of registering certain callbacks #16

Open Mikewando opened 2 years ago

Mikewando commented 2 years ago

For example I want to handle drag & drop events in my app. This is easy to do with GLFW by calling glfwSetDropCallback(handle, callback). But the window handle isn't currently exposed so modifying Application.cpp is necessary.

If it's undesirable to expose GLFW I'd be fine with some other abstraction for setting the drop callback.

StevenJAckerman commented 2 years ago

I recently used this framework to implement an application that uses the implot Immediate Mode Plotting library:

https://github.com/epezent/implot

I had to modify the Application.cpp file to create and destroy an ImPlot context inside of the ImGui::CreateContext / ImGui::DestroyContext:

Integration

  1. Set up an ImGui environment if you don't already have one.
  2. Add implot.h, implot_internal.h, implot.cpp, implot_items.cpp and optionally implot_demo.cpp to your sources. Alternatively, you can get ImPlot using vcpkg.
  3. Create and destroy an ImPlotContext wherever you do so for your ImGuiContext:

ImGui::CreateContext(); ImPlot::CreateContext(); ... ImPlot::DestroyContext(); ImGui::DestroyContext();

Etaash-mathamsetty commented 2 years ago

just modify the source code to expose whatever you need, it's an MIT license after all...