mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 14:20:04 -04:00
Deduplicate code found in both egui_glium and egui_glow (#819)
* Move window building to egui-winit * Move icon loading to egui-winit * `use glow::HasContext;` -> `use glow::HasContext as _;` * Move FileStorage into epi behind a feature flag * De-duplicate screen_size_in_pixels and native_pixels_per_point * Move creation of FileStorage to epi * Handle epi app output (window size changes etc) in egui-winit * Move app and memory persistence and autosave logic to egui-winit * fix check.sh * Make the epi backend opt-in for egui_glium and egui_glow * Fix persistence * Add integration name to epi::IntegrationInfo and the demo * Clean up Cargo.toml files and fix making egui_glium optional * fix typo * Make egui_glium compile without the `epi` feature
This commit is contained in:
@@ -76,32 +76,20 @@
|
||||
#![allow(clippy::float_cmp)]
|
||||
#![allow(clippy::manual_range_contains)]
|
||||
|
||||
mod backend;
|
||||
mod painter;
|
||||
#[cfg(feature = "persistence")]
|
||||
pub mod persistence;
|
||||
|
||||
pub use backend::*;
|
||||
pub use painter::Painter;
|
||||
|
||||
#[cfg(feature = "epi")]
|
||||
mod epi_backend;
|
||||
#[cfg(feature = "epi")]
|
||||
pub use epi_backend::{run, NativeOptions};
|
||||
|
||||
pub use egui_winit;
|
||||
pub use epi::NativeOptions;
|
||||
|
||||
use glium::glutin;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
pub fn screen_size_in_pixels(display: &glium::Display) -> egui::Vec2 {
|
||||
let (width_in_pixels, height_in_pixels) = display.get_framebuffer_dimensions();
|
||||
egui::vec2(width_in_pixels as f32, height_in_pixels as f32)
|
||||
}
|
||||
|
||||
pub fn native_pixels_per_point(display: &glium::Display) -> f32 {
|
||||
display.gl_window().window().scale_factor() as f32
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// Use [`egui`] from a [`glium`] app.
|
||||
pub struct EguiGlium {
|
||||
egui_ctx: egui::CtxRef,
|
||||
|
||||
Reference in New Issue
Block a user