Exemplo n.º 1
0
        private unsafe void AddFont(string fileName, ref ImFontPtr fontPtr)
        {
            string fontFile = fileName;
            string fontPath = Path.Combine(dllPath, fontFile);

            ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

            fontConfig.MergeMode  = true;
            fontConfig.PixelSnapH = false;

            var gameRangeHandle = GCHandle.Alloc(new ushort[]
            {
                0xE016,
                0xf739,
                0
            }, GCHandleType.Pinned);

            var gameRangeHandle2 = GCHandle.Alloc(new ushort[]
            {
                0x2013,
                0x303D,
                0
            }, GCHandleType.Pinned);

            fontPtr = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, config.FontSize);
            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, config.FontSize, fontConfig, gameRangeHandle.AddrOfPinnedObject());
            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, config.FontSize, fontConfig, gameRangeHandle2.AddrOfPinnedObject());


            fontConfig.Destroy();
            gameRangeHandle.Free();
            gameRangeHandle2.Free();
        }
Exemplo n.º 2
0
        public static void AddFontFromFileTTF(string filename,
                                              float sizePixels,
                                              char[] glyphRanges)
        {
            unsafe
            {
                ImFontConfigPtr nativeConfig = ImGuiNative.ImFontConfig_ImFontConfig();
                nativeConfig.MergeMode  = true;
                nativeConfig.PixelSnapH = true;

                GCHandle rangeHandle = GCHandle.Alloc(new ushort[]
                {
                    glyphRanges[0], glyphRanges[1], 0
                }, GCHandleType.Pinned);
                try
                {
                    ImGui.GetIO().Fonts.AddFontFromFileTTF(filename, sizePixels, nativeConfig,
                                                           rangeHandle.AddrOfPinnedObject());
                    ImGui.GetIO().Fonts.Build();
                }
                finally
                {
                    ImGuiNative.ImFontConfig_destroy(nativeConfig);
                    if (rangeHandle.IsAllocated)
                    {
                        rangeHandle.Free();
                    }
                }
            }
        }
Exemplo n.º 3
0
        private unsafe void SetupFonts()
        {
            this.fontBuildSignal.Reset();

            ImGui.GetIO().Fonts.Clear();

            ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

            fontConfig.MergeMode  = true;
            fontConfig.PixelSnapH = true;

            var fontPathJp = Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "NotoSansCJKjp-Medium.otf");

            var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);

            DefaultFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, japaneseRangeHandle.AddrOfPinnedObject());

            var fontPathGame = Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "gamesym.ttf");

            var gameRangeHandle = GCHandle.Alloc(new ushort[]
            {
                0xE020,
                0xE0DB,
                0
            }, GCHandleType.Pinned);

            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathGame, 17.0f, fontConfig, gameRangeHandle.AddrOfPinnedObject());

            var fontPathIcon = Path.Combine(this.dalamud.AssetDirectory.FullName, "UIRes", "FontAwesome5FreeSolid.otf");

            var iconRangeHandle = GCHandle.Alloc(new ushort[]
            {
                0xE000,
                0xF8FF,
                0
            }, GCHandleType.Pinned);

            IconFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathIcon, 17.0f, null, iconRangeHandle.AddrOfPinnedObject());

            Log.Verbose("[FONT] Invoke OnBuildFonts");
            this.OnBuildFonts?.Invoke();
            Log.Verbose("[FONT] OnBuildFonts OK!");

            for (var i = 0; i < ImGui.GetIO().Fonts.Fonts.Size; i++)
            {
                Log.Verbose("{0} - {1}", i, ImGui.GetIO().Fonts.Fonts[i].GetDebugName());
            }

            ImGui.GetIO().Fonts.Build();

            Log.Verbose("[FONT] Fonts built!");

            this.fontBuildSignal.Set();

            fontConfig.Destroy();
            japaneseRangeHandle.Free();
            gameRangeHandle.Free();
            iconRangeHandle.Free();
        }
        private static unsafe void SetupFullscreenStyle(SimpleImGuiScene scene)
        {
            scene.Renderer.ClearColor = new Vector4(0, 0, 0, 0);

            ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

            fontConfig.MergeMode  = true;
            fontConfig.PixelSnapH = true;

            const string fontPathJp = @"NotoSansCJKjp-Medium.otf";

            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, ImGui.GetIO().Fonts.GetGlyphRangesJapanese());

            const string fontPathGame = @"gamesym.ttf";

            GCHandle rangeHandle = GCHandle.Alloc(
                new ushort[]
            {
                0xE020,
                0xE0DB,
                0
            },
                GCHandleType.Pinned);

            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathGame, 17.0f, fontConfig, rangeHandle.AddrOfPinnedObject());
            ImGui.GetIO().Fonts.Build();
            fontConfig.Destroy();
            rangeHandle.Free();

            ImGui.GetStyle().GrabRounding             = 3f;
            ImGui.GetStyle().FrameRounding            = 4f;
            ImGui.GetStyle().WindowRounding           = 4f;
            ImGui.GetStyle().WindowBorderSize         = 0f;
            ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Right;
            ImGui.GetStyle().ScrollbarSize            = 16f;

            ImGui.GetStyle().Colors[(int)ImGuiCol.WindowBg]          = new Vector4(0.06f, 0.06f, 0.06f, 0.87f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBg]           = new Vector4(0.29f, 0.29f, 0.29f, 0.54f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgHovered]    = new Vector4(0.54f, 0.54f, 0.54f, 0.40f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgActive]     = new Vector4(0.64f, 0.64f, 0.64f, 0.67f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.TitleBgActive]     = new Vector4(0.29f, 0.29f, 0.29f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.CheckMark]         = new Vector4(0.86f, 0.86f, 0.86f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrab]        = new Vector4(0.54f, 0.54f, 0.54f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrabActive]  = new Vector4(0.67f, 0.67f, 0.67f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.Button]            = new Vector4(0.71f, 0.71f, 0.71f, 0.40f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]     = new Vector4(0.47f, 0.47f, 0.47f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonActive]      = new Vector4(0.74f, 0.74f, 0.74f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.Header]            = new Vector4(0.59f, 0.59f, 0.59f, 0.31f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderHovered]     = new Vector4(0.50f, 0.50f, 0.50f, 0.80f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderActive]      = new Vector4(0.60f, 0.60f, 0.60f, 1.00f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGrip]        = new Vector4(0.79f, 0.79f, 0.79f, 0.25f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripHovered] = new Vector4(0.78f, 0.78f, 0.78f, 0.67f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripActive]  = new Vector4(0.88f, 0.88f, 0.88f, 0.95f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.Tab]        = new Vector4(0.23f, 0.23f, 0.23f, 0.86f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.TabHovered] = new Vector4(0.71f, 0.71f, 0.71f, 0.80f);
            ImGui.GetStyle().Colors[(int)ImGuiCol.TabActive]  = new Vector4(0.36f, 0.36f, 0.36f, 1.00f);
        }
Exemplo n.º 5
0
    public unsafe void SetupFonts()
    {
        var ioFonts = ImGui.GetIO().Fonts;

        ImGui.GetIO().Fonts.Clear();

        ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

        fontConfig.PixelSnapH = true;

        var fontDataText  = AppUtil.GetEmbeddedResourceBytes("NotoSansCJKjp-Regular.otf");
        var fontDataIcons = AppUtil.GetEmbeddedResourceBytes("FontAwesome5FreeSolid.otf");

        var fontDataTextPtr = Marshal.AllocHGlobal(fontDataText.Length);

        Marshal.Copy(fontDataText, 0, fontDataTextPtr, fontDataText.Length);

        var fontDataIconsPtr = Marshal.AllocHGlobal(fontDataIcons.Length);

        Marshal.Copy(fontDataIcons, 0, fontDataIconsPtr, fontDataIcons.Length);

        var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);

        const float FONT_SIZE = 20.0f;

        TextFont = ioFonts.AddFontFromMemoryTTF(fontDataTextPtr, fontDataText.Length, FONT_SIZE, null, japaneseRangeHandle.AddrOfPinnedObject());

        var iconRangeHandle = GCHandle.Alloc(
            new ushort[]
        {
            0xE000,
            0xF8FF,
            0,
        },
            GCHandleType.Pinned);

        IconFont = ioFonts.AddFontFromMemoryTTF(fontDataIconsPtr, fontDataIcons.Length, FONT_SIZE, fontConfig, iconRangeHandle.AddrOfPinnedObject());

        ioFonts.Build();

        if (Math.Abs(FONT_GAMMA - 1.0f) >= 0.001)
        {
            // Gamma correction (stbtt/FreeType would output in linear space whereas most real world usages will apply 1.4 or 1.8 gamma; Windows/XIV prebaked uses 1.4)
            ioFonts.GetTexDataAsRGBA32(out byte *texPixels, out var texWidth, out var texHeight);
            for (int i = 3, j = texWidth * texHeight * 4; i < j; i += 4)
            {
                texPixels[i] = (byte)(Math.Pow(texPixels[i] / 255.0f, 1.0f / FONT_GAMMA) * 255.0f);
            }
        }

        fontConfig.Destroy();
        japaneseRangeHandle.Free();
        iconRangeHandle.Free();
    }
Exemplo n.º 6
0
 /// <summary>
 /// Method responsible for loading custom fonts.
 /// The order in which fonts are provided matters!
 /// </summary>
 /// <param name="gd"> Main graphics device </param>
 /// <param name="fontInfos">Information on the specifics of each font to be loaded</param>
 public void LoadFonts(GraphicsDevice gd, bool replaceExistingFonts, ImGuiFontInfo[] fontInfos)
 {
     unsafe
     {
         ImFontConfigPtr iconConfig = ImGuiNative.ImFontConfig_ImFontConfig();
         iconConfig.OversampleH        = 3;
         iconConfig.OversampleV        = 3;
         iconConfig.RasterizerMultiply = 1f;
         iconConfig.GlyphExtraSpacing  = Vector2.Zero;
         iconConfig.PixelSnapH         = true;
         var io = ImGui.GetIO();
         try
         {
             if (replaceExistingFonts)
             {
                 io.Fonts.Clear();
             }
             foreach (var fontInfo in fontInfos)
             {
                 iconConfig.MergeMode = fontInfo.MergeMode;
                 if (fontInfo.IsIconFont)
                 {
                     GCHandle rangeHandle = GCHandle.Alloc(fontInfo.Ranges, GCHandleType.Pinned);
                     try
                     {
                         io.Fonts.AddFontFromFileTTF(fontInfo.Path, fontInfo.Size, iconConfig, rangeHandle.AddrOfPinnedObject());
                     }
                     finally
                     {
                         if (rangeHandle.IsAllocated)
                         {
                             rangeHandle.Free();
                         }
                     }
                 }
                 else
                 {
                     io.Fonts.AddFontFromFileTTF(fontInfo.Path, fontInfo.Size);
                 }
             }
         }
         catch
         {
             io.Fonts.AddFontDefault();
         }
         finally
         {
             ImGuiNative.ImFontConfig_destroy(iconConfig);
         }
         RecreateFontDeviceTexture(gd);
     }
     fontTextureResourceSet = gd.ResourceFactory.CreateResourceSet(new ResourceSetDescription(textureLayout, fontTextureView));
 }
