Пример #1
0
        public void End()
        {
            ImGuiIOPtr  io  = ImGui.GetIO();
            Application app = Application.Instance;

            io.DisplaySize = new Vector2((float)app.Window.Width, (float)app.Window.Height);

            // Rendering
            ImGui.Render();
            ImGuiController.ImGui_ImplOpenGL3_RenderDrawData(ImGui.GetDrawData());

            if ((io.ConfigFlags & ImGuiConfigFlags.ViewportsEnable) > 0)
            {
                GLFW.Window backup_current_context = GLFW.Glfw.CurrentContext;
                ImGui.UpdatePlatformWindows();
                ImGui.RenderPlatformWindowsDefault();
                GLFW.Glfw.MakeContextCurrent(backup_current_context);
            }
        }
Пример #2
0
        public unsafe override void OnAttach()
        {
            ImGuiContext = ImGui.CreateContext();
            //ImGui.SetCurrentContext(context);
            ImGuizmo.SetImGuiContext(ImGuiContext);

            Application app = Application.Instance;

            GLFW.Window windowHandle = app.Window.Handle;

            if (ImGuiController.ImGui_ImplGlfw_InitForOpenGL(windowHandle, true))
            {
                Log.Core.Info("ImGui GLFW part initialized");
            }
            if (ImGuiController.ImGui_ImplOpenGL3_Init("#version 330 core"))
            {
                Log.Core.Info("ImGui OpenGL part initialized");
            }

            ImGuiIOPtr io = ImGui.GetIO();

            io.DisplaySize = new Vector2(
                app.Window.Width / Vector2.One.X,
                app.Window.Height / Vector2.One.Y);
            io.DisplayFramebufferScale = Vector2.One;
            io.DeltaTime = 1.0f / 60.0f;

            // base theme
            //ImGui.StyleColorsClassic();
            //ImGui.StyleColorsLight();
            ImGui.StyleColorsDark();
            SetDarkThemeColors();

            io.ConfigFlags |= ImGuiConfigFlags.DockingEnable;

            //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
            ////io.ConfigFlags |= ImGuiConfigFlags.ViewportsNoTaskBarIcons;
            ////io.ConfigFlags |= ImGuiConfigFlags.ViewportsNoMerge;

            //io.BackendFlags |= ImGuiBackendFlags.HasMouseCursors;
            //io.BackendFlags |= ImGuiBackendFlags.HasSetMousePos;



            //io.Fonts.AddFontDefault(io.Fonts.AddFontFromFileTTF(FileEnvironment.ResourceFolder + "fonts/consola.ttf", 16.0f, null, io.Fonts.GetGlyphRangesChineseSimplifiedCommon()).ConfigData);

            //ImFontAtlasPtr fonts = ImGui.GetIO().Fonts;
            //io.Fonts.AddFontDefault();
            //io.Fonts.AddFontFromFileTTF(FileEnvironment.ResourceFolder + "fonts/arial.ttf", 18.0f);
            //io.Fonts.AddFontDefault(io.Fonts.AddFontFromFileTTF(FileEnvironment.ResourceFolder + "fonts/arial.ttf", 18.0f).ConfigData); //io.FontDefault = io.Fonts.AddFontFromFileTTF(FileEnvironment.ResourceFolder + "fonts/arial.ttf", 18.0f);
            //
            //
            //
            //ImGuiStylePtr style = ImGui.GetStyle();
            //if ((io.ConfigFlags & ImGuiConfigFlags.ViewportsEnable) > 0)
            //{
            //    style.WindowRounding = 0.0f;
            //    style.Colors[(int)ImGuiCol.WindowBg].W = 1.0f;
            //}
            //
        }