aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorTomaka17 <pierre.krieger1708@gmail.com>2014-10-26 10:32:51 +0100
committerTomaka17 <pierre.krieger1708@gmail.com>2014-10-26 16:35:24 +0100
commit8249e545f8d582cc3a99ddab3ab7c998c152cb3a (patch)
treea3d9647aa90deaf5725125f9b7452cf25c82d445 /src/lib.rs
parente887cf57b8177f28d4307f7d092f158fac09ef15 (diff)
downloadglutin-8249e545f8d582cc3a99ddab3ab7c998c152cb3a.tar.gz
glutin-8249e545f8d582cc3a99ddab3ab7c998c152cb3a.zip
Add `with_vsync` to WindowBuilder, plus the win32 implementation
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index da92cc2..8f9dbf5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -73,6 +73,7 @@ pub struct WindowBuilder {
title: String,
monitor: Option<winimpl::MonitorID>,
gl_version: Option<(uint, uint)>,
+ vsync: bool,
}
#[cfg(feature = "window")]
@@ -84,6 +85,7 @@ impl WindowBuilder {
title: "gl-init-rs window".to_string(),
monitor: None,
gl_version: None,
+ vsync: false,
}
}
@@ -119,6 +121,12 @@ impl WindowBuilder {
self
}
+ /// Requests that the window has vsync enabled.
+ pub fn with_vsync(mut self) -> WindowBuilder {
+ self.vsync = true;
+ self
+ }
+
/// Builds the window.
///
/// Error should be very rare and only occur in case of permission denied, incompatible system,
@@ -339,6 +347,10 @@ impl Window {
///
/// You should call this function every time you have finished rendering, or the image
/// may not be displayed on the screen.
+ ///
+ /// **Warning**: if you enabled vsync, this function will block until the next time the screen
+ /// is refreshed. However drivers can choose to override your vsync settings, which means that
+ /// you can't know in advance whether `swap_buffers` will block or not.
#[inline]
pub fn swap_buffers(&self) {
self.window.swap_buffers()