Exemplo n.º 7
0
        private unsafe void UiBuilderOnBuildFonts()
        {
            var fontPath = Path.Combine(PluginInterface.AssemblyLocation.DirectoryName !, "Fonts", "Miedinger W01 Regular.ttf");

            ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

            fontConfig.MergeMode  = false;
            fontConfig.PixelSnapH = false;

            _pluginConfiguration.NumberFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, 48f, fontConfig);

            fontConfig.Destroy();
        }
        public void SetFrom(ImFontConfigPtr im)
        {
            FontIndexInFile    = im.FontNo;
            SizeInPixels       = im.SizePixels;
            Oversample         = new Vector2Int(im.OversampleH, im.OversampleV);
            PixelSnapH         = im.PixelSnapH;
            GlyphExtraSpacing  = im.GlyphExtraSpacing;
            GlyphOffset        = im.GlyphOffset;
            GlyphMinAdvanceX   = im.GlyphMinAdvanceX;
            GlyphMaxAdvanceX   = im.GlyphMaxAdvanceX;
            MergeIntoPrevious  = im.MergeMode;
            RasterizerFlags    = im.RasterizerFlags;
            RasterizerMultiply = im.RasterizerMultiply;
            EllipsisChar       = (char)im.EllipsisChar;

            // no good way to set GlyphRanges, do manually
        }
Exemplo n.º 9
0
        private unsafe void SetupFonts()
        {
            ImGui.GetIO().Fonts.Clear();

            ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

            fontConfig.MergeMode  = true;
            fontConfig.PixelSnapH = true;

            var fontPathJp = Path.Combine(this.dalamud.StartInfo.WorkingDirectory, "UIRes", "NotoSansCJKjp-Medium.otf");

            var japaneseRangeHandle = GCHandle.Alloc(GlyphRangesJapanese.GlyphRanges, GCHandleType.Pinned);

            DefaultFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, japaneseRangeHandle.AddrOfPinnedObject());

            var fontPathGame = Path.Combine(this.dalamud.StartInfo.WorkingDirectory, "UIRes", "gamesym.ttf");

            var gameRangeHandle = GCHandle.Alloc(new ushort[]
            {
                0xE020,
                0xE0DB,
                0
            }, GCHandleType.Pinned);

            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathGame, 17.0f, fontConfig, gameRangeHandle.AddrOfPinnedObject());

            var fontPathIcon = Path.Combine(this.dalamud.StartInfo.WorkingDirectory, "UIRes", "FontAwesome5FreeSolid.otf");

            var iconRangeHandle = GCHandle.Alloc(new ushort[]
            {
                0xE000,
                0xF8FF,
                0
            }, GCHandleType.Pinned);

            IconFont = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathIcon, 17.0f, null, iconRangeHandle.AddrOfPinnedObject());

            this.OnBuildFonts?.Invoke();

            ImGui.GetIO().Fonts.Build();

            fontConfig.Destroy();
            japaneseRangeHandle.Free();
            gameRangeHandle.Free();
            iconRangeHandle.Free();
        }
Exemplo n.º 10
0
        public void CreateScene(string iniPath = null)
        {
            this.scene = new SimpleImGuiScene(RendererFactory.RendererBackend.OpenGL3, new WindowCreateInfo
            {
                Title            = "ImGui Overlay",
                Fullscreen       = true,
                TransparentColor = new float[] { 0, 0, 0, 0 },
            })
            {
                ImGuiIniPath = iniPath,
            };

            this.scene.Renderer.ClearColor = new Vector4(0, 0, 0, 0);

            this.scene.OnBuildUI += OnBuildUi;

            unsafe
            {
                ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
                fontConfig.GlyphExtraSpacing.X = 0.5f;

                var io = ImGui.GetIO();

                var defaultFontStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("IslandUniverse.Assets.Roboto-Regular.ttf");
                var dfIntPtr          = Marshal.AllocHGlobal((int)defaultFontStream.Length);
                var defaultFont       = new UnmanagedMemoryStream((byte *)dfIntPtr.ToPointer(), defaultFontStream.Length, defaultFontStream.Length, FileAccess.Write);
                defaultFontStream.CopyTo(defaultFont);

                // ImGui's font upscaling is pretty bad, so we add some larger versions in advance.
                var fontPtr1 = io.Fonts.AddFontFromMemoryTTF(dfIntPtr, 13, 13f, fontConfig);
                this.Fonts.Add("Roboto Regular 13px", fontPtr1);
                var fontPtr2 = io.Fonts.AddFontFromMemoryTTF(dfIntPtr, 18, 18f, fontConfig);
                this.Fonts.Add("Roboto Regular 18px", fontPtr2);
                var fontPtr3 = io.Fonts.AddFontFromMemoryTTF(dfIntPtr, 24, 24f, fontConfig);
                this.Fonts.Add("Roboto Regular 24px", fontPtr3);

                io.Fonts.Build();

                fontConfig.Destroy();
            }

            SetUiStyle(DefaultUiStyle);

            this.scene.Run();
        }
        public void ApplyTo(ImFontConfigPtr im)
        {
            im.FontNo             = FontIndexInFile;
            im.SizePixels         = SizeInPixels;
            im.OversampleH        = Oversample.x;
            im.OversampleV        = Oversample.y;
            im.PixelSnapH         = PixelSnapH;
            im.GlyphExtraSpacing  = GlyphExtraSpacing;
            im.GlyphOffset        = GlyphOffset;
            im.GlyphMinAdvanceX   = GlyphMinAdvanceX;
            im.GlyphMaxAdvanceX   = GlyphMaxAdvanceX;
            im.MergeMode          = MergeIntoPrevious;
            im.RasterizerFlags    = RasterizerFlags;
            im.RasterizerMultiply = RasterizerMultiply;
            im.EllipsisChar       = EllipsisChar;

            // setting GlyphRanges requires allocating memory so it is not done here
            // use BuildRanges to get a List with the values, then allocate memory and copy
            // (see TextureManager)
        }
