From 6debc4f3351446417d0c4e38173cd9ef0faa71d5 Mon Sep 17 00:00:00 2001 From: YOSHIOKA Takuma Date: Tue, 13 Mar 2018 20:16:01 +0900 Subject: Try to create window with different SRGB config when failed This may truly solve #921 (and issue caused by #1178) . --- src/window.rs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/window.rs b/src/window.rs index 0f527a4f..42a1785e 100644 --- a/src/window.rs +++ b/src/window.rs @@ -183,6 +183,17 @@ impl From for Error { } } +fn create_gl_window( + window: WindowBuilder, + event_loop: &EventsLoop, + srgb: bool, +) -> ::std::result::Result { + let context = ContextBuilder::new() + .with_srgb(srgb) + .with_vsync(true); + ::glutin::GlWindow::new(window, context, event_loop) +} + impl Window { /// Create a new window /// @@ -199,10 +210,8 @@ impl Window { .with_visibility(false) .with_transparency(true) .with_decorations(window_config.decorations()); - let context = ContextBuilder::new() - .with_srgb(true) - .with_vsync(true); - let window = ::glutin::GlWindow::new(window, context, &event_loop)?; + let window = create_gl_window(window.clone(), &event_loop, false) + .or_else(|_| create_gl_window(window, &event_loop, true))?; window.show(); // Text cursor -- cgit