|
1 | 1 | use std::ffi::{c_void, CString}; |
2 | 2 | use std::os::raw::{c_int, c_ulong}; |
3 | 3 |
|
4 | | -use raw_window_handle::{HasRawWindowHandle, RawWindowHandle}; |
5 | | - |
6 | 4 | use x11::glx; |
7 | 5 | use x11::xlib; |
8 | 6 |
|
@@ -80,20 +78,12 @@ impl GlContext { |
80 | 78 | /// |
81 | 79 | /// Use [Self::get_fb_config_and_visual] to create both of these things. |
82 | 80 | pub unsafe fn create( |
83 | | - parent: &impl HasRawWindowHandle, config: FbConfig, |
| 81 | + window: c_ulong, display: *mut xlib::_XDisplay, config: FbConfig, |
84 | 82 | ) -> Result<GlContext, GlError> { |
85 | | - let handle = if let RawWindowHandle::Xlib(handle) = parent.raw_window_handle() { |
86 | | - handle |
87 | | - } else { |
88 | | - return Err(GlError::InvalidWindowHandle); |
89 | | - }; |
90 | | - |
91 | | - if handle.display.is_null() { |
| 83 | + if display.is_null() { |
92 | 84 | return Err(GlError::InvalidWindowHandle); |
93 | 85 | } |
94 | 86 |
|
95 | | - let display = handle.display as *mut xlib::_XDisplay; |
96 | | - |
97 | 87 | errors::XErrorHandler::handle(display, |error_handler| { |
98 | 88 | #[allow(non_snake_case)] |
99 | 89 | let glXCreateContextAttribsARB: GlXCreateContextAttribsARB = { |
@@ -144,21 +134,21 @@ impl GlContext { |
144 | 134 | return Err(GlError::CreationFailed(CreationFailedError::ContextCreationFailed)); |
145 | 135 | } |
146 | 136 |
|
147 | | - let res = glx::glXMakeCurrent(display, handle.window, context); |
| 137 | + let res = glx::glXMakeCurrent(display, window, context); |
148 | 138 | error_handler.check()?; |
149 | 139 | if res == 0 { |
150 | 140 | return Err(GlError::CreationFailed(CreationFailedError::MakeCurrentFailed)); |
151 | 141 | } |
152 | 142 |
|
153 | | - glXSwapIntervalEXT(display, handle.window, config.gl_config.vsync as i32); |
| 143 | + glXSwapIntervalEXT(display, window, config.gl_config.vsync as i32); |
154 | 144 | error_handler.check()?; |
155 | 145 |
|
156 | 146 | if glx::glXMakeCurrent(display, 0, std::ptr::null_mut()) == 0 { |
157 | 147 | error_handler.check()?; |
158 | 148 | return Err(GlError::CreationFailed(CreationFailedError::MakeCurrentFailed)); |
159 | 149 | } |
160 | 150 |
|
161 | | - Ok(GlContext { window: handle.window, display, context }) |
| 151 | + Ok(GlContext { window, display, context }) |
162 | 152 | }) |
163 | 153 | } |
164 | 154 |
|
|
0 commit comments