mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-18 06:06:35 +00:00
Examples: GL2: rename functions to include GL2 in name
This commit is contained in:
parent
d165817880
commit
7d1f2c0dc5
@ -33,7 +33,7 @@ static GLuint g_FontTexture = 0;
|
||||
// This is the main rendering function that you have to implement and provide to ImGui (via setting up 'RenderDrawListsFn' in the ImGuiIO structure)
|
||||
// If text or lines are blurry when integrating ImGui in your engine:
|
||||
// - in your Render function, try translating your projection matrix by (0.5f,0.5f) or (0.375f,0.375f)
|
||||
void ImGui_ImplGlfw_RenderDrawLists(ImDrawData* draw_data)
|
||||
void ImGui_ImplGlfwGL2_RenderDrawLists(ImDrawData* draw_data)
|
||||
{
|
||||
// Avoid rendering when minimized, scale coordinates for retina displays (screen coordinates != framebuffer coordinates)
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -126,18 +126,18 @@ static void ImGui_ImplGlfw_SetClipboardText(void* user_data, const char* text)
|
||||
glfwSetClipboardString((GLFWwindow*)user_data, text);
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||
void ImGui_ImplGlfwGL2_MouseButtonCallback(GLFWwindow*, int button, int action, int /*mods*/)
|
||||
{
|
||||
if (action == GLFW_PRESS && button >= 0 && button < 3)
|
||||
g_MousePressed[button] = true;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
||||
void ImGui_ImplGlfwGL2_ScrollCallback(GLFWwindow*, double /*xoffset*/, double yoffset)
|
||||
{
|
||||
g_MouseWheel += (float)yoffset; // Use fractional mouse wheel, 1.0 unit 5 lines.
|
||||
}
|
||||
|
||||
void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
||||
void ImGui_ImplGlfwGL2_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (action == GLFW_PRESS)
|
||||
@ -152,14 +152,14 @@ void ImGui_ImplGlFw_KeyCallback(GLFWwindow*, int key, int, int action, int mods)
|
||||
io.KeySuper = io.KeysDown[GLFW_KEY_LEFT_SUPER] || io.KeysDown[GLFW_KEY_RIGHT_SUPER];
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
|
||||
void ImGui_ImplGlfwGL2_CharCallback(GLFWwindow*, unsigned int c)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
if (c > 0 && c < 0x10000)
|
||||
io.AddInputCharacter((unsigned short)c);
|
||||
}
|
||||
|
||||
bool ImGui_ImplGlfw_CreateDeviceObjects()
|
||||
bool ImGui_ImplGlfwGL2_CreateDeviceObjects()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -185,7 +185,7 @@ bool ImGui_ImplGlfw_CreateDeviceObjects()
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_InvalidateDeviceObjects()
|
||||
void ImGui_ImplGlfwGL2_InvalidateDeviceObjects()
|
||||
{
|
||||
if (g_FontTexture)
|
||||
{
|
||||
@ -195,7 +195,7 @@ void ImGui_ImplGlfw_InvalidateDeviceObjects()
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
||||
bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks)
|
||||
{
|
||||
g_Window = window;
|
||||
|
||||
@ -220,7 +220,7 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
||||
io.KeyMap[ImGuiKey_Y] = GLFW_KEY_Y;
|
||||
io.KeyMap[ImGuiKey_Z] = GLFW_KEY_Z;
|
||||
|
||||
io.RenderDrawListsFn = ImGui_ImplGlfw_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||
io.RenderDrawListsFn = ImGui_ImplGlfwGL2_RenderDrawLists; // Alternatively you can set this to NULL and call ImGui::GetDrawData() after ImGui::Render() to get the same ImDrawData pointer.
|
||||
io.SetClipboardTextFn = ImGui_ImplGlfw_SetClipboardText;
|
||||
io.GetClipboardTextFn = ImGui_ImplGlfw_GetClipboardText;
|
||||
io.ClipboardUserData = g_Window;
|
||||
@ -230,25 +230,25 @@ bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks)
|
||||
|
||||
if (install_callbacks)
|
||||
{
|
||||
glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||
glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
||||
glfwSetKeyCallback(window, ImGui_ImplGlFw_KeyCallback);
|
||||
glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
||||
glfwSetMouseButtonCallback(window, ImGui_ImplGlfwGL2_MouseButtonCallback);
|
||||
glfwSetScrollCallback(window, ImGui_ImplGlfwGL2_ScrollCallback);
|
||||
glfwSetKeyCallback(window, ImGui_ImplGlfwGL2_KeyCallback);
|
||||
glfwSetCharCallback(window, ImGui_ImplGlfwGL2_CharCallback);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_Shutdown()
|
||||
void ImGui_ImplGlfwGL2_Shutdown()
|
||||
{
|
||||
ImGui_ImplGlfw_InvalidateDeviceObjects();
|
||||
ImGui_ImplGlfwGL2_InvalidateDeviceObjects();
|
||||
ImGui::Shutdown();
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_NewFrame()
|
||||
void ImGui_ImplGlfwGL2_NewFrame()
|
||||
{
|
||||
if (!g_FontTexture)
|
||||
ImGui_ImplGlfw_CreateDeviceObjects();
|
||||
ImGui_ImplGlfwGL2_CreateDeviceObjects();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
|
@ -12,18 +12,17 @@
|
||||
|
||||
struct GLFWwindow;
|
||||
|
||||
IMGUI_API bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks);
|
||||
IMGUI_API void ImGui_ImplGlfw_Shutdown();
|
||||
IMGUI_API void ImGui_ImplGlfw_NewFrame();
|
||||
IMGUI_API bool ImGui_ImplGlfwGL2_Init(GLFWwindow* window, bool install_callbacks);
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_Shutdown();
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_NewFrame();
|
||||
|
||||
// Use if you want to reset your rendering device without losing ImGui state.
|
||||
IMGUI_API void ImGui_ImplGlfw_InvalidateDeviceObjects();
|
||||
IMGUI_API bool ImGui_ImplGlfw_CreateDeviceObjects();
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_InvalidateDeviceObjects();
|
||||
IMGUI_API bool ImGui_ImplGlfwGL2_CreateDeviceObjects();
|
||||
|
||||
// GLFW callbacks (installed by default if you enable 'install_callbacks' during initialization)
|
||||
// Provided here if you want to chain callbacks.
|
||||
// You can also handle inputs yourself and use those as a reference.
|
||||
IMGUI_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||
IMGUI_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||
IMGUI_API void ImGui_ImplGlFw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
IMGUI_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c);
|
||||
// GLFW callbacks (registered by default to GLFW if you enable 'install_callbacks' during initialization)
|
||||
// Provided here if you want to chain callbacks yourself. You may also handle inputs yourself and use those as a reference.
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
IMGUI_API void ImGui_ImplGlfwGL2_CharCallback(GLFWwindow* window, unsigned int c);
|
||||
|
@ -22,7 +22,7 @@ int main(int, char**)
|
||||
glfwSwapInterval(1); // Enable vsync
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui_ImplGlfw_Init(window, true);
|
||||
ImGui_ImplGlfwGL2_Init(window, true);
|
||||
|
||||
// Load Fonts
|
||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
||||
@ -42,7 +42,7 @@ int main(int, char**)
|
||||
while (!glfwWindowShouldClose(window))
|
||||
{
|
||||
glfwPollEvents();
|
||||
ImGui_ImplGlfw_NewFrame();
|
||||
ImGui_ImplGlfwGL2_NewFrame();
|
||||
|
||||
// 1. Show a simple window
|
||||
// Tip: if we don't call ImGui::Begin()/ImGui::End() the widgets appears in a window automatically called "Debug"
|
||||
@ -84,7 +84,7 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
ImGui_ImplGlfw_Shutdown();
|
||||
ImGui_ImplGlfwGL2_Shutdown();
|
||||
glfwTerminate();
|
||||
|
||||
return 0;
|
||||
|
@ -117,7 +117,7 @@ static void ImGui_ImplSdl_SetClipboardText(void*, const char* text)
|
||||
SDL_SetClipboardText(text);
|
||||
}
|
||||
|
||||
bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event)
|
||||
bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event)
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
switch (event->type)
|
||||
@ -157,7 +157,7 @@ bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ImGui_ImplSdl_CreateDeviceObjects()
|
||||
bool ImGui_ImplSdlGL2_CreateDeviceObjects()
|
||||
{
|
||||
// Build texture atlas
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
@ -184,7 +184,7 @@ bool ImGui_ImplSdl_CreateDeviceObjects()
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplSdl_InvalidateDeviceObjects()
|
||||
void ImGui_ImplSdlGL2_InvalidateDeviceObjects()
|
||||
{
|
||||
if (g_FontTexture)
|
||||
{
|
||||
@ -194,7 +194,7 @@ void ImGui_ImplSdl_InvalidateDeviceObjects()
|
||||
}
|
||||
}
|
||||
|
||||
bool ImGui_ImplSdl_Init(SDL_Window* window)
|
||||
bool ImGui_ImplSdlGL2_Init(SDL_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.
|
||||
@ -234,16 +234,16 @@ bool ImGui_ImplSdl_Init(SDL_Window* window)
|
||||
return true;
|
||||
}
|
||||
|
||||
void ImGui_ImplSdl_Shutdown()
|
||||
void ImGui_ImplSdlGL2_Shutdown()
|
||||
{
|
||||
ImGui_ImplSdl_InvalidateDeviceObjects();
|
||||
ImGui_ImplSdlGL2_InvalidateDeviceObjects();
|
||||
ImGui::Shutdown();
|
||||
}
|
||||
|
||||
void ImGui_ImplSdl_NewFrame(SDL_Window *window)
|
||||
void ImGui_ImplSdlGL2_NewFrame(SDL_Window *window)
|
||||
{
|
||||
if (!g_FontTexture)
|
||||
ImGui_ImplSdl_CreateDeviceObjects();
|
||||
ImGui_ImplSdlGL2_CreateDeviceObjects();
|
||||
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
|
||||
|
@ -9,11 +9,11 @@
|
||||
struct SDL_Window;
|
||||
typedef union SDL_Event SDL_Event;
|
||||
|
||||
IMGUI_API bool ImGui_ImplSdl_Init(SDL_Window* window);
|
||||
IMGUI_API void ImGui_ImplSdl_Shutdown();
|
||||
IMGUI_API void ImGui_ImplSdl_NewFrame(SDL_Window* window);
|
||||
IMGUI_API bool ImGui_ImplSdl_ProcessEvent(SDL_Event* event);
|
||||
IMGUI_API bool ImGui_ImplSdlGL2_Init(SDL_Window* window);
|
||||
IMGUI_API void ImGui_ImplSdlGL2_Shutdown();
|
||||
IMGUI_API void ImGui_ImplSdlGL2_NewFrame(SDL_Window* window);
|
||||
IMGUI_API bool ImGui_ImplSdlGL2_ProcessEvent(SDL_Event* event);
|
||||
|
||||
// Use if you want to reset your rendering device without losing ImGui state.
|
||||
IMGUI_API void ImGui_ImplSdl_InvalidateDeviceObjects();
|
||||
IMGUI_API bool ImGui_ImplSdl_CreateDeviceObjects();
|
||||
IMGUI_API void ImGui_ImplSdlGL2_InvalidateDeviceObjects();
|
||||
IMGUI_API bool ImGui_ImplSdlGL2_CreateDeviceObjects();
|
||||
|
@ -28,7 +28,7 @@ int main(int, char**)
|
||||
SDL_GLContext glcontext = SDL_GL_CreateContext(window);
|
||||
|
||||
// Setup ImGui binding
|
||||
ImGui_ImplSdl_Init(window);
|
||||
ImGui_ImplSdlGL2_Init(window);
|
||||
|
||||
// Load Fonts
|
||||
// (there is a default font, this is only if you want to change it. see extra_fonts/README.txt for more details)
|
||||
@ -51,11 +51,11 @@ int main(int, char**)
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
{
|
||||
ImGui_ImplSdl_ProcessEvent(&event);
|
||||
ImGui_ImplSdlGL2_ProcessEvent(&event);
|
||||
if (event.type == SDL_QUIT)
|
||||
done = true;
|
||||
}
|
||||
ImGui_ImplSdl_NewFrame(window);
|
||||
ImGui_ImplSdlGL2_NewFrame(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"
|
||||
@ -95,7 +95,7 @@ int main(int, char**)
|
||||
}
|
||||
|
||||
// Cleanup
|
||||
ImGui_ImplSdl_Shutdown();
|
||||
ImGui_ImplSdlGL2_Shutdown();
|
||||
SDL_GL_DeleteContext(glcontext);
|
||||
SDL_DestroyWindow(window);
|
||||
SDL_Quit();
|
||||
|
Loading…
Reference in New Issue
Block a user