Exemplo n.º 12
0
        private unsafe void UpdateFont()
        {
            string fontFile = "XIVfree.ttf";
            string fontPath = Path.Combine(dllPath, fontFile);

            ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();

            fontConfig.MergeMode  = true;
            fontConfig.PixelSnapH = false;

            var gameRangeHandle = GCHandle.Alloc(new ushort[]
            {
                0xE016,
                0xf739,
                0
            }, GCHandleType.Pinned);

            var gameRangeHandle2 = GCHandle.Alloc(new ushort[]
            {
                0x2013,
                0x303D,
                0
            }, GCHandleType.Pinned);

            var fontPathJp = Path.Combine(Directory.GetParent(Directory.GetParent(Directory.GetParent(dllPath).ToString()).ToString()).ToString(), "addon", "Hooks", "UIRes", "NotoSansCJKjp-Medium.otf");

            font = ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, (float)fontsize, fontConfig);
            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, (float)fontsize, fontConfig, gameRangeHandle.AddrOfPinnedObject());
            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPath, (float)fontsize, fontConfig, gameRangeHandle2.AddrOfPinnedObject());
            ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, (float)fontsize, fontConfig, ImGui.GetIO().Fonts.GetGlyphRangesJapanese());


            fontConfig.Destroy();
            gameRangeHandle.Free();
            gameRangeHandle2.Free();

            pluginInterface.UiBuilder.RebuildFonts();
            skipfont = true;
        }
Exemplo n.º 13
0
        unsafe public MapStudioNew()
        {
            CFG.AttemptLoadOrDefault();

            if (UseRenderdoc)
            {
                RenderDoc.Load(out RenderDocManager);
                RenderDocManager.OverlayEnabled = false;
            }

            WindowCreateInfo windowCI = new WindowCreateInfo
            {
                X                  = CFG.Current.GFX_Display_X,
                Y                  = CFG.Current.GFX_Display_Y,
                WindowWidth        = CFG.Current.GFX_Display_Width,
                WindowHeight       = CFG.Current.GFX_Display_Height,
                WindowInitialState = WindowState.Maximized,
                WindowTitle        = "Dark Souls Map Studio " + _version + " by Katalash",
            };
            GraphicsDeviceOptions gdOptions = new GraphicsDeviceOptions(false, PixelFormat.R32_Float, true, ResourceBindingModel.Improved, true, true, _colorSrgb);

#if DEBUG
            gdOptions.Debug = true;
#endif

            VeldridStartup.CreateWindowAndGraphicsDevice(
                windowCI,
                gdOptions,
                //VeldridStartup.GetPlatformDefaultBackend(),
                //GraphicsBackend.Metal,
                GraphicsBackend.Vulkan,

                //GraphicsBackend.Direct3D11,
                //GraphicsBackend.OpenGL,
                //GraphicsBackend.OpenGLES,
                out _window,
                out _gd);
            _window.Resized += () => _windowResized = true;
            _window.Moved   += (p) => _windowMoved = true;

            Sdl2Native.SDL_Init(SDLInitFlags.GameController);
            //Sdl2ControllerTracker.CreateDefault(out _controllerTracker);

            var factory = _gd.ResourceFactory;
            TextureSamplerResourceLayout = factory.CreateResourceLayout(new ResourceLayoutDescription(
                                                                            new ResourceLayoutElementDescription("SourceTexture", ResourceKind.TextureReadOnly, ShaderStages.Fragment),
                                                                            new ResourceLayoutElementDescription("SourceSampler", ResourceKind.Sampler, ShaderStages.Fragment)));

            Scene.Renderer.Initialize(_gd);

            ImguiRenderer = new ImGuiRenderer(_gd, _gd.SwapchainFramebuffer.OutputDescription, CFG.Current.GFX_Display_Width,
                                              CFG.Current.GFX_Display_Height, ColorSpaceHandling.Legacy);
            MainWindowCommandList = factory.CreateCommandList();
            GuiCommandList        = factory.CreateCommandList();

            _assetLocator = new AssetLocator();
            MSBEditor     = new MsbEditor.MsbEditorScreen(_window, _gd, _assetLocator);
            ModelEditor   = new MsbEditor.ModelEditorScreen(_window, _gd, _assetLocator);
            ParamEditor   = new MsbEditor.ParamEditorScreen(_window, _gd);
            TextEditor    = new MsbEditor.TextEditorScreen(_window, _gd);

            MsbEditor.ParamBank.LoadParams(_assetLocator);
            MsbEditor.FMGBank.LoadFMGs(_assetLocator);
            MsbEditor.MtdBank.LoadMtds(_assetLocator);

            ImGui.GetIO().ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard;
            var fonts    = ImGui.GetIO().Fonts;
            var fileJp   = Path.Combine(AppContext.BaseDirectory, $@"Assets\Fonts\NotoSansCJKtc-Light.otf");
            var fontJp   = File.ReadAllBytes(fileJp);
            var fileEn   = Path.Combine(AppContext.BaseDirectory, $@"Assets\Fonts\RobotoMono-Light.ttf");
            var fontEn   = File.ReadAllBytes(fileEn);
            var fileIcon = Path.Combine(AppContext.BaseDirectory, $@"Assets\Fonts\forkawesome-webfont.ttf");
            var fontIcon = File.ReadAllBytes(fileIcon);
            //fonts.AddFontFromFileTTF($@"Assets\Fonts\NotoSansCJKtc-Medium.otf", 20.0f, null, fonts.GetGlyphRangesJapanese());
            fonts.Clear();
            fixed(byte *p = fontEn)
            {
                var ptr = ImGuiNative.ImFontConfig_ImFontConfig();
                var cfg = new ImFontConfigPtr(ptr);

                cfg.GlyphMinAdvanceX = 5.0f;
                cfg.OversampleH      = 5;
                cfg.OversampleV      = 5;
                var f = fonts.AddFontFromMemoryTTF((IntPtr)p, fontEn.Length, 14.0f, cfg, fonts.GetGlyphRangesDefault());
            }

            fixed(byte *p = fontJp)
            {
                var ptr = ImGuiNative.ImFontConfig_ImFontConfig();
                var cfg = new ImFontConfigPtr(ptr);

                cfg.MergeMode        = true;
                cfg.GlyphMinAdvanceX = 7.0f;
                cfg.OversampleH      = 5;
                cfg.OversampleV      = 5;
                var f = fonts.AddFontFromMemoryTTF((IntPtr)p, fontJp.Length, 16.0f, cfg, fonts.GetGlyphRangesJapanese());
            }

            fixed(byte *p = fontIcon)
            {
                ushort[] ranges = { ForkAwesome.IconMin, ForkAwesome.IconMax, 0 };
                var      ptr    = ImGuiNative.ImFontConfig_ImFontConfig();
                var      cfg    = new ImFontConfigPtr(ptr);

                cfg.MergeMode        = true;
                cfg.GlyphMinAdvanceX = 12.0f;
                cfg.OversampleH      = 5;
                cfg.OversampleV      = 5;
                ImFontGlyphRangesBuilder b = new ImFontGlyphRangesBuilder();

                fixed(ushort *r = ranges)
                {
                    var f = fonts.AddFontFromMemoryTTF((IntPtr)p, fontIcon.Length, 16.0f, cfg, (IntPtr)r);
                }
            }

            fonts.Build();
            ImguiRenderer.RecreateFontDeviceTexture();
            ImguiRenderer.OnSetupDone();

            var style = ImGui.GetStyle();
            style.TabBorderSize = 0;

            if (CFG.Current.LastProjectFile != null && CFG.Current.LastProjectFile != "")
            {
                if (File.Exists(CFG.Current.LastProjectFile))
                {
                    var project = MsbEditor.ProjectSettings.Deserialize(CFG.Current.LastProjectFile);
                    AttemptLoadProject(project, CFG.Current.LastProjectFile, false);
                }
            }
        }
