-
-
Notifications
You must be signed in to change notification settings - Fork 480
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
buffer_age
method on WindowedContext
This uses `EGL_EXT_buffer_age` and `GLX_EXT_buffer_age` API to query window's back buffer age.
- Loading branch information
Showing
13 changed files
with
148 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
mod support; | ||
|
||
use glutin::event::{Event, WindowEvent}; | ||
use glutin::event_loop::{ControlFlow, EventLoop}; | ||
use glutin::window::WindowBuilder; | ||
use glutin::ContextBuilder; | ||
|
||
fn main() { | ||
let el = EventLoop::new(); | ||
let wb = WindowBuilder::new().with_title("A fantastic window!"); | ||
|
||
let windowed_context = ContextBuilder::new().with_vsync(true).build_windowed(wb, &el).unwrap(); | ||
|
||
let windowed_context = unsafe { windowed_context.make_current().unwrap() }; | ||
|
||
println!("Pixel format of the window's GL context: {:?}", windowed_context.get_pixel_format()); | ||
|
||
let gl = support::load(&windowed_context.context()); | ||
|
||
el.run(move |event, _, control_flow| { | ||
println!("{:?}", event); | ||
*control_flow = ControlFlow::Wait; | ||
|
||
match event { | ||
Event::LoopDestroyed => return, | ||
Event::WindowEvent { event, .. } => match event { | ||
WindowEvent::Resized(physical_size) => windowed_context.resize(physical_size), | ||
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, | ||
_ => (), | ||
}, | ||
Event::RedrawRequested(_) => { | ||
gl.draw_frame([1.0, 0.5, 0.7, 1.0]); | ||
println!("Buffer age: {}", windowed_context.buffer_age()); | ||
windowed_context.swap_buffers().unwrap(); | ||
windowed_context.window().request_redraw(); | ||
} | ||
_ => (), | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters