From 689ace8b251ceb2446fc460aad3dd19a1692f3f8 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 4 Mar 2015 07:38:55 +0100 Subject: Add is_current function --- src/win32/headless.rs | 5 +++++ src/win32/mod.rs | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'src/win32') diff --git a/src/win32/headless.rs b/src/win32/headless.rs index 1da8b02..6189360 100644 --- a/src/win32/headless.rs +++ b/src/win32/headless.rs @@ -20,6 +20,11 @@ impl HeadlessContext { self.0.make_current() } + /// See the docs in the crate root file. + pub fn is_current(&self) -> bool { + self.0.is_current() + } + /// See the docs in the crate root file. pub fn get_proc_address(&self, addr: &str) -> *const () { self.0.get_proc_address(addr) diff --git a/src/win32/mod.rs b/src/win32/mod.rs index 327b71d..8cb6d39 100644 --- a/src/win32/mod.rs +++ b/src/win32/mod.rs @@ -208,6 +208,11 @@ impl Window { self.context.0 as *const libc::c_void); } + /// See the docs in the crate root file. + pub fn is_current(&self) -> bool { + unsafe { gl::wgl::GetCurrentContext() == self.context.0 as *const libc::c_void } + } + /// See the docs in the crate root file. pub fn get_proc_address(&self, addr: &str) -> *const () { let addr = CString::new(addr.as_bytes()).unwrap(); -- cgit v1.2.3