andrewoconnor / crimgui

Crystal bindings for dear imgui
BSD Zero Clause License
16 stars 1 forks source link

Invalid memory access #1

Open ergoadams opened 4 years ago

ergoadams commented 4 years ago

Hello!

I've been trying for some time now to get crimgui to work. First it wouldn't find cimgui, but I got that fixed by using the makefile and copying cimgui.so to a folder, that ld looks through. That got rid of the cimgui part of issues. Now I'm running into an Invalid memory access. Seems like it originates from ImFontAtlas_GetTexDataAsRGBA32 in lib.cr, which is called from imgui.cr as LibImGui.im_font_atlas_get_tex_data_as_rgba32(io.value.fonts, out pixels, out width, out height, out bytes_per_pixel). All of these errors come, when trying to run the test file. Unfortunately I'm nowhere as good as a programmer to fix that, cause I don't even know where to start from.

oprypin commented 4 years ago

It's from the missing font. You can either get a ttf file and populate the path to it, or just drop the custom font code (delete the following:).

imgui.font_atlas_clear
imgui.add_font_from_file_ttf("/Library/Fonts/Andale Mono.ttf", 24.0)
imgui.update_font_texture
ergoadams commented 4 years ago

Unfortunately this doesn't seem to fix it. I had already tried commenting them out. I'll post the error just in case.

[0x56061c626426] *Exception::CallStack::print_backtrace:Int32 +118
[0x56061c618fe5] __crystal_sigfault_handler +341
[0x7fdfa1317540] ???
[0x7fdfa185ad4f] _ZN11ImFontAtlas18GetTexDataAsRGBA32EPPhPiS2_S2_ +47
[0x56061c68c618] *ImGui +56
[0x56061c68c540] *ImGui +2688
[0x56061c68baa1] *ImGui +513
[0x56061c68b88c] *ImGui +44
[0x56061c68b848] *ImGui +104
[0x56061c608e44] __crystal_main +2452
[0x56061c6919f6] *Crystal::main_user_code<Int32, Pointer(Pointer(UInt8))>:Nil +6
[0x56061c691865] *Crystal::main<Int32, Pointer(Pointer(UInt8))>:Int32 +53
[0x56061c6141e6] main +6
[0x7fdfa0ec51e3] __libc_start_main +243
[0x56061c6083ee] _start +46
[0x0] ???
andrewoconnor commented 4 years ago

@ergoa2001 Try pulling the latest and use the cimgui.so in the deps directory. I have updated the example.

ergoadams commented 4 years ago

After some tweaking I got it to work. I'm under Ubuntu 20.04 and had to copy the cimgui.so file twice under different names to /usr/lib/x86_64-linux-gnu/. Once with the name libcimgui.so and the other time with the original name in the deps folder. Also had to add crsfml to shards.yml. Crimgui seems to be working fine now!

oprypin commented 4 years ago

I think 034e3d3e050670017ee778c93f62416d60316b57 was not a good move. The .so files shouldn't be in the source repo :/