New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a way to store rendered "frames" #687
Comments
Sorry for the slow reply! This would be a good thing to support. Main issue is we can't trivially add There was a similar request to (de)serialize the draw data in #606 which would work in this case - the solution there was to basically have a duplicate set of structs: We could provide these in I suspect possibly having something like |
Hello, and first of all, thank you for writing this library! I stumbled across this issue as I am also working on integrating imgui-rs into a multithreaded renderer (Bevy), and also need a means of cloning and temporarily storing an When looking into potential avenues here, I came across this issue in the ImGui repo and the use case feels very similar to ocornut/imgui#2646. So I thought I'd try prototyping a similar solution, which you can find here: https://github.com/jbrd/imgui-rs/commit/a6454917989daba33f6bb7432fba64ac46df758a It'd be great to get your thoughts on this. Essentially, the idea is to introduce an Would something like this be possible to provide? |
That sounds pretty much perfect - it's consistent with the upstream library, plus it solves the concern of having two objects for renderers to deal with, and avoids having to keep the duplicated structs up to date 🥳 |
My two cents: this is exactly what I expected. |
Excellent, thanks both! I'll try to get this tidied up and into a PR over the next few days... |
Issue #687: Add OwnedDrawData for deep cloning DrawData
Done in v0.11 🥳 |
Nice, thanks! |
Is your feature request related to a problem? Please describe.
I want to support both, opengl and vulkan renderers of imgui. However, the opengl renderer is relying on having an object with a limited lifetime passed to the "render" function. At the same time, for Vulkan it is better to separate the "drawing" and "presentation" stages, due to the nature of vulkan. So I was sort of trying to support both APIs by separating the stages for opengl renderer too. However, this would require storing the
imgui::Ui
object with a limited lifetime which I can't guarantee. In other words, I'd have to own the data in my structure. With current imgui-rs API it is impossible to obtain the imgui draw state (vertex buffers and others) and own them. We only can get a reference to the current frame's data and guarantee its lifetime.Another problem is that now it is impossible to, let's say, "draw" a bunch of frames of the imgui, then store these states, and later render those either to a frame buffer of an API of choice or dump to a file, or render without any API to a file, you would be able to do anything with it. The only option now is to render immediately at the same place where the
imgui::Ui
object is obtained.Describe the solution you'd like
I'd like to have a way to obtain an owned copy of
imgui::DrawData
, namely vertex and index buffers, so that I am not limited by the lifetime of a single frame but can postpone the rendering and split it into stages and actually can do whatever I want with this data at any time later.Currently, the
imgui::Context::render
returns only a reference toimgui::DrawData
that can't be owned. Due to the limitations ofimgui::Context
, it is also not possible to store it directly as it is neither copyable nor clonable. The only solution now, which is dirty here, is to store anRc<RefCell<imgui::Context>>
that is ugly and not really a solution.Describe alternatives you've considered
Can't think of any alternatives.
Additional context
imgui::DrawData
implements neitherCopy
norClone
.The text was updated successfully, but these errors were encountered: