Skip to content

Commit

Permalink
ImGUI input handling now works.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robadob committed Aug 19, 2022
1 parent ff97295 commit 2bd3645
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
6 changes: 6 additions & 0 deletions src/flamegpu/visualiser/Visualiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ void Visualiser::render() {
this->lighting->getPointLight(0).Position(this->camera->getEye());
// handle each event on the queue
while (SDL_PollEvent(&e) != 0) {
if (!SDL_GetRelativeMouseMode()) {
// Assume ImGUI is top level, allow it first chance on IO if mouse isn't locked for movement
ImGui_ImplSDL2_ProcessEvent(&e);
if (ImGui::GetIO().WantCaptureMouse || ImGui::GetIO().WantCaptureKeyboard)
continue;
}
switch (e.type) {
case SDL_QUIT:
continueRender = false;
Expand Down
13 changes: 6 additions & 7 deletions src/flamegpu/visualiser/ui/ImGuiPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,19 @@ namespace visualiser {

ImGuiPanel::ImGuiPanel()
: Overlay(std::make_shared<Shaders>(Stock::Shaders::SPRITE2D)) {
bool is_true = true;

// Start the Dear ImGui frame
ImGui_ImplOpenGL3_NewFrame();
ImGui_ImplSDL2_NewFrame();
ImGui::NewFrame();
ImGui::ShowDemoWindow(&is_true);
// This renders the interface to a host texture
ImGui::Render();
ImGui_ImplSDL2_NewFrame(); // This can't be called in the render thread, as it tries to grab the window dimensions via SDL
}
void ImGuiPanel::reload() {
// Do nothing
}
void ImGuiPanel::render(const glm::mat4*, const glm::mat4*, GLuint fbo) {
ImGui::NewFrame();
bool is_true = true;
ImGui::ShowDemoWindow(&is_true);
// This renders the interface to a host texture
ImGui::Render();
// glViewport(0, 0, (int)io.DisplaySize.x, (int)io.DisplaySize.y);
// glClearColor(clear_color.x * clear_color.w, clear_color.y * clear_color.w, clear_color.z * clear_color.w, clear_color.w);
// glClear(GL_COLOR_BUFFER_BIT);
Expand Down

0 comments on commit 2bd3645

Please sign in to comment.