veeenu / hudhook

A videogame overlay framework written in Rust, supporting DirectX and OpenGL
MIT License
185 stars 27 forks source link

Expose ImGui Context #119

Closed vars1ty closed 1 year ago

vars1ty commented 1 year ago

Would it be possible to expose the ImGui context in the render function as a parameter? Since hudhook doesn't yet support EGUI, I'm using ImGui for other games, and I'd like to change the colors of the window(s).

veeenu commented 1 year ago

If you can get away with using the context just once at start, you can implement the initialize method that exposes the context explicitly for initializations/styles and whatnot.

If you want to do that dynamically (i.e. change colors during a render cycle), we have a language level problem: a Ui frame is an immutable reference derived from a &mut Context; passing in the context would violate the borrow checker rules. I could add a "pre-render" method but it would make the API super messy, and its usefulness would not be immediately apparent to the user, so I would much prefer not having that since API usability is a very important goal to me.

Do you actually need the context to do that, though? There are many constructs related to style that only require an instance of Ui, and only a couple that need Context at all, and those are for returning references to a Style object which you probably don't need to directly interact with.

vars1ty commented 1 year ago

I've looked into the functions you mentioned, and they didn't seem to be doing anything. I could try again later, but from my test they had no effect.

Regarding initialize, it's all that I need for now. Thanks!

vars1ty commented 1 year ago

Update: Nevermind I was just doing the push* functions improperly, works properly now!