diff options
Diffstat (limited to 'src/api/egl')
-rw-r--r-- | src/api/egl/ffi.rs | 2 | ||||
-rw-r--r-- | src/api/egl/mod.rs | 42 |
2 files changed, 23 insertions, 21 deletions
diff --git a/src/api/egl/ffi.rs b/src/api/egl/ffi.rs index 6a81ada..ae02e30 100644 --- a/src/api/egl/ffi.rs +++ b/src/api/egl/ffi.rs @@ -33,3 +33,5 @@ pub type EGLNativeWindowType = winapi::HWND; pub type EGLNativeWindowType = *const libc::c_void; #[cfg(target_os = "android")] pub type EGLNativeWindowType = *const libc::c_void; +#[cfg(any(target_os = "dragonfly", target_os = "freebsd"))] +pub type EGLNativeWindowType = *const libc::c_void; diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs index 32902e5..56b709d 100644 --- a/src/api/egl/mod.rs +++ b/src/api/egl/mod.rs @@ -1,12 +1,14 @@ -#![cfg(any(target_os = "windows", target_os = "linux", target_os = "android"))] +#![cfg(any(target_os = "windows", target_os = "linux", target_os = "android", + target_os = "dragonfly", target_os = "freebsd"))] #![allow(unused_variables)] -use BuilderAttribs; use ContextError; use CreationError; +use GlAttributes; use GlContext; use GlRequest; use PixelFormat; +use PixelFormatRequirements; use Robustness; use Api; @@ -157,11 +159,11 @@ impl Context { /// This function initializes some things and chooses the pixel format. /// /// To finish the process, you must call `.finish(window)` on the `ContextPrototype`. - pub fn new<'a>(egl: ffi::egl::Egl, builder: &'a BuilderAttribs<'a>, - native_display: NativeDisplay) + pub fn new<'a>(egl: ffi::egl::Egl, pf_reqs: &PixelFormatRequirements, + opengl: &'a GlAttributes<&'a Context>, native_display: NativeDisplay) -> Result<ContextPrototype<'a>, CreationError> { - if builder.sharing.is_some() { + if opengl.sharing.is_some() { unimplemented!() } @@ -196,7 +198,7 @@ impl Context { // binding the right API and choosing the version let (version, api) = unsafe { - match builder.gl_version { + match opengl.version { GlRequest::Latest => { if egl_version >= (1, 4) { if egl.BindAPI(ffi::egl::OPENGL_API) != 0 { @@ -245,10 +247,10 @@ impl Context { }; let configs = unsafe { try!(enumerate_configs(&egl, display, &egl_version, api, version)) }; - let (config_id, pixel_format) = try!(builder.choose_pixel_format(configs.into_iter())); + let (config_id, pixel_format) = try!(pf_reqs.choose_pixel_format(configs.into_iter())); Ok(ContextPrototype { - builder: builder, + opengl: opengl, egl: egl, display: display, egl_version: egl_version, @@ -329,7 +331,7 @@ impl Drop for Context { } pub struct ContextPrototype<'a> { - builder: &'a BuilderAttribs<'a>, + opengl: &'a GlAttributes<&'a Context>, egl: ffi::egl::Egl, display: ffi::egl::types::EGLDisplay, egl_version: (ffi::egl::types::EGLint, ffi::egl::types::EGLint), @@ -365,9 +367,7 @@ impl<'a> ContextPrototype<'a> { self.finish_impl(surface) } - pub fn finish_pbuffer(self) -> Result<Context, CreationError> { - let dimensions = self.builder.dimensions.unwrap_or((800, 600)); - + pub fn finish_pbuffer(self, dimensions: (u32, u32)) -> Result<Context, CreationError> { let attrs = &[ ffi::egl::WIDTH as libc::c_int, dimensions.0 as libc::c_int, ffi::egl::HEIGHT as libc::c_int, dimensions.1 as libc::c_int, @@ -393,18 +393,18 @@ impl<'a> ContextPrototype<'a> { if let Some(version) = self.version { try!(create_context(&self.egl, self.display, &self.egl_version, &self.extensions, self.api, version, self.config_id, - self.builder.gl_debug, self.builder.gl_robustness)) + self.opengl.debug, self.opengl.robustness)) } else if self.api == Api::OpenGlEs { if let Ok(ctxt) = create_context(&self.egl, self.display, &self.egl_version, &self.extensions, self.api, (2, 0), self.config_id, - self.builder.gl_debug, self.builder.gl_robustness) + self.opengl.debug, self.opengl.robustness) { ctxt } else if let Ok(ctxt) = create_context(&self.egl, self.display, &self.egl_version, &self.extensions, self.api, (1, 0), - self.config_id, self.builder.gl_debug, - self.builder.gl_robustness) + self.config_id, self.opengl.debug, + self.opengl.robustness) { ctxt } else { @@ -414,19 +414,19 @@ impl<'a> ContextPrototype<'a> { } else { if let Ok(ctxt) = create_context(&self.egl, self.display, &self.egl_version, &self.extensions, self.api, (3, 2), self.config_id, - self.builder.gl_debug, self.builder.gl_robustness) + self.opengl.debug, self.opengl.robustness) { ctxt } else if let Ok(ctxt) = create_context(&self.egl, self.display, &self.egl_version, &self.extensions, self.api, (3, 1), - self.config_id, self.builder.gl_debug, - self.builder.gl_robustness) + self.config_id, self.opengl.debug, + self.opengl.robustness) { ctxt } else if let Ok(ctxt) = create_context(&self.egl, self.display, &self.egl_version, &self.extensions, self.api, (1, 0), - self.config_id, self.builder.gl_debug, - self.builder.gl_robustness) + self.config_id, self.opengl.debug, + self.opengl.robustness) { ctxt } else { |