Crash when editing imgui demo.
Shadowblitz16 opened this issue · comments
Shadowblitz16 commented
I am getting a crash when I try to run game which is based on the imgui demo.
/home/shadowblitz16/RiderProjects/PlatformerEngine/PlatformerEngine/bin/Debug/net5.0/PlatformerEngine
Unhandled exception. System.TypeInitializationException: The type initializer for 'Love.Love2dDll' threw an exception.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Love.Boot.GetLibraryFunc(String name)
at Love.Love2dDll.LoadFunction[T](String name)
at Love.Love2dDll..cctor()
--- End of inner exception stack trace ---
at Love.Image.NewImageData(Int32 w, Int32 h, ImageDataPixelFormat format, Byte[] data)
at Love.Imgui.Renderer.RebuildFontAtlas()
at Love.Imgui.Renderer..ctor(String fontPath, Single fontSize, Func`2 imageLoader)
at PlatformerEngine.Game..ctor() in /home/shadowblitz16/RiderProjects/PlatformerEngine/PlatformerEngine/Game.cs:line 15
at PlatformerEngine.Program..ctor()
at PlatformerEngine.Program.Main(String[] args) in /home/shadowblitz16/RiderProjects/PlatformerEngine/PlatformerEngine/Program.cs:line 7
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Love;
using System.IO;
using ImGuiNET;
using Love.Imgui;
namespace PlatformerEngine
{
public abstract class Game : IDisposable
{
private Renderer _imGuiRenderer = new Renderer("G:/font/msyh.ttf", 18);
private Runner _imGuiRunner;
public GameConfig Config { get; private set; }
private class Runner : Scene
{
}
protected virtual void OnGUI ()
{
}
protected virtual void OnLoad()
{
}
protected virtual void OnTick()
{
}
protected virtual void OnDraw()
{
}
protected virtual void OnQuit()
{
}
public void Run(GameConfig config)
{
var asy = System.Reflection.Assembly.GetAssembly(typeof(Boot));
Console.WriteLine(asy);
Config = config;
_imGuiRunner = new Runner();
_imGuiRunner.OnLoad += () =>
{
Console.WriteLine(ImGui.GetVersion());
OnLoad();
};
_imGuiRunner.OnUpdate += dt =>
{
_imGuiRenderer.Update(dt, OnGUI);
OnTick();
};
_imGuiRunner.OnDraw += () =>
{
_imGuiRenderer.Draw();
OnDraw();
};
_imGuiRunner.OnQuit += () =>
{
OnQuit();
return false;
};
_imGuiRunner.OnTextInput += text =>
{
_imGuiRenderer.TextInput(text);
};
Boot.Init(new BootConfig()
{
WindowVsync = Config.VSync,
WindowTitle = Config.Title,
WindowWidth = (int)Config.Width,
WindowHeight = (int)Config.Height,
WindowResizable = Config.Resizable,
WindowFullscreen = Config.Fullscreen
});
Boot.Run(_imGuiRunner);
}
public void Dispose()
{
Love.Event.Quit(0);
}
}
public sealed class GameConfig
{
public bool VSync { get; set; }
public string Title { get; set; }
public uint Width { get; set; }
public uint Height { get; set; }
public bool Resizable { get; set; }
public bool Fullscreen { get; set; }
}
}
namespace PlatformerEngine
{
public class Program : Game
{
public static void Main(string[] args)
{
using (var game = new Program())
{
game.Run(new GameConfig()
{
Width = 1080,
Height = 640
});
}
}
}
}
Yx commented
🤔 I am not sure what happened, but here is information i can provide for you:
- LoveSharp.Imgui need
LoveSharp
nuget library but notLove2dCS
- the best way to run the deamo is clone all of this :
https://github.com/endlesstravel/LoveSharp.Imgui
Shadowblitz16 commented
I think it installs LoveSharp as a dependency.
also I based it off the demo there.