Improve the OpenGL context request system

This commit is contained in:
Pierre Krieger 2015-02-18 16:49:53 +01:00
parent 8f8c1b71bc
commit f4f84c6566
7 changed files with 101 additions and 29 deletions

View file

@ -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,