mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Examples: Misc comments mainly related to GLFW callbacks. (#1759)
This commit is contained in:
parent
a419d46205
commit
9d155c73bc
@ -22,14 +22,16 @@ int main(int, char**)
|
||||
al_register_event_source(queue, al_get_keyboard_event_source());
|
||||
al_register_event_source(queue, al_get_mouse_event_source());
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplAllegro5_Init(display);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -237,16 +237,17 @@
|
||||
if ([view openGLContext] == nil)
|
||||
NSLog(@"No OpenGL Context!");
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplOSX_Init();
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -95,16 +95,17 @@ int main(int argc, char** argv)
|
||||
// otherwise it is possible to install our own functions and call the imgui_impl_freeglut.h functions ourselves.
|
||||
glutDisplayFunc(glut_display_func);
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplFreeGLUT_Init();
|
||||
ImGui_ImplFreeGLUT_InstallFuncs();
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -36,17 +36,19 @@ int main(int, char**)
|
||||
glfwMakeContextCurrent(window);
|
||||
glfwSwapInterval(1); // Enable vsync
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
// If you have already installed GLFW callbacks in your app, call ImGui_ImplGlfw_InitForOpenGL() with install_callbacks=false and call them yourself.
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -82,17 +82,19 @@ int main(int, char**)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
// If you have already installed GLFW callbacks in your app, call ImGui_ImplGlfw_InitForOpenGL() with install_callbacks=false and call them yourself.
|
||||
ImGui_ImplGlfw_InitForOpenGL(window, true);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -350,17 +350,16 @@ int main(int, char**)
|
||||
ImGui_ImplVulkanH_WindowData* wd = &g_WindowData;
|
||||
SetupVulkanWindowData(wd, surface, w, h);
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
|
||||
|
||||
// Setup GLFW binding
|
||||
// Setup Platform/Renderer bindings
|
||||
// If you have already installed GLFW callbacks in your app, call ImGui_ImplGlfw_InitForVulkan() with install_callbacks=false and call the functions yourself.
|
||||
ImGui_ImplGlfw_InitForVulkan(window, true);
|
||||
|
||||
// Setup Vulkan binding
|
||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||
init_info.Instance = g_Instance;
|
||||
init_info.PhysicalDevice = g_PhysicalDevice;
|
||||
@ -373,7 +372,7 @@ int main(int, char**)
|
||||
init_info.CheckVkResultFn = check_vk_result;
|
||||
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -16,14 +16,16 @@ int main(int, char**)
|
||||
{
|
||||
IwGxInit();
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_Marmalade_Init(true);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -34,16 +34,17 @@ int main(int, char**)
|
||||
SDL_GLContext gl_context = SDL_GL_CreateContext(window);
|
||||
SDL_GL_SetSwapInterval(1); // Enable vsync
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||
ImGui_ImplOpenGL2_Init();
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -74,16 +74,17 @@ int main(int, char**)
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplSDL2_InitForOpenGL(window, gl_context);
|
||||
ImGui_ImplOpenGL3_Init(glsl_version);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -333,15 +333,13 @@ int main(int, char**)
|
||||
ImGui_ImplVulkanH_WindowData* wd = &g_WindowData;
|
||||
SetupVulkanWindowData(wd, surface, w, h);
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup SDL binding
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplSDL2_InitForVulkan(window);
|
||||
|
||||
// Setup Vulkan binding
|
||||
ImGui_ImplVulkan_InitInfo init_info = {};
|
||||
init_info.Instance = g_Instance;
|
||||
init_info.PhysicalDevice = g_PhysicalDevice;
|
||||
@ -354,7 +352,7 @@ int main(int, char**)
|
||||
init_info.CheckVkResultFn = check_vk_result;
|
||||
ImGui_ImplVulkan_Init(&init_info, wd->RenderPass);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -110,16 +110,17 @@ int main(int, char**)
|
||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX10_Init(g_pd3dDevice);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -113,16 +113,17 @@ int main(int, char**)
|
||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX11_Init(g_pd3dDevice, g_pd3dDeviceContext);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -286,19 +286,20 @@ int main(int, char**)
|
||||
ShowWindow(hwnd, SW_SHOWDEFAULT);
|
||||
UpdateWindow(hwnd);
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX12_Init(g_pd3dDevice, NUM_FRAMES_IN_FLIGHT,
|
||||
DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||
g_pd3dSrvDescHeap->GetCPUDescriptorHandleForHeapStart(),
|
||||
g_pd3dSrvDescHeap->GetGPUDescriptorHandleForHeapStart());
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -75,15 +75,17 @@ int main(int, char**)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Setup Dear ImGui binding
|
||||
// Setup Dear ImGui context
|
||||
IMGUI_CHECKVERSION();
|
||||
ImGui::CreateContext();
|
||||
ImGuiIO& io = ImGui::GetIO(); (void)io;
|
||||
//io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
|
||||
|
||||
// Setup Platform/Renderer bindings
|
||||
ImGui_ImplWin32_Init(hwnd);
|
||||
ImGui_ImplDX9_Init(g_pd3dDevice);
|
||||
|
||||
// Setup style
|
||||
// Setup Style
|
||||
ImGui::StyleColorsDark();
|
||||
//ImGui::StyleColorsClassic();
|
||||
|
||||
|
@ -102,14 +102,6 @@ void ImGui_ImplGlfw_CharCallback(GLFWwindow*, unsigned int c)
|
||||
io.AddInputCharacter((unsigned short)c);
|
||||
}
|
||||
|
||||
void ImGui_ImplGlfw_InstallCallbacks(GLFWwindow* window)
|
||||
{
|
||||
glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||
glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
||||
glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
||||
glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
||||
}
|
||||
|
||||
static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, GlfwClientApi client_api)
|
||||
{
|
||||
g_Window = window;
|
||||
@ -160,7 +152,12 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
||||
g_MouseCursors[ImGuiMouseCursor_Hand] = glfwCreateStandardCursor(GLFW_HAND_CURSOR);
|
||||
|
||||
if (install_callbacks)
|
||||
ImGui_ImplGlfw_InstallCallbacks(window);
|
||||
{
|
||||
glfwSetMouseButtonCallback(window, ImGui_ImplGlfw_MouseButtonCallback);
|
||||
glfwSetScrollCallback(window, ImGui_ImplGlfw_ScrollCallback);
|
||||
glfwSetKeyCallback(window, ImGui_ImplGlfw_KeyCallback);
|
||||
glfwSetCharCallback(window, ImGui_ImplGlfw_CharCallback);
|
||||
}
|
||||
|
||||
g_ClientApi = client_api;
|
||||
return true;
|
||||
|
@ -25,9 +25,10 @@ IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool in
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown();
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame();
|
||||
|
||||
// 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.
|
||||
// GLFW callbacks are installed by default if you call the InitXXX function with 'install_callbacks=true'.
|
||||
// If you already have GLFW callbacks installed by your application, call the InitXXX function with install_callbacks=false,
|
||||
// then call the functions yourselves from your own GLFW callbacks.
|
||||
// You may also handle inputs yourself and use those as a reference.
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset);
|
||||
IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods);
|
||||
|
Loading…
Reference in New Issue
Block a user