aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 041ebeb..096bae4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -37,6 +37,8 @@ extern crate libc;
extern crate cocoa;
#[cfg(target_os = "macos")]
extern crate core_foundation;
+#[cfg(target_os = "linux")]
+extern crate sync;
pub use events::*;
@@ -71,6 +73,7 @@ pub struct WindowBuilder {
title: String,
monitor: Option<winimpl::MonitorID>,
gl_version: Option<(uint, uint)>,
+ vsync: bool,
}
#[cfg(feature = "window")]
@@ -79,9 +82,10 @@ impl WindowBuilder {
pub fn new() -> WindowBuilder {
WindowBuilder {
dimensions: None,
- title: "gl-init-rs window".to_string(),
+ title: "glutin window".to_string(),
monitor: None,
gl_version: None,
+ vsync: false,
}
}
@@ -117,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,
@@ -337,10 +347,22 @@ 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()
}
+
+ /// Gets the native platform specific display for this window.
+ /// This is typically only required when integrating with
+ /// other libraries that need this information.
+ #[inline]
+ pub unsafe fn platform_display(&self) -> *mut libc::c_void {
+ self.window.platform_display()
+ }
}
/// Represents a headless OpenGL context.