surfman/info.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
// surfman/surfman/src/info.rs
//
//! OpenGL information.
use crate::Gl;
use glow::HasContext;
/// The API (OpenGL or OpenGL ES).
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum GLApi {
/// OpenGL (full or desktop OpenGL).
GL,
/// OpenGL ES (embedded OpenGL).
GLES,
}
/// Describes the OpenGL version that is requested when a context is created.
///
/// Since OpenGL and OpenGL ES have different version numbering schemes, the valid values here
/// depend on the value of `Device::gl_api()`.
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GLVersion {
/// The major OpenGL version (e.g. 4 in 4.2).
pub major: u8,
/// The minor OpenGL version (e.g. 2 in 4.2).
pub minor: u8,
}
impl GLVersion {
/// Creates a GL version structure with the given major and minor version numbers.
#[inline]
pub fn new(major: u8, minor: u8) -> GLVersion {
GLVersion { major, minor }
}
#[allow(dead_code)]
pub(crate) fn current(gl: &Gl) -> GLVersion {
let version = gl.version();
Self {
major: version.major as u8,
minor: version.minor as u8,
}
}
}