Add a GlContext trait

This commit is contained in:
Pierre Krieger 2015-04-30 13:23:37 +02:00
parent a08388bca1
commit aa58f4149a
12 changed files with 332 additions and 190 deletions

View file

@ -1,6 +1,7 @@
use CreationError;
use CreationError::OsError;
use BuilderAttribs;
use GlContext;
use libc;
use std::ptr;
@ -56,8 +57,10 @@ impl HeadlessContext {
Ok(headless)
}
}
pub unsafe fn make_current(&self) {
impl GlContext for HeadlessContext {
unsafe fn make_current(&self) {
self.context.makeCurrentContext();
gl::GenFramebuffersEXT(1, &mut framebuffer);
@ -76,11 +79,11 @@ impl HeadlessContext {
}
}
pub fn is_current(&self) -> bool {
fn is_current(&self) -> bool {
unimplemented!()
}
pub fn get_proc_address(&self, _addr: &str) -> *const () {
fn get_proc_address(&self, _addr: &str) -> *const () {
let symbol_name: CFString = _addr.parse().unwrap();
let framework_name: CFString = "com.apple.opengl".parse().unwrap();
let framework = unsafe {
@ -92,9 +95,16 @@ impl HeadlessContext {
symbol as *const ()
}
pub fn get_api(&self) -> ::Api {
fn swap_buffers(&self) {
}
fn get_api(&self) -> ::Api {
::Api::OpenGl
}
fn get_pixel_format(&self) -> PixelFormat {
unimplemented!();
}
}
unsafe impl Send for HeadlessContext {}