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