1
0
mirror of https://github.com/emilk/egui.git synced 2026-06-27 23:13:13 -04:00

Some more work on making possible to render viewport_sync in glutin

Context::current_rendering_viewport was replaced by Context::get_viewport_id
Added Context::get_parent_viewport_id
Changed Context::run to need parent_viewport_id
Changed Context::beagin to need parent_viewport_id
Added ImplContext::frame_stack
Some work on making posibile to render multiples frames at the same time
A lot of more things in glutin backend is not Arc<RwLock<T>>
This commit is contained in:
Konkitoman
2023-08-02 17:14:31 +03:00
parent c7c9713bf8
commit 34fea8a0e5
9 changed files with 248 additions and 124 deletions

View File

@@ -18,7 +18,7 @@ fn main() -> Result<(), eframe::Error> {
egui::CentralPanel::default().show(ctx, |ui| {
ui.label(format!(
"Current rendering window: {}",
ctx.current_rendering_viewport()
ctx.get_viewport_id()
));
ui.heading("My egui Application");
ui.horizontal(|ui| {

View File

@@ -9,5 +9,5 @@ publish = false
[dependencies]
eframe = { path = "../../crates/eframe", features = ["wgpu"] }
eframe = { path = "../../crates/eframe" }
env_logger = "0.10"

View File

@@ -1,4 +1,5 @@
use eframe::egui;
use eframe::egui::window::ViewportBuilder;
use eframe::egui::Id;
use eframe::NativeOptions;
@@ -10,7 +11,7 @@ fn main() {
let _ = eframe::run_simple_native(
"Viewports Examples",
NativeOptions {
renderer: eframe::Renderer::Wgpu,
renderer: eframe::Renderer::Glow,
..NativeOptions::default()
},
move |ctx, _frame| {
@@ -21,6 +22,22 @@ fn main() {
ctx.set_desktop(is_desktop);
ui.checkbox(&mut to_repair, "To Repair!");
ctx.create_viewport_sync(
ViewportBuilder::default().with_title("Sync rendering!"),
|ctx, viewport_id, parent_viewport_id| {
egui::CentralPanel::default().show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Viewport ID: ");
ui.label(format!("{viewport_id}"))
});
ui.horizontal(|ui| {
ui.label("Parent Viewport ID: ");
ui.label(format!("{parent_viewport_id}"))
});
})
},
);
egui::CollapsingHeader::new("Show Test1").show(ui, |ui| {
egui::Window::new("Test1").show(ctx, move |ui, id, parent_id| {
ui.label(format!("Frame: {}", ui.ctx().frame_nr()));
@@ -40,7 +57,7 @@ fn main() {
let ctx = ui.ctx().clone();
ui.label(format!(
"Current rendering window: {}",
ctx.current_rendering_viewport()
ctx.get_viewport_id()
));
if ui.button("Drag").is_pointer_button_down_on() {
if id != parent_id {
@@ -71,7 +88,7 @@ fn main() {
let ctx = ui.ctx().clone();
ui.label(format!(
"Current rendering window: {}",
ctx.current_rendering_viewport()
ctx.get_viewport_id()
));
if ui.button("Drag").is_pointer_button_down_on() {
@@ -94,7 +111,7 @@ fn main() {
let ctx = ui.ctx().clone();
ui.label(format!(
"Current rendering window: {}",
ctx.current_rendering_viewport()
ctx.get_viewport_id()
));
if ui.button("Drag").is_pointer_button_down_on() {