@@ -16,7 +16,7 @@ use winapi::um::winuser::{
1616} ;
1717
1818use std:: cell:: RefCell ;
19- use std:: ffi:: OsStr ;
19+ use std:: ffi:: { c_void , OsStr } ;
2020use std:: marker:: PhantomData ;
2121use std:: os:: windows:: ffi:: OsStrExt ;
2222use std:: ptr:: null_mut;
@@ -35,7 +35,7 @@ use crate::{
3535use super :: keyboard:: KeyboardState ;
3636
3737#[ cfg( feature = "opengl" ) ]
38- use crate :: gl:: GlContext ;
38+ use crate :: { gl:: GlContext , window :: RawWindowHandleWrapper } ;
3939
4040unsafe fn generate_guid ( ) -> String {
4141 let mut guid: GUID = std:: mem:: zeroed ( ) ;
@@ -84,7 +84,7 @@ unsafe impl HasRawWindowHandle for WindowHandle {
8484 fn raw_window_handle ( & self ) -> RawWindowHandle {
8585 if let Some ( hwnd) = self . hwnd {
8686 let mut handle = Win32Handle :: empty ( ) ;
87- handle. hwnd = hwnd as * mut std :: ffi :: c_void ;
87+ handle. hwnd = hwnd as * mut c_void ;
8888
8989 RawWindowHandle :: Win32 ( handle)
9090 } else {
@@ -483,8 +483,13 @@ impl Window {
483483 // todo: manage error ^
484484
485485 #[ cfg( feature = "opengl" ) ]
486- let gl_context: Arc < Option < GlContext > > =
487- Arc :: new ( todo ! ( "Create the Windows OpenGL context" ) ) ;
486+ let gl_context: Arc < Option < GlContext > > = Arc :: new ( options. gl_config . map ( |gl_config| {
487+ let mut handle = Win32Handle :: empty ( ) ;
488+ handle. hwnd = hwnd as * mut c_void ;
489+ let handle = RawWindowHandleWrapper { handle : RawWindowHandle :: Win32 ( handle) } ;
490+
491+ GlContext :: create ( & handle, gl_config) . expect ( "Could not create OpenGL context" )
492+ } ) ) ;
488493
489494 #[ cfg( not( feature = "opengl" ) ) ]
490495 let handler = Box :: new ( build ( & mut crate :: Window :: new ( & mut Window { hwnd } ) ) ) ;
@@ -583,7 +588,7 @@ impl Window {
583588unsafe impl HasRawWindowHandle for Window {
584589 fn raw_window_handle ( & self ) -> RawWindowHandle {
585590 let mut handle = Win32Handle :: empty ( ) ;
586- handle. hwnd = self . hwnd as * mut std :: ffi :: c_void ;
591+ handle. hwnd = self . hwnd as * mut c_void ;
587592
588593 RawWindowHandle :: Win32 ( handle)
589594 }
0 commit comments