aboutsummaryrefslogtreecommitdiffstats
path: root/src/win32
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-02-18 16:49:53 +0100
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-02-18 17:15:01 +0100
commitf4f84c6566d99c297cddee3c712e94927f313204 (patch)
treef5ec7a833a54ed5371e8470b859dba14c41a553b /src/win32
parent8f8c1b71bcb8a41d15f421602fb61b293f62f175 (diff)
downloadglutin-f4f84c6566d99c297cddee3c712e94927f313204.tar.gz
glutin-f4f84c6566d99c297cddee3c712e94927f313204.zip
Improve the OpenGL context request system
Diffstat (limited to 'src/win32')
-rw-r--r--src/win32/init.rs24
1 files changed, 18 insertions, 6 deletions
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 {