|
|
|
@ -15,7 +15,6 @@ |
|
|
|
|
#include <GL/gl3w.h> |
|
|
|
|
|
|
|
|
|
// Data
|
|
|
|
|
static SDL_Window* g_Window = NULL; |
|
|
|
|
static double g_Time = 0.0f; |
|
|
|
|
static bool g_MousePressed[3] = { false, false, false }; |
|
|
|
|
static float g_MouseWheel = 0.0f; |
|
|
|
@ -296,10 +295,8 @@ void ImGui_ImplSdlGL3_InvalidateDeviceObjects() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool ImGui_ImplSdlGL3_Init(SDL_Window *window) |
|
|
|
|
bool ImGui_ImplSdlGL3_Init(SDL_Window* window) |
|
|
|
|
{ |
|
|
|
|
g_Window = window; |
|
|
|
|
|
|
|
|
|
ImGuiIO& io = ImGui::GetIO(); |
|
|
|
|
io.KeyMap[ImGuiKey_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
|
|
|
|
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT; |
|
|
|
@ -341,7 +338,7 @@ void ImGui_ImplSdlGL3_Shutdown() |
|
|
|
|
ImGui::Shutdown(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void ImGui_ImplSdlGL3_NewFrame() |
|
|
|
|
void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window) |
|
|
|
|
{ |
|
|
|
|
if (!g_FontTexture) |
|
|
|
|
ImGui_ImplSdlGL3_CreateDeviceObjects(); |
|
|
|
@ -350,9 +347,11 @@ void ImGui_ImplSdlGL3_NewFrame() |
|
|
|
|
|
|
|
|
|
// Setup display size (every frame to accommodate for window resizing)
|
|
|
|
|
int w, h; |
|
|
|
|
SDL_GetWindowSize(g_Window, &w, &h); |
|
|
|
|
int display_w, display_h; |
|
|
|
|
SDL_GetWindowSize(window, &w, &h); |
|
|
|
|
SDL_GL_GetDrawableSize(window, &display_w, &display_h); |
|
|
|
|
io.DisplaySize = ImVec2((float)w, (float)h); |
|
|
|
|
io.DisplayFramebufferScale = ImVec2(1.0f, 1.0f); |
|
|
|
|
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0); |
|
|
|
|
|
|
|
|
|
// Setup time step
|
|
|
|
|
Uint32 time = SDL_GetTicks(); |
|
|
|
@ -364,7 +363,7 @@ void ImGui_ImplSdlGL3_NewFrame() |
|
|
|
|
// (we already got mouse wheel, keyboard keys & characters from SDL_PollEvent())
|
|
|
|
|
int mx, my; |
|
|
|
|
Uint32 mouseMask = SDL_GetMouseState(&mx, &my); |
|
|
|
|
if (SDL_GetWindowFlags(g_Window) & SDL_WINDOW_MOUSE_FOCUS) |
|
|
|
|
if (SDL_GetWindowFlags(window) & SDL_WINDOW_MOUSE_FOCUS) |
|
|
|
|
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
|
|
|
|
else |
|
|
|
|
io.MousePos = ImVec2(-1, -1); |
|
|
|
|