Я создаю приложение C#, используя Imgui и Veldrid, где окно imgui действует как самой основной окно применения. Чтобы сделать это, я отключил границу окна и внедрил пользовательскую функцию перетаскивания для перемещения окна. Новая позиция не сохранена правильно для последующих перетаскиваний. < /P>
using System;
using System.Numerics;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ImGuiNET;
using Veldrid;
using Veldrid.Sdl2;
using Veldrid.StartupUtilities;
internal static class Program
{
// P/Invoke bindings
[DllImport("SDL2", CallingConvention = CallingConvention.Cdecl)]
private static extern uint SDL_GetGlobalMouseState(out int x, out int y);
[DllImport("SDL2", CallingConvention = CallingConvention.Cdecl)]
private static extern int SDL_CaptureMouse(bool enabled);
static Sdl2Window _window;
static GraphicsDevice _gd;
static CommandList _cl;
static ImGuiRenderer _imgui;
static int _counter = 0;
static int _choice = 0;
static readonly string[] _items = { "Item 1", "Item 2", "Item 3" };
static float _volume = 0.5f;
static string _name = "Test";
static bool _isDragging = false;
static bool _prevLeftDown = false;
static Vector2 _dragStartMouseGlobal;
static Vector2 _dragStartWindowPos;
static void Main()
{
var wci = new WindowCreateInfo(0, 0, 500, 500, WindowState.Normal, "1st ImGUI Program");
VeldridStartup.CreateWindowAndGraphicsDevice(
wci,
new GraphicsDeviceOptions(debug: false, swapchainDepthFormat: null, syncToVerticalBlank: true),
out _window,
out _gd);
_window.BorderVisible = false;
_window.Resizable = true;
_cl = _gd.ResourceFactory.CreateCommandList();
_imgui = new ImGuiRenderer(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height);
_window.Resized += () =>
{
_gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height);
_imgui.WindowResized(_window.Width, _window.Height);
};
ImGui.StyleColorsDark();
ImGui.GetStyle().WindowRounding = 0f;
var sw = Stopwatch.StartNew();
long lastTicks = sw.ElapsedTicks;
while (_window.Exists)
{
var snapshot = _window.PumpEvents();
if (!_window.Exists) break;
long nowTicks = sw.ElapsedTicks;
float dt = (nowTicks - lastTicks) / (float)Stopwatch.Frequency;
if (dt
Подробнее здесь: https://stackoverflow.com/questions/797 ... after-drag