Open MouseProducedGames opened 5 years ago
Try to call the function below before you call SetKeyMappings();
private static void RecreateFontDeviceTexture() { ImGuiIOPtr io = ImGui.GetIO(); IntPtr pixels; int width, height, bytesPerPixel; io.Fonts.GetTexDataAsRGBA32(out pixels, out width, out height, out bytesPerPixel); io.Fonts.ClearTexData(); }
Normally you would then send the pixels to the Graphics library to upload as a texture to use, then set the fonts texture ID to point to it using io.Fonts.SetTexID(fontTexID);
Sorry for that terrible code formatting.
private static void RecreateFontDeviceTexture() { ImGuiIOPtr io = ImGui.GetIO(); IntPtr pixels; int width, height, bytesPerPixel; io.Fonts.GetTexDataAsRGBA32(out pixels, out width, out height, out bytesPerPixel); io.Fonts.ClearTexData(); }
I was having exactly the same issue (and I'm also using the lib without any rendering backend for now) and calling this actually fixes the issue with AccessViolation. I'm using OpenTK so it was kind of tricky to find something on that. Thank you!
YES, I was having the exact same issue trying to get my game engine to run under NUnit, and calling GetTexDataAsRGBA32 and ClearTexData fixed it!
That said, I'm ALL on board for having better error information! It took me hours of trying then finding this issue to fix this problem 💯
The first call to ImGui.NewFrame() always throws an access violation in my project. I copied over all the non-Veldrid specific parts to my code, and the exact same result occurs:
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
I was able to copy over the entire set of code and resource files from ImGui.NET.SampleProgram and that worked (once I embedded the shader resources properly). It may be that I don't have a render output setup for ImGui.Net, yet - based on my reading of the code, that should only result in no GUI being displayed, not an access violation exception?
I'm using glfw-net, glfw (don't know if it's necessary) and my own OpenGL very thin wrapper that doesn't do any processing at all - so it shouldn't be that; also all I use it for is clearing the screen, and commenting out those doesn't change a thing.
` public static void Run(AApplication application) { Glfw.Init();
`