aboutsummaryrefslogtreecommitdiffstats
path: root/src/api
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-07-27 09:21:13 +0200
committertomaka <pierre.krieger1708@gmail.com>2015-07-27 09:21:13 +0200
commit991b15df873136d4e7e41590cf2ffc54619b14dd (patch)
treed5a732dcbd4f2876744a52346dbcf694060f860a /src/api
parent7e1e05663b7c32efef5740435bf0e8979a8e1fb3 (diff)
parent653fbde98754e065da36661e077d81bffcc54052 (diff)
downloadglutin-991b15df873136d4e7e41590cf2ffc54619b14dd.tar.gz
glutin-991b15df873136d4e7e41590cf2ffc54619b14dd.zip
Merge pull request #548 from tomaka/egl-pbuffer
Add support for creating a pbuffer with EGL
Diffstat (limited to 'src/api')
-rw-r--r--src/api/egl/mod.rs31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs
index 8817f9d..a54fb77 100644
--- a/src/api/egl/mod.rs
+++ b/src/api/egl/mod.rs
@@ -224,6 +224,33 @@ impl<'a> ContextPrototype<'a> {
surface
};
+ self.finish_impl(surface)
+ }
+
+ pub fn finish_pbuffer(self) -> Result<Context, CreationError> {
+ let dimensions = self.builder.dimensions.unwrap_or((800, 600));
+
+ 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,
+ ffi::egl::NONE as libc::c_int,
+ ];
+
+ let surface = unsafe {
+ let surface = self.egl.CreatePbufferSurface(self.display, self.config_id,
+ attrs.as_ptr());
+ if surface.is_null() {
+ return Err(CreationError::OsError(format!("eglCreatePbufferSurface failed")))
+ }
+ surface
+ };
+
+ self.finish_impl(surface)
+ }
+
+ fn finish_impl(self, surface: ffi::egl::types::EGLSurface)
+ -> Result<Context, CreationError>
+ {
let context = unsafe {
if let Some(version) = self.version {
try!(create_context(&self.egl, self.display, &self.egl_version, self.api,
@@ -349,7 +376,9 @@ unsafe fn enumerate_configs(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDi
}
}
- if attrib!(egl, display, config_id, ffi::egl::SURFACE_TYPE) & ffi::egl::WINDOW_BIT as i32 == 0 {
+ if attrib!(egl, display, config_id, ffi::egl::SURFACE_TYPE) &
+ (ffi::egl::WINDOW_BIT | ffi::egl::PBUFFER_BIT) as i32 == 0
+ {
continue;
}