cimgui-go: Calling backend.DeleteTexture() crashes program
I’m making an app that shows a webcam preview in the GUI using GoCV (OpenCV). I need to delete the texture after I’m done drawing it to conserve GPU memory as every frame will be getting kept in VRAM. Calling backend.DeleteTexture() is crashing the entire program from within C function igDeleteTexture().
I can reproduce it with the following code example:
previewRgba, _ := imgui.LoadImage("test.jpeg")
previewTexture := backend.CreateTextureRgba(previewRgba, previewRgba.Bounds().Dx(), previewRgba.Bounds().Dy())
// imgui.Image(previewTexture, imgui.NewVec2(300, 300))
backend.DeleteTexture(previewTexture)
Is there anything obvious that would be causing this? I am calling runtime.LockOSThread() and the crash is happening in goroutine 1 so I’m pretty sure glDeleteTextures() is getting called from the main thread as it should.
About this issue
- Original URL
- State: closed
- Created 2 months ago
- Comments: 16 (7 by maintainers)
Commits related to this issue
- glfw: fix DeleteTexture implementation ref: https://github.com/AllenDang/cimgui-go/issues/279 — committed to gucio321/cimgui-go by gucio321 2 months ago
@gucio321 Good call, re-wrote my code to treat the rendering as async, persisting the texture between frames and only deleting it when a new image is ready and I now have a stable camera feed with no memory leaks 😄
I suppose I know whats wrong.
Lets look at this
^this is from Create Texture so this reffers to last texture, but we have no last texture because we bind 0 to it (or if we removed binding call in delete texture call there is something strange there. Null?)
we should deffinitly proceed this in DeleteTexture somehow
@tenten8401 now it works for me