aboutsummaryrefslogtreecommitdiffstats
path: root/src/x11
diff options
context:
space:
mode:
authortomaka <pierre.krieger1708@gmail.com>2015-02-19 21:55:15 +0100
committertomaka <pierre.krieger1708@gmail.com>2015-02-19 21:55:15 +0100
commit8e1d0f7a976078ef7031ff84e077f00655d4e061 (patch)
treee03c5d40096b2545fe02fed2ec4668a3872cc3cd /src/x11
parent95d70ce549f776794a89c6c83d1df707b914ab8f (diff)
parentf4f84c6566d99c297cddee3c712e94927f313204 (diff)
downloadglutin-8e1d0f7a976078ef7031ff84e077f00655d4e061.tar.gz
glutin-8e1d0f7a976078ef7031ff84e077f00655d4e061.zip
Merge pull request #282 from tomaka/gl-api
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 {