Skip to content
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

Is it possible to use this with imgui-rs? #168

Open
MilowLab opened this issue Sep 15, 2023 · 2 comments
Open

Is it possible to use this with imgui-rs? #168

MilowLab opened this issue Sep 15, 2023 · 2 comments

Comments

@MilowLab
Copy link

Hello!

I have been trying to get this crate to work with imgui-rs. I can get a imgui-rs window up, but don't know how to link it with raylib.
I'm assuming I need to access raylib's context for imgui to draw to. But I have not found a way to do that.

So I'm making a issue to try and see if its possible to hook the two together.

Thanks!

@Sergiovan
Copy link

Hello!

I have been trying to get this crate to work with imgui-rs. I can get a imgui-rs window up, but don't know how to link it with raylib. I'm assuming I need to access raylib's context for imgui to draw to. But I have not found a way to do that.

So I'm making a issue to try and see if its possible to hook the two together.

Thanks!

It is possible to hook imgui-rs and raylib-rs, I've made a gist from the code I use in my own project: https://gist.github.com/Sergiovan/8c6eaa8110440c31ff76f1d038ff4e9c
I translated this from the C++ version of the raylib bindings, which are also referenced in the gist. To use them you simply

let (mut rl, thread) = raylib::init().size(1024, 768).title("Example").build();
let rl_imgui = imgui_raylib::RaylibImguiSupport::setup(&mut rl, &thread);

// And later
let ui = &mut rl_imgui.start_frame(&mut rl);
ui.window("blah") // etc

I can't promise the code is flawless and I'm fairly certain it does not cover the entire renderer/platform API, but I hope it can at least help you (or someone else reading this) with their own projects.

@jestarray
Copy link
Contributor

I took this and made it work in my raylib game: https://github.com/michaelfairley/rust-imgui-opengl-renderer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants