ocornut / imgui

Dear ImGui: Bloat-free Graphical User interface for C++ with minimal dependencies
MIT License
61.07k stars 10.29k forks source link

Displaying a slice of a 3D texture #8007

Closed voithos closed 1 month ago

voithos commented 1 month ago

Version/Branch of Dear ImGui:

Branch: master

Back-ends:

Using custom engine/back-end

Compiler, OS:

Linux/WebGL/Android

Full config/build information:

No response

Details:

My Issue/Question:

I have a 3D texture (but this could also apply to a 2D array texture) that I would like to preview in the ImGui editor, but as far as I can tell, there's no 3D version of ImGui::Image(). I know my use case is probably less common, but essentially what I'd want would be some kind of ImGui::Image3D() which would take the same args as the normal function, with the addition of a depth parameter, which it'd use to select the slice of the texture to draw. This would be easy to wire up with a separate UI component to let the user select the slice in question.

Am I correct that this is not currently supported?

Screenshots/Video:

No response

Minimal, Complete and Verifiable Example code:

No response

PathogenDavid commented 1 month ago

Am I correct that this is not currently

Correct. You'd have to make a custom widget specific to your backend to accomplish this.

You might find ImDrawList::AddCallback helpful for this task, but depending on how your custom backend is structured you might just have special image IDs to represent individual slices.

ocornut commented 1 month ago

Since you are using a custom backend, the most sane approach is that you can #define ImTextureID xxxxx to your own higher-level type, which its own constructors, optional parameters, methods etc. So you can store a depth in there or anything you like, and your rendering loop with use that data during rendering.

I don't believe there is anything that needs to be added to dear imgui to support it. I'm closing this as answered but feel free to comment if you have issues and we can help and reopen.