Exemplo n.º 14
0
        public static void Init()
        {
            if (_Initialized)
            {
                return;
            }
            _Initialized = true;

            IntPtr context = ImGui.CreateContext();

            ImGui.SetCurrentContext(context);

            ImGuiIOPtr io = ImGui.GetIO();


            io.KeyMap[(int)ImGuiKey.Tab]        = (int)SDL.SDL_Keycode.SDLK_TAB;
            io.KeyMap[(int)ImGuiKey.LeftArrow]  = (int)SDL.SDL_Scancode.SDL_SCANCODE_LEFT;
            io.KeyMap[(int)ImGuiKey.RightArrow] = (int)SDL.SDL_Scancode.SDL_SCANCODE_RIGHT;
            io.KeyMap[(int)ImGuiKey.UpArrow]    = (int)SDL.SDL_Scancode.SDL_SCANCODE_UP;
            io.KeyMap[(int)ImGuiKey.DownArrow]  = (int)SDL.SDL_Scancode.SDL_SCANCODE_DOWN;
            io.KeyMap[(int)ImGuiKey.PageUp]     = (int)SDL.SDL_Scancode.SDL_SCANCODE_PAGEUP;
            io.KeyMap[(int)ImGuiKey.PageDown]   = (int)SDL.SDL_Scancode.SDL_SCANCODE_PAGEDOWN;
            io.KeyMap[(int)ImGuiKey.Home]       = (int)SDL.SDL_Scancode.SDL_SCANCODE_HOME;
            io.KeyMap[(int)ImGuiKey.End]        = (int)SDL.SDL_Scancode.SDL_SCANCODE_END;
            io.KeyMap[(int)ImGuiKey.Delete]     = (int)SDL.SDL_Keycode.SDLK_DELETE;
            io.KeyMap[(int)ImGuiKey.Backspace]  = (int)SDL.SDL_Keycode.SDLK_BACKSPACE;
            io.KeyMap[(int)ImGuiKey.Enter]      = (int)SDL.SDL_Keycode.SDLK_RETURN;
            io.KeyMap[(int)ImGuiKey.Escape]     = (int)SDL.SDL_Keycode.SDLK_ESCAPE;
            io.KeyMap[(int)ImGuiKey.A]          = (int)SDL.SDL_Keycode.SDLK_a;
            io.KeyMap[(int)ImGuiKey.C]          = (int)SDL.SDL_Keycode.SDLK_c;
            io.KeyMap[(int)ImGuiKey.V]          = (int)SDL.SDL_Keycode.SDLK_v;
            io.KeyMap[(int)ImGuiKey.X]          = (int)SDL.SDL_Keycode.SDLK_x;
            io.KeyMap[(int)ImGuiKey.Y]          = (int)SDL.SDL_Keycode.SDLK_y;
            io.KeyMap[(int)ImGuiKey.Z]          = (int)SDL.SDL_Keycode.SDLK_z;


            //io.GetClipboardTextFn((userData) => SDL.SDL_GetClipboardText());

            //io.SetSetClipboardTextFn((userData, text) => SDL.SDL_SetClipboardText(text));


            unsafe
            {
                string         rf        = "Resources";
                ImFontAtlasPtr fontAtlas = ImGui.GetIO().Fonts;
                var            builder   = new ImFontGlyphRangesBuilderPtr(ImGuiNative.ImFontGlyphRangesBuilder_ImFontGlyphRangesBuilder());
                builder.AddText("Ωων");
                //builder.AddRanges(fontAtlas.GetGlyphRangesDefault());
                builder.BuildRanges(out ImVector ranges);
                fontAtlas.AddFontFromFileTTF(Path.Combine(rf, "ProggyClean.ttf"), 13);
                ImFontConfig *  rawPtr = ImGuiNative.ImFontConfig_ImFontConfig();
                ImFontConfigPtr config = new ImFontConfigPtr(rawPtr);
                config.MergeMode = true;
                fontAtlas.AddFontFromFileTTF(Path.Combine(rf, "DejaVuSans.ttf"), 13, config, ranges.Data);
            }

            if (io.Fonts.Fonts.Size == 0)
            {
                io.Fonts.AddFontDefault();
            }
        }
