aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11
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/x11
parent8f8c1b71bcb8a41d15f421602fb61b293f62f175 (diff)
downloadglutin-f4f84c6566d99c297cddee3c712e94927f313204.tar.gz
glutin-f4f84c6566d99c297cddee3c712e94927f313204.zip
Improve the OpenGL context request system
Diffstat (limited to 'src/x11')
-rw-r--r--src/x11/window/mod.rs24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/x11/window/mod.rs b/src/x11/window/mod.rs
index 05fcf14..f8afc08 100644
--- a/src/x11/window/mod.rs
+++ b/src/x11/window/mod.rs
@@ -10,6 +10,9 @@ use super::ffi;
use std::sync::{Arc, Mutex, Once, ONCE_INIT, Weak};
use std::sync::{StaticMutex, MUTEX_INIT};
+use Api;
+use GlRequest;
+
pub use self::monitor::{MonitorID, get_available_monitors, get_primary_monitor};
mod events;
@@ -483,12 +486,21 @@ impl Window {
let (context, extra_functions) = unsafe {
let mut attributes = Vec::new();
- if builder.gl_version.is_some() {
- let version = builder.gl_version.as_ref().unwrap();
- attributes.push(ffi::GLX_CONTEXT_MAJOR_VERSION);
- attributes.push(version.0 as libc::c_int);
- attributes.push(ffi::GLX_CONTEXT_MINOR_VERSION);
- attributes.push(version.1 as libc::c_int);
+ match builder.gl_version {
+ GlRequest::Latest => {},
+ GlRequest::Specific(Api::OpenGl, (major, minor)) => {
+ attributes.push(ffi::GLX_CONTEXT_MAJOR_VERSION);
+ attributes.push(major as libc::c_int);
+ attributes.push(ffi::GLX_CONTEXT_MINOR_VERSION);
+ attributes.push(minor as libc::c_int);
+ },
+ GlRequest::Specific(_, _) => panic!("Only OpenGL is supported"),
+ GlRequest::GlThenGles { opengl_version: (major, minor), .. } => {
+ attributes.push(ffi::GLX_CONTEXT_MAJOR_VERSION);
+ attributes.push(major as libc::c_int);
+ attributes.push(ffi::GLX_CONTEXT_MINOR_VERSION);
+ attributes.push(minor as libc::c_int);
+ },
}
if builder.gl_debug {