Пример #1
0
        private unsafe void PlatformCreateWindow(ImGuiViewportPtr viewport)
        {
#if DEBUG
            using Profiler fullProfiler = new Profiler(GetType());
#endif
            SDL_WindowFlags sdlFlags = (Sdl2Native.SDL_GetWindowFlags(mainWindow.SdlWindow.SdlWindowHandle) & SDL_WindowFlags.AllowHighDpi)
                                       | SDL_WindowFlags.Hidden;
            sdlFlags |= ((viewport.Flags & ImGuiViewportFlags.NoDecoration) != 0) ? SDL_WindowFlags.Borderless : SDL_WindowFlags.Resizable;

            if (graphicsDevice.BackendType == GraphicsBackend.OpenGL || graphicsDevice.BackendType == GraphicsBackend.OpenGLES)
            {
                sdlFlags |= SDL_WindowFlags.OpenGL;
            }
            if ((viewport.Flags & ImGuiViewportFlags.TopMost) != 0)
            {
                sdlFlags |= SDL_WindowFlags.AlwaysOnTop;
            }
            //Seems to work
            if ((viewport.Flags & ImGuiViewportFlags.NoTaskBarIcon) != 0)
            {
                sdlFlags |= SDL_WindowFlags.SkipTaskbar;
            }

            Sdl2Window sdlWindow = new Sdl2Window("Viewport", (int)viewport.Pos.X, (int)viewport.Pos.Y,
                                                  (int)viewport.Size.X, (int)viewport.Size.Y, sdlFlags, false);

            sdlWindow.Resized += () => viewport.PlatformRequestResize = true;
            sdlWindow.Moved   += (_) => viewport.PlatformRequestMove = true;
            sdlWindow.Closed  += () => viewport.PlatformRequestClose = true;

            WindowBase newWindow = WindowBase.CreateSubWindow(graphicsDevice, sdlWindow, mainWindow.GetType());

            viewport.PlatformUserData = (IntPtr)newWindow.GcHandle;
            viewport.PlatformHandle   = newWindow.SdlWindow.Handle;
        }