grafix_toolbox/kit/opengl/
context.rs

1pub use offhand::*;
2
3pub mod event;
4pub mod window;
5
6#[derive(Debug)]
7pub struct Fence {
8	obj: gl::types::GLsync,
9}
10impl Fence {
11	pub fn new() -> Self {
12		let obj = GL!(gl::FenceSync(gl::SYNC_GPU_COMMANDS_COMPLETE, 0));
13		DEBUG!("Created GL Fence {obj:?}");
14		GL!(gl::Flush());
15		Self { obj }
16	}
17	pub fn Block(&self) {
18		while gl::TIMEOUT_EXPIRED == GL!(gl::ClientWaitSync(self.obj, 0, 16000000)) {}
19	}
20	pub fn BlockFor(&self, nanoseconds: u64) {
21		GL!(gl::ClientWaitSync(self.obj, 0, nanoseconds));
22		DEBUG!("Synced GL Fence {:?}", self.obj);
23	}
24}
25impl Default for Fence {
26	fn default() -> Self {
27		Self::new()
28	}
29}
30impl Drop for Fence {
31	fn drop(&mut self) {
32		DEBUG!("Deleting GL Fence {:?}", self.obj);
33		GL!(gl::DeleteSync(self.obj));
34	}
35}
36unsafe impl Send for Fence {}
37
38mod offhand;
39
40use crate::lib::*;