aboutsummaryrefslogtreecommitdiff
path: root/src/window.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/window.rs')
-rw-r--r--src/window.rs17
1 files changed, 13 insertions, 4 deletions
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<glutin::ContextError> for Error {
}
}
+fn create_gl_window(
+ window: WindowBuilder,
+ event_loop: &EventsLoop,
+ srgb: bool,
+) -> ::std::result::Result<glutin::GlWindow, glutin::CreationError> {
+ 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