Browse Source

Lesson 22.2

Godzil 3 years ago
parent
commit
75bdfa36c3
1 changed files with 12 additions and 1 deletions
  1. 12 1
      source/Game.cpp

+ 12 - 1
source/Game.cpp

@@ -14,7 +14,7 @@
 #include <glm/glm.hpp>
 #include <imgui.h>
 #include <imgui_sdl.h>
-#include <backends/imgui_impl_sdl.h>
+#include <imgui_impl_sdl.h>
 
 #include <memory>
 #include <fstream>
@@ -295,6 +295,17 @@ void Game::ProcessInput()
 
     while(SDL_PollEvent(&event))
     {
+        int mouseX, mouseY, buttons;
+
+        ImGui_ImplSDL2_ProcessEvent(&event);
+        ImGuiIO &io = ImGui::GetIO();
+
+        buttons = SDL_GetMouseState(&mouseX, &mouseY);
+        io.MousePos = ImVec2(mouseX, mouseY);
+        io.MouseDown[0] = buttons & SDL_BUTTON(SDL_BUTTON_LEFT);
+        io.MouseDown[1] = buttons & SDL_BUTTON(SDL_BUTTON_RIGHT);
+        io.MouseDown[2] = buttons & SDL_BUTTON(SDL_BUTTON_MIDDLE);
+
         switch(event.type)
         {
             case SDL_QUIT: