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/lib.rs | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'src/lib.rs') 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, - 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, -- cgit v1.2.3