use egl;
pub struct Context {
terminated: bool,
display_handle: egl::EGLDisplay,
handle: egl::EGLContext,
}
impl Drop for Context {
fn drop(&mut self) {
if !self.terminated {
trace!("destroy context");
let _ = egl::destroy_context(self.display_handle, self.handle);
}
}
}
impl Into<egl::EGLContext> for Context {
fn into(self) -> egl::EGLContext {
self.forget()
}
}
impl Context {
pub fn from_handle(display_handle: egl::EGLDisplay,
context_handle: egl::EGLSurface)
-> Context {
Context {
terminated: false,
display_handle: display_handle,
handle: context_handle,
}
}
pub fn handle(&self) -> egl::EGLContext {
self.handle
}
pub fn forget(mut self) -> egl::EGLContext {
self.terminated = true;
self.handle
}
}