mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 14:16:36 +00:00
Examples: SDL: Made ImGui_ImplSdlGL3_NewFrame() signature match GL2 one
This commit is contained in:
parent
e6c2c1fcfd
commit
fdc4299c6c
@ -15,7 +15,6 @@
|
|||||||
#include <GL/gl3w.h>
|
#include <GL/gl3w.h>
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
static SDL_Window* g_Window = NULL;
|
|
||||||
static double g_Time = 0.0f;
|
static double g_Time = 0.0f;
|
||||||
static bool g_MousePressed[3] = { false, false, false };
|
static bool g_MousePressed[3] = { false, false, false };
|
||||||
static float g_MouseWheel = 0.0f;
|
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();
|
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_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
|
io.KeyMap[ImGuiKey_LeftArrow] = SDL_SCANCODE_LEFT;
|
||||||
@ -341,7 +338,7 @@ void ImGui_ImplSdlGL3_Shutdown()
|
|||||||
ImGui::Shutdown();
|
ImGui::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImGui_ImplSdlGL3_NewFrame()
|
void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window)
|
||||||
{
|
{
|
||||||
if (!g_FontTexture)
|
if (!g_FontTexture)
|
||||||
ImGui_ImplSdlGL3_CreateDeviceObjects();
|
ImGui_ImplSdlGL3_CreateDeviceObjects();
|
||||||
@ -351,8 +348,8 @@ void ImGui_ImplSdlGL3_NewFrame()
|
|||||||
// Setup display size (every frame to accommodate for window resizing)
|
// Setup display size (every frame to accommodate for window resizing)
|
||||||
int w, h;
|
int w, h;
|
||||||
int display_w, display_h;
|
int display_w, display_h;
|
||||||
SDL_GetWindowSize(g_Window, &w, &h);
|
SDL_GetWindowSize(window, &w, &h);
|
||||||
SDL_GL_GetDrawableSize(g_Window, &display_w, &display_h);
|
SDL_GL_GetDrawableSize(window, &display_w, &display_h);
|
||||||
io.DisplaySize = ImVec2((float)w, (float)h);
|
io.DisplaySize = ImVec2((float)w, (float)h);
|
||||||
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
|
io.DisplayFramebufferScale = ImVec2(w > 0 ? ((float)display_w / w) : 0, h > 0 ? ((float)display_h / h) : 0);
|
||||||
|
|
||||||
@ -366,7 +363,7 @@ void ImGui_ImplSdlGL3_NewFrame()
|
|||||||
// (we already got mouse wheel, keyboard keys & characters from SDL_PollEvent())
|
// (we already got mouse wheel, keyboard keys & characters from SDL_PollEvent())
|
||||||
int mx, my;
|
int mx, my;
|
||||||
Uint32 mouseMask = SDL_GetMouseState(&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.)
|
io.MousePos = ImVec2((float)mx, (float)my); // Mouse position, in pixels (set to -1,-1 if no mouse / on another screen, etc.)
|
||||||
else
|
else
|
||||||
io.MousePos = ImVec2(-1, -1);
|
io.MousePos = ImVec2(-1, -1);
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_API bool ImGui_ImplSdlGL3_Init(SDL_Window *window);
|
IMGUI_API bool ImGui_ImplSdlGL3_Init(SDL_Window* window);
|
||||||
IMGUI_API void ImGui_ImplSdlGL3_Shutdown();
|
IMGUI_API void ImGui_ImplSdlGL3_Shutdown();
|
||||||
IMGUI_API void ImGui_ImplSdlGL3_NewFrame();
|
IMGUI_API void ImGui_ImplSdlGL3_NewFrame(SDL_Window* window);
|
||||||
IMGUI_API bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event);
|
IMGUI_API bool ImGui_ImplSdlGL3_ProcessEvent(SDL_Event* event);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
|
@ -58,7 +58,7 @@ int main(int, char**)
|
|||||||
if (event.type == SDL_QUIT)
|
if (event.type == SDL_QUIT)
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
ImGui_ImplSdlGL3_NewFrame();
|
ImGui_ImplSdlGL3_NewFrame(window);
|
||||||
|
|
||||||
// 1. Show a simple window
|
// 1. Show a simple window
|
||||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||||
|
@ -185,7 +185,7 @@ void ImGui_ImplSdl_InvalidateDeviceObjects()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImGui_ImplSdl_Init(SDL_Window *window)
|
bool ImGui_ImplSdl_Init(SDL_Window* window)
|
||||||
{
|
{
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
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_Tab] = SDLK_TAB; // Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
||||||
|
@ -9,9 +9,9 @@
|
|||||||
struct SDL_Window;
|
struct SDL_Window;
|
||||||
typedef union SDL_Event SDL_Event;
|
typedef union SDL_Event SDL_Event;
|
||||||
|
|
||||||
IMGUI_API bool ImGui_ImplSdl_Init(SDL_Window *window);
|
IMGUI_API bool ImGui_ImplSdl_Init(SDL_Window* window);
|
||||||
IMGUI_API void ImGui_ImplSdl_Shutdown();
|
IMGUI_API void ImGui_ImplSdl_Shutdown();
|
||||||
IMGUI_API void ImGui_ImplSdl_NewFrame(SDL_Window *window);
|
IMGUI_API void ImGui_ImplSdl_NewFrame(SDL_Window* window);
|
||||||
IMGUI_API bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event);
|
IMGUI_API bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event);
|
||||||
|
|
||||||
// Use if you want to reset your rendering device without losing ImGui state.
|
// Use if you want to reset your rendering device without losing ImGui state.
|
||||||
|
Loading…
Reference in New Issue
Block a user