aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-07-25 16:42:11 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-07-27 08:33:48 +0200
commit653fbde98754e065da36661e077d81bffcc54052 (patch)
tree291b553b5acc977e3d7393976003e829aa17facb
parent15dfbd1ef622fbd3c3475e429422275ca1798d48 (diff)
downloadglutin-653fbde98754e065da36661e077d81bffcc54052.tar.gz
glutin-653fbde98754e065da36661e077d81bffcc54052.zip
Add support for creating a pbuffer with EGL
-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 328a11e..b66417f 100644
--- a/src/api/egl/mod.rs
+++ b/src/api/egl/mod.rs
@@ -226,6 +226,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,
@@ -351,7 +378,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;
}