mirror of
https://github.com/rust-windowing/winit.git
synced 2026-09-01 06:10:07 -04:00
Fix glXCreateContextAttrib always null
This commit is contained in:
@@ -141,19 +141,33 @@ impl Window {
|
|||||||
|
|
||||||
// getting the pointer to glXCreateContextAttribs
|
// getting the pointer to glXCreateContextAttribs
|
||||||
let create_context_attribs = unsafe {
|
let create_context_attribs = unsafe {
|
||||||
let mut addr = unsafe { ffi::glXGetProcAddress(b"glXCreateContextAttribs".as_ptr()
|
// creating the dummy context
|
||||||
as *const u8) } as *const ();
|
let dummy_context =
|
||||||
|
ffi::glXCreateContext(display, &visual_infos, ptr::null(), 1);
|
||||||
|
ffi::glXMakeCurrent(display, window, dummy_context);
|
||||||
|
|
||||||
if addr.is_null() {
|
// getting the pointer
|
||||||
addr = unsafe { ffi::glXGetProcAddress(b"glXCreateContextAttribsARB".as_ptr()
|
let fn_ptr = {
|
||||||
|
let mut addr = unsafe { ffi::glXGetProcAddress(b"glXCreateContextAttribs".as_ptr()
|
||||||
as *const u8) } as *const ();
|
as *const u8) } as *const ();
|
||||||
}
|
|
||||||
|
|
||||||
addr.to_option().map(|addr| {
|
if addr.is_null() {
|
||||||
let addr: extern "system" fn(*mut ffi::Display, ffi::GLXFBConfig, ffi::GLXContext,
|
addr = unsafe { ffi::glXGetProcAddress(b"glXCreateContextAttribsARB".as_ptr()
|
||||||
ffi::Bool, *const libc::c_int) -> ffi::GLXContext = unsafe { mem::transmute(addr) };
|
as *const u8) } as *const ();
|
||||||
addr
|
}
|
||||||
})
|
|
||||||
|
addr.to_option().map(|addr| {
|
||||||
|
let addr: extern "system" fn(*mut ffi::Display, ffi::GLXFBConfig, ffi::GLXContext,
|
||||||
|
ffi::Bool, *const libc::c_int) -> ffi::GLXContext = mem::transmute(addr);
|
||||||
|
addr
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
// cleaning up
|
||||||
|
ffi::glXMakeCurrent(ptr::mut_null(), 0, ptr::null());
|
||||||
|
ffi::glXDestroyContext(display, dummy_context);
|
||||||
|
|
||||||
|
fn_ptr
|
||||||
};
|
};
|
||||||
|
|
||||||
// creating IM
|
// creating IM
|
||||||
|
|||||||
Reference in New Issue
Block a user