启用docking

This commit is contained in:
2024-02-19 01:42:13 +08:00
parent 87ad4d5eb9
commit fa2a33881a
3 changed files with 16 additions and 1 deletions

View File

@@ -117,6 +117,8 @@ void application::init_imgui() {
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_NavEnableKeyboard; // Enable Keyboard Controls
io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad; // Enable Gamepad Controls
io.ConfigFlags |= ImGuiConfigFlags_DockingEnable; // Enable Docking
io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable; // Enable Multi-Viewport / Platform Windows
ImGui::StyleColorsDark();
//ImGui::StyleColorsLight();
}

View File

@@ -88,6 +88,8 @@ void renderer_opengl::new_frame(GLFWwindow* window_handle) {
}
void renderer_opengl::end_frame(GLFWwindow* window_handle) {
const ImGuiIO& io = ImGui::GetIO();
// Rendering
ImGui::Render();
int display_w, display_h;
@@ -98,6 +100,17 @@ void renderer_opengl::end_frame(GLFWwindow* window_handle) {
glClear(GL_COLOR_BUFFER_BIT);
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());
// Update and Render additional Platform Windows
// (Platform functions may change the current OpenGL context, so we save/restore it to make it easier to paste this code elsewhere.
// For this specific demo app we could also call glfwMakeContextCurrent(window) directly)
if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable)
{
GLFWwindow* backup_current_context = glfwGetCurrentContext();
ImGui::UpdatePlatformWindows();
ImGui::RenderPlatformWindowsDefault();
glfwMakeContextCurrent(backup_current_context);
}
glfwSwapBuffers(window_handle);
}