Я разрабатываю настольную программу на основе ветки imgui docking в Ubuntu 22.04, чтобы добавлять изображение в фоновое окно и всегда центрировать его при изменении размера окна:
(Также обратите внимание: перед запуском программы поместите произвольное изображение в формате PNG в папку значков)
Я разрабатываю настольную программу на основе ветки imgui docking в Ubuntu 22.04, чтобы добавлять изображение в фоновое окно и всегда центрировать его при изменении размера окна: (Также обратите внимание: перед запуском программы поместите произвольное изображение в формате PNG в папку значков) [code]#include #define GL_SILENCE_DEPRECATION #if defined(IMGUI_IMPL_OPENGL_ES2) #include #endif #include // Will drag system OpenGL headers #include "imgui.h" #include "imgui_impl_glfw.h" #include "imgui_impl_opengl3.h" #include "IconsFontAwesome6.h" // from https://github.com/juliettef/IconFontCppHeaders.git
#define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" // from https://github.com/nothings/stb.git
// When viewports are enabled we tweak WindowRounding/WindowBg so platform windows can look identical to regular ones. ImGuiStyle& style = ImGui::GetStyle(); if (io.ConfigFlags & ImGuiConfigFlags_ViewportsEnable) { style.WindowRounding = 0.0f; style.Colors[ImGuiCol_WindowBg].w = 1.0f; } }
int my_image_width = 0; int my_image_height = 0; GLuint my_image_texture = 0; bool ret = LoadTextureFromFile("icons/test.png", &my_image_texture, &my_image_width, &my_image_height); if(!ret) return 0;
ImGuiIO& io = ImGui::GetIO(); // Main loop #ifdef __EMSCRIPTEN__ // For an Emscripten build we are disabling file-system access, so let's not attempt to do a fopen() of the imgui.ini file. // You may manually call LoadIniSettingsFromMemory() to load settings from your own storage. io.IniFilename = nullptr; EMSCRIPTEN_MAINLOOP_BEGIN #else while(!glfwWindowShouldClose(window)) #endif { // Poll and handle events (inputs, window resize, etc.) // You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs. // - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application, or clear/overwrite your copy of the mouse data. // - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application, or clear/overwrite your copy of the keyboard data. // Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags. glfwPollEvents(); if (glfwGetWindowAttrib(window, GLFW_ICONIFIED) != 0) { ImGui_ImplGlfw_Sleep(10); continue; }
// Start the Dear ImGui frame ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame();
// 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); }
Я разрабатываю настольную программу на основе стыковки imgui филиала на Ubuntu 22.04. Я новичок в iMgui и отсутствие знаний OpenGL. Я имею в виду example_glfw_opengl3 из примеров исходных кодов imgui. Изменение размера. Все работает очень хорошо...
Мой друг предложил мне обойти его программу против импорта изображений. Он описывает основу того, как это работает, но я до сих пор не нашел для этого решения. Я кратко объясню, что я пробовал и как это работает (насколько я понимаю).
I have used the glfwgetwindowpos and glfwsetwindowpos with imgui's getmousedragdelta to try and move the parent glfw window using imgui. What I am trying to accomplish is to have an imgui window where I am able to drag on it, but rather than moving...
I have used the glfwgetwindowpos and glfwsetwindowpos with imgui's getmousedragdelta to try and move the parent glfw window using imgui. What I am trying to accomplish is to have an imgui window where I am able to drag on it, but rather than moving...
I have used the glfwgetwindowpos and glfwsetwindowpos with imgui's getmousedragdelta to try and move the parent glfw window using imgui. What I am trying to accomplish is to have an imgui window where I am able to drag on it, but rather than moving...