mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-23 22:01:31 +11:00
Fixes in EGL context creation
This commit is contained in:
parent
3279f15f9f
commit
b3044809c2
9
build.rs
9
build.rs
|
@ -65,7 +65,9 @@ fn main() {
|
|||
gl_generator::registry::Ns::Egl,
|
||||
gl_generator::Fallbacks::All,
|
||||
khronos_api::EGL_XML,
|
||||
vec![],
|
||||
vec![
|
||||
"EGL_KHR_create_context".to_string()
|
||||
],
|
||||
"1.5", "core", &mut file).unwrap();
|
||||
}
|
||||
|
||||
|
@ -74,7 +76,10 @@ fn main() {
|
|||
gl_generator::generate_bindings(gl_generator::StaticStructGenerator,
|
||||
gl_generator::registry::Ns::Egl,
|
||||
gl_generator::Fallbacks::All,
|
||||
khronos_api::EGL_XML, vec![],
|
||||
khronos_api::EGL_XML,
|
||||
vec![
|
||||
"EGL_KHR_create_context".to_string()
|
||||
],
|
||||
"1.5", "core", &mut file).unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -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,25 +323,38 @@ 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 {
|
||||
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 {
|
||||
} 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue