Skip to main content

Crate egui_backend_selector

Crate egui_backend_selector 

Source
Expand description

§Egui Backend Selector

Backend selector for egui that will select a backend at runtime that works on the system your application is running on.

§Example

use egui_backend_selector::{BackendConfiguration, BackendInterop};
use eframe::Storage;

struct EguiApp {}

impl EguiApp {
    fn new(_context: egui::Context, _storage: Option<&dyn Storage>) -> Self {
        EguiApp {}
    }
}

impl egui_backend_selector::App for EguiApp {
    fn ui(&mut self, ui: &mut egui::Ui, backend: BackendInterop<'_>) {
        egui::CentralPanel::default().show_inside(ui, |ui| {
            ui.label(format!("Hello World! Running on {}", backend.backend_name()));
        });
    }
}

fn you_main_function() {
    egui_backend_selector::run_app("app-name", BackendConfiguration::default(), |ctx, storage| EguiApp::new(ctx, storage))
        .expect("failed to run app");
}

Structs§

BackendConfiguration
SoftwareBackendInterop
Wrapper for the SoftwareBackend

Enums§

Backend
Contains one element for each backend supported by the backend selector.
BackendInterop
Platform-specific interop to interact with the backend

Traits§

App
App traits

Functions§

get_backend
The function returns the backend selected to be used for egui.
is_launched
Returns true if the application was already launched and the selected backend can no longer be changed by calling the overwrite_backend function.
overwrite_backend
Overwrites the selected backend. This has no effect if the application was already launched.
run_app
Run the app using the selected backend. If no backend has been selected yet, then this function will also select the optional backend before running the app.