gl_types/
lib.rs

1#![no_std]
2#![allow(non_camel_case_types)]
3
4//! Provides the types for OpenGL and OpenGL ES.
5
6pub use core::ffi::c_void;
7
8/// `typedef unsigned char GLboolean;`
9///
10/// This is provided as a full newtype wrapper,
11/// rather than just an alias, so that correct
12/// trait impls can be provided to make this easy
13/// to work with.
14#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
15#[repr(transparent)]
16pub struct GLboolean(core::ffi::c_uchar);
17impl GLboolean {
18  pub const FALSE: Self = Self(false as _);
19  pub const TRUE: Self = Self(true as _);
20}
21impl From<bool> for GLboolean {
22  #[inline]
23  #[must_use]
24  fn from(b: bool) -> Self {
25    Self(b as _)
26  }
27}
28impl From<GLboolean> for bool {
29  #[inline]
30  #[must_use]
31  fn from(b: GLboolean) -> Self {
32    b.0 != 0
33  }
34}
35impl From<GLboolean> for GLenum {
36  #[inline]
37  #[must_use]
38  fn from(b: GLboolean) -> Self {
39    GLenum::from(bool::from(b))
40  }
41}
42impl core::fmt::Debug for GLboolean {
43  #[inline]
44  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
45    core::fmt::Debug::fmt(&bool::from(*self), f)
46  }
47}
48impl core::fmt::Display for GLboolean {
49  #[inline]
50  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
51    core::fmt::Display::fmt(&bool::from(*self), f)
52  }
53}
54
55/// `typedef unsigned int GLenum;`
56pub type GLenum = core::ffi::c_uint;
57
58/// `typedef unsigned int GLbitfield;`
59pub type GLbitfield = core::ffi::c_uint;
60
61/// `typedef void GLvoid;`
62pub type GLvoid = c_void;
63
64/// `typedef khronos_int8_t GLbyte;`
65pub type GLbyte = i8;
66
67/// `typedef khronos_uint8_t GLubyte;`
68pub type GLubyte = u8;
69
70/// `typedef khronos_int16_t GLshort;`
71pub type GLshort = i16;
72
73/// `typedef khronos_uint16_t GLushort;`
74pub type GLushort = u16;
75
76/// `typedef int GLint;`
77pub type GLint = core::ffi::c_int;
78
79/// `typedef unsigned int GLuint;`
80pub type GLuint = core::ffi::c_uint;
81
82/// `typedef khronos_int32_t GLclampx;`
83pub type GLclampx = i32;
84
85/// `typedef int GLsizei;`
86pub type GLsizei = core::ffi::c_int;
87
88/// `typedef khronos_float_t GLfloat;`
89pub type GLfloat = core::ffi::c_float;
90
91/// `typedef khronos_float_t GLclampf;`
92pub type GLclampf = core::ffi::c_float;
93
94/// `typedef double GLdouble;`
95pub type GLdouble = core::ffi::c_double;
96
97/// `typedef double GLclampd;`
98pub type GLclampd = core::ffi::c_double;
99
100/// `typedef void * GLeglClientBufferEXT;`
101pub type GLeglClientBufferEXT = *mut c_void;
102
103/// `typedef void * GLeglImageOES;`
104pub type GLeglImageOES = *mut c_void;
105
106/// `typedef char GLchar;`
107pub type GLchar = core::ffi::c_char;
108
109/// `typedef char GLcharARB;`
110pub type GLcharARB = core::ffi::c_char;
111
112/// ```c
113/// #ifdef __APPLE__
114/// typedef void *GLhandleARB;
115/// #else
116/// typedef unsigned int GLhandleARB;
117/// #endif
118/// ````
119#[cfg(any(target_os = "ios", target_os = "macos"))]
120pub type GLhandleARB = *mut c_void;
121
122/// ```c
123/// #ifdef __APPLE__
124/// typedef void *GLhandleARB;
125/// #else
126/// typedef unsigned int GLhandleARB;
127/// #endif
128/// ````
129#[cfg(not(any(target_os = "ios", target_os = "macos")))]
130pub type GLhandleARB = GLuint;
131
132/// `typedef khronos_uint16_t GLhalf;`
133pub type GLhalf = u16;
134
135/// `typedef khronos_uint16_t GLhalfARB;`
136pub type GLhalfARB = u16;
137
138/// `typedef khronos_int32_t GLfixed;`
139pub type GLfixed = i32;
140
141/// `typedef khronos_intptr_t GLintptr;`
142pub type GLintptr = isize;
143
144/// `typedef khronos_intptr_t GLintptrARB;`
145pub type GLintptrARB = isize;
146
147/// `typedef khronos_ssize_t GLsizeiptr;`
148pub type GLsizeiptr = isize;
149
150/// `typedef khronos_ssize_t GLsizeiptrARB;`
151pub type GLsizeiptrARB = isize;
152
153/// `typedef khronos_int64_t GLint64;`
154pub type GLint64 = i64;
155
156/// `typedef khronos_int64_t GLint64EXT;`
157pub type GLint64EXT = i64;
158
159/// `typedef khronos_uint64_t GLuint64;`
160pub type GLuint64 = u64;
161
162/// `typedef khronos_uint64_t GLuint64EXT;`
163pub type GLuint64EXT = u64;
164
165/// `typedef struct __GLsync * GLsync;`
166pub type GLsync = *mut c_void;
167
168/// `struct _cl_context;`
169pub type _cl_context = c_void;
170
171/// `struct _cl_event;`
172pub type _cl_event = c_void;
173
174/// ```c
175/// typedef void (*GLDEBUGPROC)(
176///   GLenum source,
177///   GLenum type,
178///   GLuint id,
179///   GLenum severity,
180///   GLsizei length,
181///   const GLchar *message,
182///   const void *userParam
183/// );
184/// ```
185pub type GLDEBUGPROC = Option<
186  unsafe extern "system" fn(GLenum, GLenum, GLuint, GLenum, GLsizei, *const GLchar, *const c_void),
187>;
188
189/// ```c
190/// typedef void (*GLDEBUGPROCARB)(
191///   GLenum source,
192///   GLenum type,
193///   GLuint id,
194///   GLenum severity,
195///   GLsizei length,
196///   const GLchar *message,
197///   const void *userParam
198/// );
199/// ````
200pub type GLDEBUGPROCARB = Option<
201  unsafe extern "system" fn(GLenum, GLenum, GLuint, GLenum, GLsizei, *const GLchar, *const c_void),
202>;
203
204/// ```c
205/// typedef void (*GLDEBUGPROCKHR)(
206///   GLenum source,
207///   GLenum type,
208///   GLuint id,
209///   GLenum severity,
210///   GLsizei length,
211///   const GLchar *message,
212///   const void *userParam
213/// );
214/// ```
215pub type GLDEBUGPROCKHR = Option<
216  unsafe extern "system" fn(GLenum, GLenum, GLuint, GLenum, GLsizei, *const GLchar, *const c_void),
217>;
218
219/// ```c
220/// typedef void (*GLDEBUGPROCAMD)(
221///   GLuint id,
222///   GLenum category,
223///   GLenum severity,
224///   GLsizei length,
225///   const GLchar *message,
226///   void *userParam
227/// );
228/// ```
229pub type GLDEBUGPROCAMD =
230  Option<unsafe extern "system" fn(GLuint, GLenum, GLenum, GLsizei, *const GLchar, *mut c_void)>;
231
232/// `typedef unsigned short GLhalfNV;`
233pub type GLhalfNV = core::ffi::c_ushort;
234
235/// `typedef GLintptr GLvdpauSurfaceNV;`
236pub type GLvdpauSurfaceNV = isize;
237
238/// `typedef void (*GLVULKANPROCNV)(void);`
239pub type GLVULKANPROCNV = Option<unsafe extern "system" fn()>;