Exemplo n.º 15
0
        public static unsafe void Inititalize(IPluginUIMock pluginUI)
        {
            // you can edit this if you want more control over things
            // mainly if you want a regular window instead of transparent overlay
            // Typically you don't want to change any colors here if you keep the fullscreen overlay
            using (var scene = new SimpleImGuiScene(RendererFactory.RendererBackend.DirectX11, new WindowCreateInfo
            {
                Title = "UI Test",
                Fullscreen = true,
                TransparentColor = new float[] { 0, 0, 0 },
            }))
            {
                // the background color of your window - typically don't change this for fullscreen overlays
                scene.Renderer.ClearColor = new Vector4(0, 0, 0, 0);

                // this just makes the application quit if you hit escape
                scene.Window.OnSDLEvent += (ref SDL_Event sdlEvent) =>
                {
                    if (sdlEvent.type == SDL_EventType.SDL_KEYDOWN && sdlEvent.key.keysym.scancode == SDL_Scancode.SDL_SCANCODE_ESCAPE)
                    {
                        scene.ShouldQuit = true;
                    }
                };

                // all of this is taken straight from dalamud

                ImFontConfigPtr fontConfig = ImGuiNative.ImFontConfig_ImFontConfig();
                fontConfig.MergeMode  = true;
                fontConfig.PixelSnapH = true;

                var fontPathJp = @"NotoSansCJKjp-Medium.otf";
                ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathJp, 17.0f, null, ImGui.GetIO().Fonts.GetGlyphRangesJapanese());

                var fontPathGame = @"gamesym.ttf";

                var rangeHandle = GCHandle.Alloc(new ushort[]
                {
                    0xE020,
                    0xE0DB,
                    0
                }, GCHandleType.Pinned);


                ImGui.GetIO().Fonts.AddFontFromFileTTF(fontPathGame, 17.0f, fontConfig, rangeHandle.AddrOfPinnedObject());

                ImGui.GetIO().Fonts.Build();

                fontConfig.Destroy();
                rangeHandle.Free();


                ImGui.GetStyle().GrabRounding             = 3f;
                ImGui.GetStyle().FrameRounding            = 4f;
                ImGui.GetStyle().WindowRounding           = 4f;
                ImGui.GetStyle().WindowBorderSize         = 0f;
                ImGui.GetStyle().WindowMenuButtonPosition = ImGuiDir.Right;
                ImGui.GetStyle().ScrollbarSize            = 16f;

                ImGui.GetStyle().Colors[(int)ImGuiCol.WindowBg]          = new Vector4(0.06f, 0.06f, 0.06f, 0.87f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBg]           = new Vector4(0.29f, 0.29f, 0.29f, 0.54f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgHovered]    = new Vector4(0.54f, 0.54f, 0.54f, 0.40f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.FrameBgActive]     = new Vector4(0.64f, 0.64f, 0.64f, 0.67f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TitleBgActive]     = new Vector4(0.29f, 0.29f, 0.29f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.CheckMark]         = new Vector4(0.86f, 0.86f, 0.86f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrab]        = new Vector4(0.54f, 0.54f, 0.54f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.SliderGrabActive]  = new Vector4(0.67f, 0.67f, 0.67f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Button]            = new Vector4(0.71f, 0.71f, 0.71f, 0.40f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonHovered]     = new Vector4(0.47f, 0.47f, 0.47f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ButtonActive]      = new Vector4(0.74f, 0.74f, 0.74f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Header]            = new Vector4(0.59f, 0.59f, 0.59f, 0.31f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderHovered]     = new Vector4(0.50f, 0.50f, 0.50f, 0.80f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.HeaderActive]      = new Vector4(0.60f, 0.60f, 0.60f, 1.00f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGrip]        = new Vector4(0.79f, 0.79f, 0.79f, 0.25f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripHovered] = new Vector4(0.78f, 0.78f, 0.78f, 0.67f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.ResizeGripActive]  = new Vector4(0.88f, 0.88f, 0.88f, 0.95f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.Tab]        = new Vector4(0.23f, 0.23f, 0.23f, 0.86f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TabHovered] = new Vector4(0.71f, 0.71f, 0.71f, 0.80f);
                ImGui.GetStyle().Colors[(int)ImGuiCol.TabActive]  = new Vector4(0.36f, 0.36f, 0.36f, 1.00f);
                // end dalamud copy

                pluginUI.Initialize(scene);

                scene.Run();

                pluginUI.Dispose();
            }
        }
