using Echo.Core.Common.Packed; using Echo.UserInterface.Backend; using ImGuiNET; using SDL2; using SDL2Demo; using System; using System.Collections.Generic; using System.Linq; using System.Numerics; using System.Text; using System.Threading.Tasks; using skyscraper8.Skyscraper.Drawing; using testdrid.SdlWrapper; namespace skyscraper8.UI.ImGuiForms { internal abstract class SdlWindow : IRenderable { protected readonly Vector2 _size; protected readonly Texture _texture; protected readonly string title; protected SdlWindow(ImGuiDevice imGuiDevice, int width, int height, string title = "SDL Window") { IntPtr textureIntPtr = imGuiDevice.CreateTexture(new Int2(width, height), true, !BitConverter.IsLittleEndian); _texture = Texture.FromIntPointer(textureIntPtr); _size = new Vector2(_texture.GetWidth(), _texture.GetHeight()); this.title = title; } public void Render() { _texture.Lock(); RenderInternal(_texture); _texture.Unlock(); ImGuiNET.ImGui.PushStyleVar(ImGuiStyleVar.WindowMinSize, new Vector2(_texture.GetWidth() + 16, _texture.GetHeight() + 16)); ImGuiNET.ImGui.Begin(title); ImGuiNET.ImGui.Image(_texture.Pointer, _size); ImGuiNET.ImGui.End(); ImGuiNET.ImGui.PopStyleVar(); } protected abstract void RenderInternal(Texture surface); } }