Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with fonts #425

Open
ZereX666 opened this issue Sep 6, 2023 · 2 comments
Open

Problem with fonts #425

ZereX666 opened this issue Sep 6, 2023 · 2 comments

Comments

@ZereX666
Copy link

ZereX666 commented Sep 6, 2023

I can't figure out what I did wrong....

https://github.com/ImGuiNET/ImGui.NET/blob/master/src/ImGui.NET.SampleProgram/ImGuiController.cs (i use this for example)
image

Code:

       	_window = VeldridStartup.CreateWindow(new WindowCreateInfo(50, 50, Settings.Config!.windowWidth, Settings.Config.windowHeight, Settings.Config.WindowState, "test"));
        _gd = VeldridStartup.CreateGraphicsDevice(_window,new GraphicsDeviceOptions(false, null, true, ResourceBindingModel.Improved, true, true) , GraphicsBackend.Direct3D11); 
        _window.Resized += () =>
        {
            _gd.MainSwapchain.Resize((uint)_window.Width, (uint)_window.Height);
            _controller.WindowResized(_window.Width, _window.Height);
        }        
        _cl = _gd.ResourceFactory.CreateCommandList();
        _controller = new ImGuiController(_gd, _gd.MainSwapchain.Framebuffer.OutputDescription, _window.Width, _window.Height);

        var stopwatch = Stopwatch.StartNew();
        float deltaTime = 0f;
        
        ImFontPtr imFontPtr;
        unsafe
        {
            ImGui.GetIO().Fonts.Clear();
            var config = ImGuiNative.ImFontConfig_ImFontConfig();
            imFontPtr = ImGui.GetIO().Fonts.AddFontFromFileTTF(@"ProggyClean.ttf", 13.0f, config, ImGui.GetIO().Fonts.GetGlyphRangesCyrillic());
            ImGuiNative.ImFontConfig_destroy(config);
        }
        
        _controller.RecreateFontDeviceTexture(_gd);
        
        while (_window.Exists)
        {
            deltaTime = stopwatch.ElapsedTicks / (float)Stopwatch.Frequency;
            stopwatch.Restart();
            InputSnapshot snapshot = _window.PumpEvents();

            if (!_window.Exists)
                break;
            
            if (_window.WindowState == WindowState.Minimized)
            {
                Thread.Sleep(1);
                continue;
            }
            
            _controller.Update(deltaTime, snapshot); // Feed the input events to our ImGui controller, which passes them through to ImGui.
            
            ImGui.PushFont(imFontPtr);
            SubmitUI();
            
            _cl.Begin();
            _cl.SetFramebuffer(_gd.MainSwapchain.Framebuffer);
            _cl.ClearColorTarget(0, new RgbaFloat(_clearColor.X, _clearColor.Y, _clearColor.Z, 1f));
            _controller.Render(_gd, _cl);
            _cl.End();
            _gd.SubmitCommands(_cl);
            _gd.SwapBuffers(_gd.MainSwapchain);
        }

        ImGui.GetIO().ConfigDockingWithShift = true;

        _gd.WaitForIdle();
        _controller.Dispose();
        _cl.Dispose();
        _gd.Dispose();
     
@ZereX666
Copy link
Author

still relevant

@zaafar
Copy link
Collaborator

zaafar commented Apr 25, 2024

ImGui.PushFont(imFontPtr); in this line you are pushing the font for imgui to use that your graphic card doesn't know about. You have to use the graphic card api/lib to upload the font to it and then use it in imgui.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants