aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
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/lib.rs
parent8f8c1b71bcb8a41d15f421602fb61b293f62f175 (diff)
downloadglutin-f4f84c6566d99c297cddee3c712e94927f313204.tar.gz
glutin-f4f84c6566d99c297cddee3c712e94927f313204.zip
Improve the OpenGL context request system
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 1bd29bb..3798ffd 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -114,6 +114,30 @@ pub enum Api {
WebGl,
}
+/// Describes the OpenGL API and version that are being requested when a context is created.
+#[derive(Debug, Copy, Clone)]
+pub enum GlRequest {
+ /// Request the latest version of the "best" API of this platform.
+ ///
+ /// On desktop, will try OpenGL.
+ Latest,
+
+ /// Request a specific version of a specific API.
+ ///
+ /// Example: `GlRequest::Specific(Api::OpenGl, (3, 3))`.
+ Specific(Api, (u8, u8)),
+
+ /// If OpenGL is available, create an OpenGL context with the specified `opengl_version`.
+ /// Else if OpenGL ES or WebGL is available, create a context with the
+ /// specified `opengles_version`.
+ GlThenGles {
+ /// The version to use for OpenGL.
+ opengl_version: (u8, u8),
+ /// The version to use for OpenGL ES.
+ opengles_version: (u8, u8),
+ },
+}
+
#[derive(Debug, Copy)]
pub enum MouseCursor {
/// The platform-dependent default cursor.
@@ -194,7 +218,7 @@ struct BuilderAttribs<'a> {
dimensions: Option<(u32, u32)>,
title: String,
monitor: Option<winimpl::MonitorID>,
- gl_version: Option<(u32, u32)>,
+ gl_version: GlRequest,
gl_debug: bool,
vsync: bool,
visible: bool,
@@ -215,7 +239,7 @@ impl BuilderAttribs<'static> {
dimensions: None,
title: "glutin window".to_string(),
monitor: None,
- gl_version: None,
+ gl_version: GlRequest::Latest,
gl_debug: cfg!(ndebug),
vsync: false,
visible: true,