Exemplo n.º 16
0
        public unsafe ImGuiHelper(Game game)
        {
            this.game                = game;
            game.Keyboard.KeyDown   += Keyboard_KeyDown;
            game.Keyboard.KeyUp     += Keyboard_KeyUp;
            game.Keyboard.TextInput += Keyboard_TextInput;
            context = ImGui.CreateContext();
            ImGui.SetCurrentContext(context);
            SetKeyMappings();
            var io = ImGui.GetIO();

            io.WantSaveIniSettings    = false;
            io.NativePtr->IniFilename = (byte *)0; //disable ini!!
            var fontConfigA = new ImFontConfigPtr(ImFontConfig_ImFontConfig());
            var fontConfigB = new ImFontConfigPtr(ImFontConfig_ImFontConfig());
            var fontConfigC = new ImFontConfigPtr(ImFontConfig_ImFontConfig());

            ushort[] glyphRangesFull = new ushort[]
            {
                0x0020, 0x00FF, //Basic Latin + Latin Supplement,
                0x0400, 0x052F, //Cyrillic + Cyrillic Supplement
                0x2DE0, 0x2DFF, //Cyrillic Extended-A
                0xA640, 0xA69F, //Cyrillic Extended-B
                ImGuiExt.ReplacementHash, ImGuiExt.ReplacementHash,
                0
            };
            var rangesPtrFull = Marshal.AllocHGlobal(sizeof(short) * glyphRangesFull.Length);

            for (int i = 0; i < glyphRangesFull.Length; i++)
            {
                ((ushort *)rangesPtrFull)[i] = glyphRangesFull[i];
            }
            ushort[] glyphRangesLatin = new ushort[]
            {
                0x0020, 0x00FF, //Basic Latin + Latin Supplement
                ImGuiExt.ReplacementHash, ImGuiExt.ReplacementHash,
                0
            };
            var rangesPtrLatin = Marshal.AllocHGlobal(sizeof(short) * glyphRangesLatin.Length);

            for (int i = 0; i < glyphRangesLatin.Length; i++)
            {
                ((ushort *)rangesPtrLatin)[i] = glyphRangesLatin[i];
            }
            fontConfigA.GlyphRanges = rangesPtrLatin;
            fontConfigB.GlyphRanges = rangesPtrFull;
            fontConfigC.GlyphRanges = rangesPtrFull;
            Default = io.Fonts.AddFontDefault(fontConfigA);
            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LibreLancer.ImUI.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.Fonts.AddFontFromMemoryTTF(ttfPtr, ttf.Length, 15, fontConfigB);
            }
            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LibreLancer.ImUI.checkerboard.png"))
            {
                checkerboard   = LibreLancer.ImageLib.Generic.FromStream(stream);
                CheckerboardId = RegisterTexture(checkerboard);
            }
            var monospace = Platform.GetMonospaceBytes();

            fixed(byte *mmPtr = monospace)
            {
                SystemMonospace = io.Fonts.AddFontFromMemoryTTF((IntPtr)mmPtr, monospace.Length, 16, fontConfigC);
            }

            ImGuiExt.BuildFontAtlas((IntPtr)io.Fonts.NativePtr);
            byte *fontBytes;
            int   fontWidth, fontHeight;

            io.Fonts.GetTexDataAsAlpha8(out fontBytes, out fontWidth, out fontHeight);
            io.Fonts.TexUvWhitePixel = new Vector2(10, 10);
            fontTexture = new Texture2D(fontWidth, fontHeight, false, SurfaceFormat.R8);
            var bytes = new byte[fontWidth * fontHeight];

            Marshal.Copy((IntPtr)fontBytes, bytes, 0, fontWidth * fontHeight);
            fontTexture.SetData(bytes);
            fontTexture.SetFiltering(TextureFiltering.Linear);
            io.Fonts.SetTexID((IntPtr)FONT_TEXTURE_ID);
            io.Fonts.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();
            //Required for clipboard function on non-Windows platforms
            utf8buf    = Marshal.AllocHGlobal(8192);
            instance   = this;
            setTextDel = SetClipboardText;
            getTextDel = GetClipboardText;

            io.GetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(getTextDel);
            io.SetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(setTextDel);
        }
