Closed TrevorCash closed 2 months ago
The code inside ImGuiIntegration
assumes the texture ID is actually a pointer to the texture object, not the underlying OpenGL ID (which is possibly a bit silly, but that's what it is).
If you use the ImGuiIntegration::image() helper instead of ImGui::Image()
, which wraps this in a safe way, it should work.
I overlooked this in the docs. Thanks, it is working.
Just for the record, as of 1117d6f9b843aafe1fbd95bbadbc36e1180a488a the ImTextureID
uses the underlying OpenGL ID (as you attempted to use here) and not a pointer to a live GL::Texture2D
instance. It's much safer and makes the implementation simpler as well. Another such accidental crash was mosra/magnum#476.
No change is needed if you use the suggested image()
and imageButton()
utils, low-level code should use the new ImGuiIntegration::textureId() helper instead of a direct cast.
Hello,
I am trying to bind an image to a texture and then render using ImGui::Image() call.
The Code I am using is below (which loads a png image and then binds to texture when the button is pushed)
The above code works fine.
later when imgui is drawn. in MagnumImGuiIntegration / Context.cpp / drawFrame()
I get a crash at this call (line 366) _shader .bindTexture(static_cast<GL::Texture2D>(pcmd->TextureId)) .draw(_mesh);
I think it may not be correctly converting to GL::Texture2D from pcmd->TextureId (which is 0x2)
Call stack
Is there some other step I should be doing to get a image to render with ImGui? I keep 1 Texture2D object around at all times.
Thanks for any help/tips in advance.
-Trevor