0

I am trying to integrate egui with a renderer I made.

Looking at the dos I find this snippet where they explain how to integrate the library:

let mut ctx = egui::Context::default();

// Game loop:
loop {
    let raw_input: egui::RawInput = gather_input();

    let full_output = ctx.run(raw_input, |ctx| {
        egui::CentralPanel::default().show(&ctx, |ui| {
            ui.label("Hello world!");
            if ui.button("Click me").clicked() {
                // take some action here
            }
        });
    });
    handle_platform_output(full_output.platform_output);
    let clipped_primitives = ctx.tessellate(full_output.shapes); // create triangles to paint
    paint(full_output.textures_delta, clipped_primitives);
}

There are 2 things missing, there. First, how to get the font atlas, 2 what are the shaders.

looking at the repo I found this:

https://github.com/emilk/egui/tree/master/crates/egui_glium/src/shader

So I assume those shaders should be good enough, but maybe I am mistaken.

The other thing I cannot find for the life of me is how you get the font atlas, the fragment shader in that repo is clearly asking for a texture, and I assume it must be the font atlas but the docs do not mention it at all.

Makogan
  • 8,208
  • 7
  • 44
  • 112

1 Answers1

0

It will be sent to you on the first draw call:

 let output = self.ctx.run(raw_input, |ctx|
        {
            egui::CentralPanel::default().show(&ctx, |ui| {
                ui.label("Hello world!");
                if ui.button("Click me").clicked() {
                    // take some action here
                }
            });
        });

    let texture_changes = output.textures_delta;
    for (texture_id, image_delta) in texture_changes.set
    { /* collect the data here */ }
    ```
Makogan
  • 8,208
  • 7
  • 44
  • 112