aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/android/mod.rs9
-rw-r--r--src/cocoa/headless.rs4
-rw-r--r--src/cocoa/mod.rs4
-rw-r--r--src/headless.rs6
-rw-r--r--src/win32/headless.rs5
-rw-r--r--src/win32/mod.rs5
-rw-r--r--src/window.rs6
-rw-r--r--src/x11/headless.rs4
-rw-r--r--src/x11/window/mod.rs4
9 files changed, 47 insertions, 0 deletions
diff --git a/src/android/mod.rs b/src/android/mod.rs
index 84d71c2..3c01b4c 100644
--- a/src/android/mod.rs
+++ b/src/android/mod.rs
@@ -62,6 +62,11 @@ impl HeadlessContext {
}
/// See the docs in the crate root file.
+ pub fn is_current(&self) -> bool {
+ unimplemented!()
+ }
+
+ /// See the docs in the crate root file.
pub fn get_proc_address(&self, _addr: &str) -> *const () {
unimplemented!()
}
@@ -312,6 +317,10 @@ impl Window {
}
}
+ pub fn is_current(&self) -> bool {
+ unsafe { ffi::egl::GetCurrentContext() == self.context }
+ }
+
pub fn get_proc_address(&self, addr: &str) -> *const () {
let addr = CString::from_slice(addr.as_bytes());
let addr = addr.as_ptr();
diff --git a/src/cocoa/headless.rs b/src/cocoa/headless.rs
index fb91a0a..298027f 100644
--- a/src/cocoa/headless.rs
+++ b/src/cocoa/headless.rs
@@ -76,6 +76,10 @@ impl HeadlessContext {
}
}
+ pub fn is_current(&self) -> bool {
+ unimplemented!()
+ }
+
pub fn get_proc_address(&self, _addr: &str) -> *const () {
let symbol_name: CFString = _addr.parse().unwrap();
let framework_name: CFString = "com.apple.opengl".parse().unwrap();
diff --git a/src/cocoa/mod.rs b/src/cocoa/mod.rs
index e39df9f..9819319 100644
--- a/src/cocoa/mod.rs
+++ b/src/cocoa/mod.rs
@@ -587,6 +587,10 @@ impl Window {
self.context.makeCurrentContext();
}
+ pub fn is_current(&self) -> bool {
+ unimplemented!()
+ }
+
pub fn get_proc_address(&self, _addr: &str) -> *const () {
let symbol_name: CFString = FromStr::from_str(_addr).unwrap();
let framework_name: CFString = FromStr::from_str("com.apple.opengl").unwrap();
diff --git a/src/headless.rs b/src/headless.rs
index a38c194..5106a7b 100644
--- a/src/headless.rs
+++ b/src/headless.rs
@@ -77,6 +77,12 @@ impl HeadlessContext {
pub unsafe fn make_current(&self) {
self.context.make_current()
}
+
+ /// Returns true if this context is the current one in this thread.
+ #[inline]
+ pub fn is_current(&self) -> bool {
+ self.context.is_current()
+ }
/// Returns the address of an OpenGL function.
///
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
@@ -21,6 +21,11 @@ impl HeadlessContext {
}
/// 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
@@ -209,6 +209,11 @@ impl Window {
}
/// 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();
let addr = addr.as_ptr();
diff --git a/src/window.rs b/src/window.rs
index 6b2269f..1bab245 100644
--- a/src/window.rs
+++ b/src/window.rs
@@ -329,6 +329,12 @@ impl Window {
self.window.make_current()
}
+ /// Returns true if this context is the current one in this thread.
+ #[inline]
+ pub fn is_current(&self) -> bool {
+ self.window.is_current()
+ }
+
/// Returns the address of an OpenGL function.
///
/// Contrary to `wglGetProcAddress`, all available OpenGL functions return an address.
diff --git a/src/x11/headless.rs b/src/x11/headless.rs
index ca47414..e23dfa7 100644
--- a/src/x11/headless.rs
+++ b/src/x11/headless.rs
@@ -47,6 +47,10 @@ impl HeadlessContext {
}
}
+ pub fn is_current(&self) -> bool {
+ unsafe { ffi::OSMesaGetCurrentContext() == self.context }
+ }
+
pub fn get_proc_address(&self, addr: &str) -> *const () {
unsafe {
with_c_str(addr, |s| {
diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs
index 8664b4a..404324a 100644
--- a/src/x11/window/mod.rs
+++ b/src/x11/window/mod.rs
@@ -701,6 +701,10 @@ impl Window {
}
}
+ pub fn is_current(&self) -> bool {
+ unsafe { ffi::glx::GetCurrentContext() == self.x.context }
+ }
+
pub fn get_proc_address(&self, addr: &str) -> *const () {
use std::mem;