Exemplo n.º 17
0
        public unsafe ImGuiHelper(Game game, float scale)
        {
            Scale                    = scale;
            this.game                = game;
            game.Keyboard.KeyDown   += Keyboard_KeyDown;
            game.Keyboard.KeyUp     += Keyboard_KeyUp;
            game.Keyboard.TextInput += Keyboard_TextInput;
            context                  = ImGui.CreateContext();
            ImGui.SetCurrentContext(context);
            SetKeyMappings();
            var io = ImGui.GetIO();

            io.WantSaveIniSettings    = false;
            io.NativePtr->IniFilename = (byte *)0; //disable ini!!
            var fontConfigA = new ImFontConfigPtr(ImFontConfig_ImFontConfig());
            var fontConfigB = new ImFontConfigPtr(ImFontConfig_ImFontConfig());
            var fontConfigC = new ImFontConfigPtr(ImFontConfig_ImFontConfig());

            ushort[] glyphRangesFull = new ushort[]
            {
                0x0020, 0x00FF, //Basic Latin + Latin Supplement,
                0x0400, 0x052F, //Cyrillic + Cyrillic Supplement
                0x2DE0, 0x2DFF, //Cyrillic Extended-A
                0xA640, 0xA69F, //Cyrillic Extended-B
                ImGuiExt.ReplacementHash, ImGuiExt.ReplacementHash,
                0
            };
            var rangesPtrFull = Marshal.AllocHGlobal(sizeof(short) * glyphRangesFull.Length);

            for (int i = 0; i < glyphRangesFull.Length; i++)
            {
                ((ushort *)rangesPtrFull)[i] = glyphRangesFull[i];
            }
            ushort[] glyphRangesLatin = new ushort[]
            {
                0x0020, 0x00FF, //Basic Latin + Latin Supplement
                ImGuiExt.ReplacementHash, ImGuiExt.ReplacementHash,
                0
            };
            var rangesPtrLatin = Marshal.AllocHGlobal(sizeof(short) * glyphRangesLatin.Length);

            for (int i = 0; i < glyphRangesLatin.Length; i++)
            {
                ((ushort *)rangesPtrLatin)[i] = glyphRangesLatin[i];
            }
            fontConfigA.GlyphRanges = rangesPtrLatin;
            fontConfigB.GlyphRanges = rangesPtrFull;
            fontConfigC.GlyphRanges = rangesPtrFull;

            Default = io.Fonts.AddFontDefault(fontConfigA);
            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LibreLancer.ImUI.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.Fonts.AddFontFromMemoryTTF(ttfPtr, ttf.Length, (int)(15 * Scale), fontConfigB);
            }

            using (var stream =
                       typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LibreLancer.ImUI.fa-solid-900.ttf"))
            {
                var iconFontConfig = new ImFontConfigPtr(ImFontConfig_ImFontConfig());
                iconFontConfig.MergeMode        = true;
                iconFontConfig.GlyphMinAdvanceX = iconFontConfig.GlyphMaxAdvanceX = (int)(20 * Scale);
                var glyphs = new List <ushort>();
                foreach (var chars in Icons.GetChars())
                {
                    glyphs.Add(chars);
                    glyphs.Add(chars);
                }
                glyphs.Add(0);
                var rangesPtrIcon = Marshal.AllocHGlobal(sizeof(short) * glyphs.Count);
                for (int i = 0; i < glyphs.Count; i++)
                {
                    ((ushort *)rangesPtrIcon)[i] = glyphs[i];
                }
                iconFontConfig.GlyphRanges = rangesPtrIcon;
                var ttf = new byte[stream.Length];
                stream.Read(ttf, 0, ttf.Length);
                ttfPtr = Marshal.AllocHGlobal(ttf.Length);
                Marshal.Copy(ttf, 0, ttfPtr, ttf.Length);
                io.Fonts.AddFontFromMemoryTTF(ttfPtr, ttf.Length, (int)(15 * Scale), iconFontConfig);
            }

            using (var stream =
                       typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LibreLancer.ImUI.empty-bullet.ttf"))
            {
                var iconFontConfig = new ImFontConfigPtr(ImFontConfig_ImFontConfig());
                iconFontConfig.MergeMode = true;
                var glyphs        = new ushort[] { Icons.BulletEmpty, Icons.BulletEmpty, 0 };
                var rangesPtrIcon = Marshal.AllocHGlobal(sizeof(short) * glyphs.Length);
                for (int i = 0; i < glyphs.Length; i++)
                {
                    ((ushort *)rangesPtrIcon)[i] = glyphs[i];
                }
                iconFontConfig.GlyphRanges = rangesPtrIcon;
                var ttf = new byte[stream.Length];
                stream.Read(ttf, 0, ttf.Length);
                ttfPtr = Marshal.AllocHGlobal(ttf.Length);
                Marshal.Copy(ttf, 0, ttfPtr, ttf.Length);
                io.Fonts.AddFontFromMemoryTTF(ttfPtr, ttf.Length, (int)(15 * Scale), iconFontConfig);
            }

            using (var stream = typeof(ImGuiHelper).Assembly.GetManifestResourceStream("LibreLancer.ImUI.checkerboard.png"))
            {
                checkerboard   = (Texture2D)LibreLancer.ImageLib.Generic.FromStream(stream);
                CheckerboardId = RegisterTexture(checkerboard);
            }
            var monospace = Platform.GetMonospaceBytes();

            fixed(byte *mmPtr = monospace)
            {
                SystemMonospace = io.Fonts.AddFontFromMemoryTTF((IntPtr)mmPtr, monospace.Length, (int)(16 * Scale), fontConfigC);
            }

            ImGuiExt.BuildFontAtlas((IntPtr)io.Fonts.NativePtr);
            byte *fontBytes;
            int   fontWidth, fontHeight;

            io.Fonts.GetTexDataAsRGBA32(out fontBytes, out fontWidth, out fontHeight);
            io.Fonts.TexUvWhitePixel = new Vector2(10, 10);
            Icons.TintGlyphs(fontBytes, fontWidth, fontHeight, Noto);
            fontTexture = new Texture2D(fontWidth, fontHeight, false, SurfaceFormat.Color);
            var bytes = new byte[fontWidth * fontHeight * 4];

            Marshal.Copy((IntPtr)fontBytes, bytes, 0, fontWidth * fontHeight * 4);
            fontTexture.SetData(bytes);
            fontTexture.SetFiltering(TextureFiltering.Linear);
            io.Fonts.SetTexID((IntPtr)FONT_TEXTURE_ID);
            io.Fonts.ClearTexData();
            string glslVer = RenderContext.GLES ? "300 es\nprecision mediump float;" : "140";

            textShader  = new Shader(vertex_source.Replace("{0}", glslVer), text_fragment_source.Replace("{0}", glslVer));
            colorShader = new Shader(vertex_source.Replace("{0}", glslVer), color_fragment_source.Replace("{0}", glslVer));
            dot         = new Texture2D(1, 1, false, SurfaceFormat.Color);
            var c = new Color4b[] { Color4b.White };

            dot.SetData(c);
            Theme.Apply(scale);
            //Required for clipboard function on non-Windows platforms
            utf8buf    = Marshal.AllocHGlobal(8192);
            instance   = this;
            setTextDel = SetClipboardText;
            getTextDel = GetClipboardText;

            io.GetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(getTextDel);
            io.SetClipboardTextFn = Marshal.GetFunctionPointerForDelegate(setTextDel);
        }