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

Add Context::request_repaint_after #1694

Merged
emilk:master from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
change egui glium examples to use repaint_after instead of needs_repaint
  • Loading branch information
coderedart committed May 31, 2022
commit 9444edefaf15e2742a4d27df9d6fc0c29e3f569a
8 changes: 6 additions & 2 deletions egui_glium/examples/native_texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn main() {
let mut redraw = || {
let mut quit = false;

let needs_repaint = egui_glium.run(&display, |egui_ctx| {
let repaint_after = egui_glium.run(&display, |egui_ctx| {
egui::SidePanel::left("my_side_panel").show(egui_ctx, |ui| {
if ui
.add(egui::Button::image_and_text(
Expand All @@ -44,9 +44,13 @@ fn main() {

*control_flow = if quit {
glutin::event_loop::ControlFlow::Exit
} else if needs_repaint {
} else if repaint_after.is_zero() {
display.gl_window().window().request_redraw();
glutin::event_loop::ControlFlow::Poll
} else if let Some(repaint_after_instant) =
std::time::Instant::now().checked_add(repaint_after)
{
glutin::event_loop::ControlFlow::WaitUntil(repaint_after_instant)
coderedart marked this conversation as resolved.
Show resolved Hide resolved
} else {
glutin::event_loop::ControlFlow::Wait
};
Expand Down
8 changes: 6 additions & 2 deletions egui_glium/examples/pure_glium.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fn main() {
let mut redraw = || {
let mut quit = false;

let needs_repaint = egui_glium.run(&display, |egui_ctx| {
let repaint_after = egui_glium.run(&display, |egui_ctx| {
egui::SidePanel::left("my_side_panel").show(egui_ctx, |ui| {
ui.heading("Hello World!");
if ui.button("Quit").clicked() {
Expand All @@ -25,9 +25,13 @@ fn main() {

*control_flow = if quit {
glutin::event_loop::ControlFlow::Exit
} else if needs_repaint {
} else if repaint_after.is_zero() {
display.gl_window().window().request_redraw();
glutin::event_loop::ControlFlow::Poll
} else if let Some(repaint_after_instant) =
std::time::Instant::now().checked_add(repaint_after)
{
glutin::event_loop::ControlFlow::WaitUntil(repaint_after_instant)
coderedart marked this conversation as resolved.
Show resolved Hide resolved
} else {
glutin::event_loop::ControlFlow::Wait
};
Expand Down