From f4f84c6566d99c297cddee3c712e94927f313204 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 18 Feb 2015 16:49:53 +0100 Subject: Improve the OpenGL context request system --- src/win32/init.rs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/win32') diff --git a/src/win32/init.rs b/src/win32/init.rs index 90a6035..8a91214 100644 --- a/src/win32/init.rs +++ b/src/win32/init.rs @@ -5,9 +5,12 @@ use std::os; use super::callback; use super::Window; use super::MonitorID; + +use Api; use BuilderAttribs; use CreationError; use CreationError::OsError; +use GlRequest; use PixelFormat; use std::ffi::CString; @@ -353,12 +356,21 @@ fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'static>)> if extra_functions.CreateContextAttribsARB.is_loaded() { let mut attributes = Vec::new(); - if builder.gl_version.is_some() { - let version = builder.gl_version.as_ref().unwrap(); - attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int); - attributes.push(version.0 as libc::c_int); - attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int); - attributes.push(version.1 as libc::c_int); + match builder.gl_version { + GlRequest::Latest => {}, + GlRequest::Specific(Api::OpenGl, (major, minor)) => { + attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int); + attributes.push(major as libc::c_int); + attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int); + attributes.push(minor as libc::c_int); + }, + GlRequest::Specific(_, _) => panic!("Only OpenGL is supported"), + GlRequest::GlThenGles { opengl_version: (major, minor), .. } => { + attributes.push(gl::wgl_extra::CONTEXT_MAJOR_VERSION_ARB as libc::c_int); + attributes.push(major as libc::c_int); + attributes.push(gl::wgl_extra::CONTEXT_MINOR_VERSION_ARB as libc::c_int); + attributes.push(minor as libc::c_int); + }, } if builder.gl_debug { -- cgit v1.2.3