aboutsummaryrefslogtreecommitdiffstats
path: root/src/api/egl
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-05-12 20:59:45 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-05-12 21:28:56 +0200
commitb3044809c229cdda865728308b2653b116bb63ce (patch)
treede4e9e7d8da9b2f16aad39229211c7760e92d280 /src/api/egl
parent3279f15f9f0ff24c644479e73923a0cb64f99fda (diff)
downloadglutin-b3044809c229cdda865728308b2653b116bb63ce.tar.gz
glutin-b3044809c229cdda865728308b2653b116bb63ce.zip
Fixes in EGL context creation
Diffstat (limited to 'src/api/egl')
-rw-r--r--src/api/egl/mod.rs31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/api/egl/mod.rs b/src/api/egl/mod.rs
index 8f9ebcf..a97ef62 100644
--- a/src/api/egl/mod.rs
+++ b/src/api/egl/mod.rs
@@ -9,7 +9,7 @@ use PixelFormat;
use Api;
use libc;
-use std::ffi::CString;
+use std::ffi::{CStr, CString};
use std::{mem, ptr};
pub mod ffi;
@@ -323,24 +323,37 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
gl_debug: bool)
-> Result<ffi::egl::types::EGLContext, ()>
{
+ let extensions = if egl_version >= &(1, 2) {
+ let p = CStr::from_ptr(egl.QueryString(display, ffi::egl::EXTENSIONS as i32));
+ String::from_utf8(p.to_bytes().to_vec()).unwrap_or_else(|_| format!(""))
+ } else {
+ format!("")
+ };
+
let mut context_attributes = vec![];
- if egl_version >= &(1, 5) {
+ if egl_version >= &(1, 5) ||
+ extensions.contains("EGL_KHR_create_context ") ||
+ extensions.ends_with("EGL_KHR_create_context")
+ {
context_attributes.push(ffi::egl::CONTEXT_MAJOR_VERSION as i32);
context_attributes.push(version.0 as i32);
context_attributes.push(ffi::egl::CONTEXT_MINOR_VERSION as i32);
context_attributes.push(version.1 as i32);
if gl_debug {
- context_attributes.push(ffi::egl::CONTEXT_OPENGL_DEBUG as i32);
- context_attributes.push(ffi::egl::TRUE as i32);
+ if egl_version >= &(1, 5) {
+ context_attributes.push(ffi::egl::CONTEXT_OPENGL_DEBUG as i32);
+ context_attributes.push(ffi::egl::TRUE as i32);
+ } else {
+ context_attributes.push(ffi::egl::CONTEXT_FLAGS_KHR as i32);
+ context_attributes.push(ffi::egl::CONTEXT_OPENGL_DEBUG_BIT_KHR as i32);
+ }
}
- } else {
- if api == Api::OpenGlEs {
- context_attributes.push(ffi::egl::CONTEXT_CLIENT_VERSION as i32);
- context_attributes.push(version.0 as i32);
- }
+ } else if egl_version >= &(1, 3) && api == Api::OpenGlEs {
+ context_attributes.push(ffi::egl::CONTEXT_CLIENT_VERSION as i32);
+ context_attributes.push(version.0 as i32);
}
context_attributes.push(ffi::egl::NONE as i32);