public ImGuiHelper(Game game) { this.game = game; game.Keyboard.KeyDown += Keyboard_KeyDown; game.Keyboard.KeyUp += Keyboard_KeyUp; game.Keyboard.TextInput += Keyboard_TextInput; SetKeyMappings(); var io = ImGui.GetIO(); unsafe { io.GetNativePointer()->IniFilename = IntPtr.Zero; } Default = io.FontAtlas.AddDefaultFont(); using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.Roboto-Medium.ttf")) { var ttf = new byte[stream.Length]; stream.Read(ttf, 0, ttf.Length); ttfPtr = Marshal.AllocHGlobal(ttf.Length); Marshal.Copy(ttf, 0, ttfPtr, ttf.Length); Noto = io.FontAtlas.AddFontFromMemoryTTF(ttfPtr, ttf.Length, 15); } using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.checkerboard.png")) { checkerboard = LibreLancer.ImageLib.Generic.FromStream(stream); CheckerboardId = RegisterTexture(checkerboard); } using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LancerEdit.UILib.circle.png")) { circle = LibreLancer.ImageLib.Generic.FromStream(stream); CircleId = RegisterTexture(circle); } unsafe { ImGuiExt.BuildFontAtlas((IntPtr)ImGuiNative.igGetIO()->FontAtlas); } FontTextureData texData = io.FontAtlas.GetTexDataAsAlpha8(); fontTexture = new Texture2D(texData.Width, texData.Height, false, SurfaceFormat.R8); var bytes = new byte[texData.Width * texData.Height * texData.BytesPerPixel]; unsafe { Marshal.Copy((IntPtr)texData.Pixels, bytes, 0, texData.Width * texData.Height * texData.BytesPerPixel); } fontTexture.SetData(bytes); fontTexture.SetFiltering(TextureFiltering.Linear); io.FontAtlas.SetTexID(FONT_TEXTURE_ID); io.FontAtlas.ClearTexData(); textShader = new Shader(vertex_source, text_fragment_source); colorShader = new Shader(vertex_source, color_fragment_source); dot = new Texture2D(1, 1, false, SurfaceFormat.Color); var c = new Color4b[] { Color4b.White }; dot.SetData(c); Theme.Apply(); }