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

wgpu backend #19

Closed
IceSentry opened this issue Aug 20, 2020 · 10 comments
Closed

wgpu backend #19

IceSentry opened this issue Aug 20, 2020 · 10 comments

Comments

@IceSentry
Copy link

IceSentry commented Aug 20, 2020

I was trying to create a plugin for https://github.com/bevyengine/bevy and that would require a wgpu backend I think. I'd be interested in working on this, but I have no idea where to start.

@emilk
Copy link
Owner

emilk commented Aug 21, 2020

Hello!

A good place to start is probably to look at how the rendering is done for Glium: https://github.com/emilk/egui/blob/master/egui_glium/src/painter.rs

@IceSentry
Copy link
Author

So I've been working on my implementation here https://github.com/IceSentry/bevy_prototype_egui_plugin

I was about to start the painter based on glium, but I keep getting a crash saying No fonts available. I've been looking everywhere in the glium examples and egui_glium and I can't figure out how fonts are loaded.

@IceSentry
Copy link
Author

Also, just to be sure. it seems like implementing App and Backend isn't actually required. Is this true or did I miss something?

@IceSentry
Copy link
Author

I figured out my font bug. It was an issue with the ordering of the update calls.

@emilk
Copy link
Owner

emilk commented Aug 22, 2020

it seems like implementing App and Backend isn't actually required

You are correct!

egui::app is a model I introduced for writing backend agnostic apps. The goal is that you can write e.g. a calculator app that implements egui::app::App and then easily compile it for different Egui backends that implements egui::app::Backend (such as egui_glium and egui_web). It is still quite experimental.

@emilk
Copy link
Owner

emilk commented Aug 22, 2020

I've added this section to README.md:

You need to collect egui::RawInput, paint egui::PaintJobs and handle egui::Output. The basic structure is this:

let mut egui_ctx = egui::Context::new();

// game loop:
loop {
    let raw_input: egui::RawInput = my_backend.gather_input();
    let mut ui = egui_ctx.begin_frame(raw_input);
    my_app.ui(&mut ui); // add windows and widgets to `ui` here
    let (output, paint_jobs) = egui_ctx.end_frame();
    my_backend.paint(paint_jobs);
    my_backend.set_cursor_icon(output.cursor_icon);
    // Also see `egui::Output` for more
}

@IceSentry
Copy link
Author

I saw that, thank you, it was helpful. Now I just need to figure out how to draw the triangles in bevy and I think I'll be set.

@Gonkalbell
Copy link

I just uploaded https://github.com/Gonkalbell/egui_wgpu, which is a pretty lazy port of the glium bindings. I haven't gotten around to uploading the documentation to docs.rs or publishing this to crates.io yet, but maybe you can find it useful.

@IceSentry
Copy link
Author

Oh cool, thanks, I'll look at it. I kind of stopped working on this.

@emilk
Copy link
Owner

emilk commented Oct 18, 2020

It seems like we have TWO wgpu backends for Egui now:

So I will consider this issue closed!

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