aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2014-10-27 09:24:31 +0100
committertomaka <pierre.krieger1708@gmail.com>2014-10-27 09:24:31 +0100
commita6bc0b0ba0a451ceb6704a1fdb47b4677c1c4761 (patch)
tree870435de14d7047ed9044534adb426313130555a /src/win32
parent60e9ba4febf32d2f3406b44b5e1d22396a29ff6d (diff)
parent8249e545f8d582cc3a99ddab3ab7c998c152cb3a (diff)
downloadglutin-a6bc0b0ba0a451ceb6704a1fdb47b4677c1c4761.tar.gz
glutin-a6bc0b0ba0a451ceb6704a1fdb47b4677c1c4761.zip
Merge pull request #72 from tomaka/vsync
Add `with_vsync` to WindowBuilder, plus the win32 implementation
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/ffi.rs3
-rw-r--r--src/win32/init.rs10
-rw-r--r--src/win32/mod.rs6
3 files changed, 14 insertions, 5 deletions
diff --git a/src/win32/ffi.rs b/src/win32/ffi.rs
index 317935d..71f8d55 100644
--- a/src/win32/ffi.rs
+++ b/src/win32/ffi.rs
@@ -23,7 +23,8 @@ pub mod wgl_extra {
version: "1.0",
generator: "struct",
extensions: [
- "WGL_ARB_create_context"
+ "WGL_ARB_create_context",
+ "WGL_EXT_swap_control"
]
}
}
diff --git a/src/win32/init.rs b/src/win32/init.rs
index 36bf639..ca99da8 100644
--- a/src/win32/init.rs
+++ b/src/win32/init.rs
@@ -16,7 +16,7 @@ local_data_key!(WINDOW: (ffi::HWND, Sender<Event>))
pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: String,
builder_monitor: Option<super::MonitorID>,
- builder_gl_version: Option<(uint, uint)>,
+ builder_gl_version: Option<(uint, uint)>, builder_vsync: bool,
builder_headless: bool) -> Result<Window, String>
{
use std::mem;
@@ -346,6 +346,14 @@ pub fn new_window(builder_dimensions: Option<(uint, uint)>, builder_title: Strin
lib
};
+ // handling vsync
+ if builder_vsync {
+ if extra_functions.SwapIntervalEXT.is_loaded() {
+ unsafe { ffi::wgl::MakeCurrent(hdc, context) };
+ extra_functions.SwapIntervalEXT(1);
+ }
+ }
+
// building the struct
let window = Window{
window: real_window,
diff --git a/src/win32/mod.rs b/src/win32/mod.rs
index 33d0600..3cfdc7e 100644
--- a/src/win32/mod.rs
+++ b/src/win32/mod.rs
@@ -25,7 +25,7 @@ impl HeadlessContext {
/// See the docs in the crate root file.
pub fn new(builder: HeadlessRendererBuilder) -> Result<HeadlessContext, String> {
let HeadlessRendererBuilder { dimensions, gl_version } = builder;
- init::new_window(Some(dimensions), "".to_string(), None, gl_version, true)
+ init::new_window(Some(dimensions), "".to_string(), None, gl_version, false, true)
.map(|w| HeadlessContext(w))
}
@@ -68,8 +68,8 @@ pub struct Window {
impl Window {
/// See the docs in the crate root file.
pub fn new(builder: WindowBuilder) -> Result<Window, String> {
- let WindowBuilder { dimensions, title, monitor, gl_version } = builder;
- init::new_window(dimensions, title, monitor, gl_version, false)
+ let WindowBuilder { dimensions, title, monitor, gl_version, vsync } = builder;
+ init::new_window(dimensions, title, monitor, gl_version, vsync, false)
}
}