ImGuiNET / ImGui.NET

An ImGui wrapper for .NET.
MIT License
1.87k stars 305 forks source link

Access violation #125

Open TezzoeR opened 5 years ago

TezzoeR commented 5 years ago

Im using the ImGui.net in vb.net and if i try to draw the imgui i get this error Screenshot_1

mellinoe commented 5 years ago

Hi @TezzoeR, it's likely that you're calling some of the functions out of order. Can you double check that you are doing things the same way that the example project is, for example?

itayronen commented 5 years ago

Happened to me when I didn't call the ImGuiRenderer.Update(...) function. Example: this.ImGuiRenderer.Update(1f / 60f, snapshot);

Kein commented 5 years ago

Getting the same issue when trying to change the font, using sample project:

 private static unsafe void ChangeFont()
{
    var x = ImGui.GetIO();
    var nativeConfig = ImGuiNative.ImFontConfig_ImFontConfig();
    var config = new ImFontConfigPtr(nativeConfig);
    config.SizePixels = 22f;
    config.OversampleH = config.OversampleV = 1;
    config.PixelSnapH = true;
    _segoe = x.Fonts.AddFontFromFileTTF("segoeui.ttf", 22f, config);
    config.Destroy();
}

ChangeFont();

while (_window.Exists)
{
    //...
    _controller.Update(1f / 60f, snapshot); // newFrame called here

    ImGui.PushFont(_segoe);
    SubmitUI();
    ImGui.PopFont();
}
oxysoft commented 4 years ago

Same problem as Kein, I am unable to a font with nearly exactly the same steps.

sonoro1234 commented 4 years ago

Using LuaJIT-imgui bindings, after render

    ig.GetIO().Fonts:Clear()
    ig.lib.ImGui_ImplOpenGL3_DestroyFontsTexture()
    local theFONT
    local fnt_cfg = ig.ImFontConfig()
    fnt_cfg.PixelSnapH = true
    --fnt_cfg.OversampleH = 1
    theFONT= ig.GetIO().Fonts:AddFontFromFileTTF(font, fontsize, fnt_cfg,nil) 
    assert(theFONT ~= nil)
    ig.lib.ImGui_ImplOpenGL3_CreateFontsTexture()
    ig.GetIO().FontDefault = theFONT

The part missing above is ig.lib.ImGui_ImplOpenGL3_DestroyFontsTexture() and ig.lib.ImGui_ImplOpenGL3_CreateFontsTexture() Several issues in this repo are related to Font loading!!

All the above described must be done after Render (not between NewFrame and Render)