makepad_platform/os/linux/
gl_sys.rs

1#![allow(non_snake_case)]
2#![allow(non_upper_case_globals)]
3
4use std::mem;
5use std::os::raw;
6
7pub mod types {
8    use super::raw;
9    pub type GLenum = raw::c_uint;
10    pub type GLsizei = raw::c_int;
11    pub type GLuint = raw::c_uint;
12    pub type GLint = raw::c_int;
13    pub type GLdouble = raw::c_double;
14    pub type GLfloat = raw::c_float;
15    pub type GLbitfield = raw::c_uint;
16    pub type GLboolean = raw::c_uchar;
17    pub type GLchar = raw::c_char;
18    pub type GLubyte = raw::c_uchar;
19    pub type GLsizeiptr = isize; 
20}
21pub use types::*; 
22
23pub const TRUE: types::GLboolean = 1;
24pub const ARRAY_BUFFER: types::GLenum = 0x8892;
25pub const FLOAT: types::GLenum = 0x1406;
26pub const ELEMENT_ARRAY_BUFFER: types::GLenum = 0x8893;
27pub const TEXTURE0: types::GLenum = 0x84C0;
28pub const TEXTURE_2D: types::GLenum = 0x0DE1;
29pub const TRIANGLES: types::GLenum = 0x0004;
30pub const UNSIGNED_INT: types::GLenum = 0x1405;
31pub const DEPTH_TEST: types::GLenum = 0x0B71;
32pub const LEQUAL: types::GLenum = 0x0203;
33pub const FUNC_ADD: types::GLenum = 0x8006;
34pub const ONE: types::GLenum = 1;
35pub const ONE_MINUS_SRC_ALPHA: types::GLenum = 0x0303;
36pub const BLEND: types::GLenum = 0x0BE2;
37pub const FRAMEBUFFER: types::GLenum = 0x8D40;
38pub const COLOR_BUFFER_BIT: types::GLenum = 0x00004000;
39pub const DEPTH_BUFFER_BIT: types::GLenum = 0x00000100;
40pub const RENDERBUFFER: types::GLenum = 0x8D41;
41pub const DEPTH_COMPONENT16: types::GLenum = 0x81A5;
42pub const DEPTH_ATTACHMENT: types::GLenum = 0x8D00;
43pub const COLOR_ATTACHMENT0: types::GLenum = 0x8CE0;
44pub const INFO_LOG_LENGTH: types::GLenum = 0x8B84;
45pub const COMPILE_STATUS: types::GLenum = 0x8B81;
46pub const LINK_STATUS: types::GLenum = 0x8B82;
47pub const VERTEX_SHADER: types::GLenum = 0x8B31;
48pub const FRAGMENT_SHADER: types::GLenum = 0x8B30;
49pub const TEXTURE_MIN_FILTER: types::GLenum = 0x2801;
50pub const LINEAR: types::GLenum = 0x2601;
51pub const LINEAR_MIPMAP_LINEAR: types::GLenum = 0x2703;
52pub const TEXTURE_BASE_LEVEL: types::GLenum = 0x813C;
53pub const TEXTURE_MAX_LEVEL: types::GLenum = 0x813D;
54pub const TEXTURE_MAG_FILTER: types::GLenum = 0x2800;
55pub const RGBA: types::GLenum = 0x1908;
56pub const UNSIGNED_BYTE: types::GLenum = 0x1401;
57pub const DEPTH_COMPONENT32F: types::GLenum = 0x8CAC;
58pub const STATIC_DRAW: types::GLenum = 0x88E4;
59pub const NEAREST: types::GLenum = 0x2600;
60pub const TEXTURE_WRAP_S: types::GLenum = 0x2802;
61pub const TEXTURE_WRAP_T: types::GLenum = 0x2803;
62pub const CLAMP_TO_EDGE: types::GLenum = 0x812F;
63pub const PROGRAM_BINARY_LENGTH: types::GLenum = 0x8741;
64pub const NO_ERROR: types::GLenum = 0x0;
65
66#[inline] pub unsafe fn GenVertexArrays(n: types::GLsizei, arrays: *mut types::GLuint) -> () {mem::transmute::<_, extern "system" fn(types::GLsizei, *mut types::GLuint) -> ()>(storage::GenVertexArrays.f)(n, arrays)}
67#[inline] pub unsafe fn BindVertexArray(array: types::GLuint) -> () {mem::transmute::<_, extern "system" fn(types::GLuint) -> ()>(storage::BindVertexArray.f)(array)}
68#[inline] pub unsafe fn BindBuffer(target: types::GLenum, buffer: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLuint) -> ()>(storage::BindBuffer.f)(target, buffer) }
69#[inline] pub unsafe fn VertexAttribPointer(index: types::GLuint, size: types::GLint, type_: types::GLenum, normalized: types::GLboolean, stride: types::GLsizei, pointer: *const raw::c_void) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLint, types::GLenum, types::GLboolean, types::GLsizei, *const raw::c_void) -> ()>(storage::VertexAttribPointer.f)(index, size, type_, normalized, stride, pointer) }
70#[inline] pub unsafe fn EnableVertexAttribArray(index: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint) -> ()>(storage::EnableVertexAttribArray.f)(index) }
71#[inline] pub unsafe fn VertexAttribDivisor(index: types::GLuint, divisor: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLuint) -> ()>(storage::VertexAttribDivisor.f)(index, divisor) }
72#[inline] pub unsafe fn UseProgram(program: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint) -> ()>(storage::UseProgram.f)(program) }
73#[inline] pub unsafe fn ActiveTexture(texture: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum) -> ()>(storage::ActiveTexture.f)(texture) }
74#[inline] pub unsafe fn BindTexture(target: types::GLenum, texture: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLuint) -> ()>(storage::BindTexture.f)(target, texture) }
75#[inline] pub unsafe fn DrawElementsInstanced(mode: types::GLenum, count: types::GLsizei, type_: types::GLenum, indices: *const raw::c_void, instancecount: types::GLsizei) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLsizei, types::GLenum, *const raw::c_void, types::GLsizei) -> ()>(storage::DrawElementsInstanced.f)(mode, count, type_, indices, instancecount) }
76#[inline] pub unsafe fn Enable(cap: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum) -> ()>(storage::Enable.f)(cap) }
77#[inline] pub unsafe fn DepthFunc(func: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum) -> ()>(storage::DepthFunc.f)(func) }
78#[inline] pub unsafe fn BlendEquationSeparate(modeRGB: types::GLenum, modeAlpha: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLenum) -> ()>(storage::BlendEquationSeparate.f)(modeRGB, modeAlpha) }
79#[inline] pub unsafe fn BlendFuncSeparate(sfactorRGB: types::GLenum, dfactorRGB: types::GLenum, sfactorAlpha: types::GLenum, dfactorAlpha: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLenum, types::GLenum, types::GLenum) -> ()>(storage::BlendFuncSeparate.f)(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha) }
80#[inline] pub unsafe fn Viewport(x: types::GLint, y: types::GLint, width: types::GLsizei, height: types::GLsizei) -> () { mem::transmute::<_, extern "system" fn(types::GLint, types::GLint, types::GLsizei, types::GLsizei) -> ()>(storage::Viewport.f)(x, y, width, height) }
81#[inline] pub unsafe fn BindFramebuffer(target: types::GLenum, framebuffer: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLuint) -> ()>(storage::BindFramebuffer.f)(target, framebuffer) }
82#[inline] pub unsafe fn ClearDepthf(d: types::GLfloat) -> () { mem::transmute::<_, extern "system" fn(types::GLfloat) -> ()>(storage::ClearDepthf.f)(d) }
83#[inline] pub unsafe fn ClearColor(red: types::GLfloat, green: types::GLfloat, blue: types::GLfloat, alpha: types::GLfloat) -> () { mem::transmute::<_, extern "system" fn(types::GLfloat, types::GLfloat, types::GLfloat, types::GLfloat) -> ()>(storage::ClearColor.f)(red, green, blue, alpha) }
84#[inline] pub unsafe fn Clear(mask: types::GLbitfield) -> () { mem::transmute::<_, extern "system" fn(types::GLbitfield) -> ()>(storage::Clear.f)(mask) }
85#[inline] pub unsafe fn GenFramebuffers(n: types::GLsizei, framebuffers: *mut types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *mut types::GLuint) -> ()>(storage::GenFramebuffers.f)(n, framebuffers) }
86#[inline] pub unsafe fn GenRenderbuffers(n: types::GLsizei, renderbuffers: *mut types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *mut types::GLuint) -> ()>(storage::GenRenderbuffers.f)(n, renderbuffers) }
87#[inline] pub unsafe fn BindRenderbuffer(target: types::GLenum, renderbuffer: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLuint) -> ()>(storage::BindRenderbuffer.f)(target, renderbuffer) }
88#[inline] pub unsafe fn RenderbufferStorage(target: types::GLenum, internalformat: types::GLenum, width: types::GLsizei, height: types::GLsizei) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLenum, types::GLsizei, types::GLsizei) -> ()>(storage::RenderbufferStorage.f)(target, internalformat, width, height) }
89#[inline] pub unsafe fn Disable(cap: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum) -> ()>(storage::Disable.f)(cap) }
90#[inline] pub unsafe fn FramebufferRenderbuffer(target: types::GLenum, attachment: types::GLenum, renderbuffertarget: types::GLenum, renderbuffer: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLenum, types::GLenum, types::GLuint) -> ()>(storage::FramebufferRenderbuffer.f)(target, attachment, renderbuffertarget, renderbuffer) }
91#[inline] pub unsafe fn FramebufferTexture2D(target: types::GLenum, attachment: types::GLenum, textarget: types::GLenum, texture: types::GLuint, level: types::GLint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLenum, types::GLenum, types::GLuint, types::GLint) -> ()>(storage::FramebufferTexture2D.f)(target, attachment, textarget, texture, level) }
92#[inline] pub unsafe fn GetShaderiv(shader: types::GLuint, pname: types::GLenum, params: *mut types::GLint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLenum, *mut types::GLint) -> ()>(storage::GetShaderiv.f)(shader, pname, params) }
93#[inline] pub unsafe fn GetProgramiv(program: types::GLuint, pname: types::GLenum, params: *mut types::GLint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLenum, *mut types::GLint) -> ()>(storage::GetProgramiv.f)(program, pname, params) }
94#[inline] pub unsafe fn GetShaderInfoLog(shader: types::GLuint, bufSize: types::GLsizei, length: *mut types::GLsizei, infoLog: *mut types::GLchar) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLsizei, *mut types::GLsizei, *mut types::GLchar) -> ()>(storage::GetShaderInfoLog.f)(shader, bufSize, length, infoLog) }
95#[inline] pub unsafe fn GetProgramInfoLog(program: types::GLuint, bufSize: types::GLsizei, length: *mut types::GLsizei, infoLog: *mut types::GLchar) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLsizei, *mut types::GLsizei, *mut types::GLchar) -> ()>(storage::GetProgramInfoLog.f)(program, bufSize, length, infoLog) }
96#[inline] pub unsafe fn GetAttribLocation(program: types::GLuint, name: *const types::GLchar) -> types::GLint { mem::transmute::<_, extern "system" fn(types::GLuint, *const types::GLchar) -> types::GLint>(storage::GetAttribLocation.f)(program, name) }
97#[inline] pub unsafe fn GetUniformLocation(program: types::GLuint, name: *const types::GLchar) -> types::GLint { mem::transmute::<_, extern "system" fn(types::GLuint, *const types::GLchar) -> types::GLint>(storage::GetUniformLocation.f)(program, name) }
98#[inline] pub unsafe fn CreateShader(type_: types::GLenum) -> types::GLuint { mem::transmute::<_, extern "system" fn(types::GLenum) -> types::GLuint>(storage::CreateShader.f)(type_) }            
99#[inline] pub unsafe fn ShaderSource(shader: types::GLuint, count: types::GLsizei, string: *const *const types::GLchar, length: *const types::GLint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLsizei, *const *const types::GLchar, *const types::GLint) -> ()>(storage::ShaderSource.f)(shader, count, string, length) }
100#[inline] pub unsafe fn CompileShader(shader: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint) -> ()>(storage::CompileShader.f)(shader) }
101#[inline] pub unsafe fn CreateProgram() -> types::GLuint { mem::transmute::<_, extern "system" fn() -> types::GLuint>(storage::CreateProgram.f)() }
102#[inline] pub unsafe fn AttachShader(program: types::GLuint, shader: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLuint) -> ()>(storage::AttachShader.f)(program, shader) }
103#[inline] pub unsafe fn LinkProgram(program: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint) -> ()>(storage::LinkProgram.f)(program) }
104#[inline] pub unsafe fn DeleteShader(shader: types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLuint) -> ()>(storage::DeleteShader.f)(shader) }
105#[inline] pub unsafe fn Uniform1fv(location: types::GLint, count: types::GLsizei, value: *const types::GLfloat) -> () { mem::transmute::<_, extern "system" fn(types::GLint, types::GLsizei, *const types::GLfloat) -> ()>(storage::Uniform1fv.f)(location, count, value) }
106#[inline] pub unsafe fn GenTextures(n: types::GLsizei, textures: *mut types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *mut types::GLuint) -> ()>(storage::GenTextures.f)(n, textures) }
107#[inline] pub unsafe fn TexParameteri(target: types::GLenum, pname: types::GLenum, param: types::GLint) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLenum, types::GLint) -> ()>(storage::TexParameteri.f)(target, pname, param) }
108#[inline] pub unsafe fn TexImage2D(target: types::GLenum, level: types::GLint, internalformat: types::GLint, width: types::GLsizei, height: types::GLsizei, border: types::GLint, format: types::GLenum, type_: types::GLenum, pixels: *const raw::c_void) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLint, types::GLint, types::GLsizei, types::GLsizei, types::GLint, types::GLenum, types::GLenum, *const raw::c_void) -> ()>(storage::TexImage2D.f)(target, level, internalformat, width, height, border, format, type_, pixels) }
109#[inline] pub unsafe fn DeleteTextures(n: types::GLsizei, textures: *const types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *const types::GLuint) -> ()>(storage::DeleteTextures.f)(n, textures) }
110#[inline] pub unsafe fn GenBuffers(n: types::GLsizei, buffers: *mut types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *mut types::GLuint) -> ()>(storage::GenBuffers.f)(n, buffers) }
111#[inline] pub unsafe fn BufferData(target: types::GLenum, size: types::GLsizeiptr, data: *const raw::c_void, usage: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum, types::GLsizeiptr, *const raw::c_void, types::GLenum) -> ()>(storage::BufferData.f)(target, size, data, usage) }
112#[inline] pub unsafe fn Uniform1i(location: types::GLint, v0: types::GLint) -> () { mem::transmute::<_, extern "system" fn(types::GLint, types::GLint) -> ()>(storage::Uniform1i.f)(location, v0) }
113#[inline] pub unsafe fn GetError() -> types::GLenum { mem::transmute::<_, extern "system" fn() -> types::GLenum>(storage::GetError.f)() }
114#[inline] pub unsafe fn Finish() -> () { mem::transmute::<_, extern "system" fn() -> ()>(storage::Finish.f)() }
115#[inline] pub unsafe fn GetProgramBinary(program: types::GLuint, bufSize: types::GLsizei, length: *mut types::GLsizei, binaryFormat: *mut types::GLenum, binary: *mut raw::c_void) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLsizei, *mut types::GLsizei, *mut types::GLenum, *mut raw::c_void) -> ()>(storage::GetProgramBinary.f)(program, bufSize, length, binaryFormat, binary) }
116#[inline] pub unsafe fn ProgramBinary(program: types::GLuint, binaryFormat: types::GLenum, binary: *const raw::c_void, length: types::GLsizei) -> () { mem::transmute::<_, extern "system" fn(types::GLuint, types::GLenum, *const raw::c_void, types::GLsizei) -> ()>(storage::ProgramBinary.f)(program, binaryFormat, binary, length) }            
117#[inline] pub unsafe fn DeleteRenderbuffers(n: types::GLsizei, renderbuffers: *const types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *const types::GLuint) -> ()>(storage::DeleteRenderbuffers.f)(n, renderbuffers) }
118#[inline] pub unsafe fn DeleteBuffers(n: types::GLsizei, buffers: *const types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *const types::GLuint) -> ()>(storage::DeleteBuffers.f)(n, buffers) }
119#[inline] pub unsafe fn DeleteFramebuffers(n: types::GLsizei, framebuffers: *const types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *const types::GLuint) -> ()>(storage::DeleteFramebuffers.f)(n, framebuffers) }
120#[inline] pub unsafe fn DeleteVertexArrays(n: types::GLsizei, arrays: *const types::GLuint) -> () { mem::transmute::<_, extern "system" fn(types::GLsizei, *const types::GLuint) -> ()>(storage::DeleteVertexArrays.f)(n, arrays) }
121#[inline] pub unsafe fn GenerateMipmap(target: types::GLenum) -> () { mem::transmute::<_, extern "system" fn(types::GLenum) -> ()>( storage::GenerateMipmap.f)(target)}
122
123mod storage {
124    use super::FnPtr;
125    pub static mut GenVertexArrays: FnPtr = FnPtr::default();
126    pub static mut BindVertexArray: FnPtr = FnPtr::default();
127    pub static mut BindBuffer: FnPtr = FnPtr::default();
128    pub static mut VertexAttribPointer: FnPtr = FnPtr::default();
129    pub static mut EnableVertexAttribArray: FnPtr = FnPtr::default();
130    pub static mut VertexAttribDivisor: FnPtr = FnPtr::default();
131    pub static mut UseProgram: FnPtr = FnPtr::default();
132    pub static mut ActiveTexture: FnPtr = FnPtr::default();
133    pub static mut BindTexture: FnPtr = FnPtr::default();
134    pub static mut DrawElementsInstanced: FnPtr = FnPtr::default();
135    pub static mut Enable: FnPtr = FnPtr::default();
136    pub static mut DepthFunc: FnPtr = FnPtr::default();
137    pub static mut BlendEquationSeparate: FnPtr = FnPtr::default();
138    pub static mut BlendFuncSeparate: FnPtr = FnPtr::default();
139    pub static mut Viewport: FnPtr = FnPtr::default();
140    pub static mut BindFramebuffer: FnPtr = FnPtr::default();
141    pub static mut ClearDepth: FnPtr = FnPtr::default();
142    pub static mut ClearDepthf: FnPtr = FnPtr::default();
143    pub static mut ClearColor: FnPtr = FnPtr::default();
144    pub static mut Clear: FnPtr = FnPtr::default();
145    pub static mut GenFramebuffers: FnPtr = FnPtr::default();
146    pub static mut GenRenderbuffers: FnPtr = FnPtr::default();
147    pub static mut BindRenderbuffer: FnPtr = FnPtr::default();
148    pub static mut RenderbufferStorage: FnPtr = FnPtr::default();
149    pub static mut Disable: FnPtr = FnPtr::default();
150    pub static mut FramebufferRenderbuffer: FnPtr = FnPtr::default();
151    pub static mut FramebufferTexture2D: FnPtr = FnPtr::default();
152    pub static mut GetShaderiv: FnPtr = FnPtr::default();
153    pub static mut GetProgramiv: FnPtr = FnPtr::default();
154    pub static mut GetShaderInfoLog: FnPtr = FnPtr::default();
155    pub static mut GetProgramInfoLog: FnPtr = FnPtr::default();
156    pub static mut GetAttribLocation: FnPtr = FnPtr::default();
157    pub static mut GetUniformLocation: FnPtr = FnPtr::default();
158    pub static mut CreateShader: FnPtr = FnPtr::default();
159    pub static mut ShaderSource: FnPtr = FnPtr::default();
160    pub static mut CompileShader: FnPtr = FnPtr::default();
161    pub static mut CreateProgram: FnPtr = FnPtr::default();
162    pub static mut AttachShader: FnPtr = FnPtr::default();
163    pub static mut LinkProgram: FnPtr = FnPtr::default();
164    pub static mut DeleteShader: FnPtr = FnPtr::default();
165    pub static mut Uniform1fv: FnPtr = FnPtr::default();
166    pub static mut GenTextures: FnPtr = FnPtr::default();
167    pub static mut TexParameteri: FnPtr = FnPtr::default();
168    pub static mut TexImage2D: FnPtr = FnPtr::default();
169    pub static mut DeleteTextures: FnPtr = FnPtr::default();
170    pub static mut GenBuffers: FnPtr = FnPtr::default();
171    pub static mut BufferData: FnPtr = FnPtr::default();
172    pub static mut Uniform1i: FnPtr = FnPtr::default();
173    pub static mut GetError: FnPtr = FnPtr::default();
174    pub static mut Finish: FnPtr = FnPtr::default();
175    pub static mut GetProgramBinary: FnPtr = FnPtr::default();
176    pub static mut ProgramBinary: FnPtr = FnPtr::default();
177    pub static mut DeleteRenderbuffers: FnPtr = FnPtr::default();
178    pub static mut DeleteBuffers: FnPtr = FnPtr::default();
179    pub static mut DeleteFramebuffers: FnPtr = FnPtr::default();
180    pub static mut DeleteVertexArrays: FnPtr = FnPtr::default();
181    pub static mut GenerateMipmap: FnPtr = FnPtr::default();
182}
183
184pub unsafe fn load_with<F>(mut loadfn: F) where F: FnMut(&'static str) -> *const raw::c_void {
185    storage::GenVertexArrays = FnPtr::new(metaloadfn(&mut loadfn, "glGenVertexArrays", &["glGenVertexArraysAPPLE", "glGenVertexArraysOES"]));
186    storage::BindVertexArray = FnPtr::new(metaloadfn(&mut loadfn, "glBindVertexArray", &["glBindVertexArrayOES"]));
187    storage::BindBuffer = FnPtr::new(metaloadfn(&mut loadfn, "glBindBuffer", &["glBindBufferARB"]));
188    storage::VertexAttribPointer = FnPtr::new(metaloadfn(&mut loadfn, "glVertexAttribPointer", &["glVertexAttribPointerARB"]));
189    storage::EnableVertexAttribArray = FnPtr::new(metaloadfn(&mut loadfn, "glEnableVertexAttribArray", &["glEnableVertexAttribArrayARB"]));
190    storage::VertexAttribDivisor = FnPtr::new(metaloadfn(&mut loadfn, "glVertexAttribDivisor", &["glVertexAttribDivisorANGLE", "glVertexAttribDivisorARB", "glVertexAttribDivisorEXT", "glVertexAttribDivisorNV"]));
191    storage::UseProgram = FnPtr::new(metaloadfn(&mut loadfn, "glUseProgram", &["glUseProgramObjectARB"]));
192    storage::ActiveTexture = FnPtr::new(metaloadfn(&mut loadfn, "glActiveTexture", &["glActiveTextureARB"]));
193    storage::BindTexture = FnPtr::new(metaloadfn(&mut loadfn, "glBindTexture", &["glBindTextureEXT"]));
194    storage::DrawElementsInstanced = FnPtr::new(metaloadfn(&mut loadfn, "glDrawElementsInstanced", &["glDrawElementsInstancedANGLE", "glDrawElementsInstancedARB", "glDrawElementsInstancedEXT", "glDrawElementsInstancedNV"]));
195    storage::Enable = FnPtr::new(metaloadfn(&mut loadfn, "glEnable", &[]));
196    storage::DepthFunc = FnPtr::new(metaloadfn(&mut loadfn, "glDepthFunc", &[]));
197    storage::BlendEquationSeparate = FnPtr::new(metaloadfn(&mut loadfn, "glBlendEquationSeparate", &["glBlendEquationSeparateEXT"]));
198    storage::BlendFuncSeparate = FnPtr::new(metaloadfn(&mut loadfn, "glBlendFuncSeparate", &["glBlendFuncSeparateEXT", "glBlendFuncSeparateINGR"]));
199    storage::Viewport = FnPtr::new(metaloadfn(&mut loadfn, "glViewport", &[]));
200    storage::BindFramebuffer = FnPtr::new(metaloadfn(&mut loadfn, "glBindFramebuffer", &[]));
201    storage::ClearDepth = FnPtr::new(metaloadfn(&mut loadfn, "glClearDepth", &[]));
202    storage::ClearColor = FnPtr::new(metaloadfn(&mut loadfn, "glClearColor", &[]));
203    storage::Clear = FnPtr::new(metaloadfn(&mut loadfn, "glClear", &[]));
204    storage::GenFramebuffers = FnPtr::new(metaloadfn(&mut loadfn, "glGenFramebuffers", &["glGenFramebuffersEXT"]));
205    storage::GenRenderbuffers = FnPtr::new(metaloadfn(&mut loadfn, "glGenRenderbuffers", &["glGenRenderbuffersEXT"]));
206    storage::BindRenderbuffer = FnPtr::new(metaloadfn(&mut loadfn, "glBindRenderbuffer", &[]));
207    storage::RenderbufferStorage = FnPtr::new(metaloadfn(&mut loadfn, "glRenderbufferStorage", &["glRenderbufferStorageEXT"]));
208    storage::Disable = FnPtr::new(metaloadfn(&mut loadfn, "glDisable", &[]));
209    storage::FramebufferRenderbuffer = FnPtr::new(metaloadfn(&mut loadfn, "glFramebufferRenderbuffer", &["glFramebufferRenderbufferEXT"]));
210    storage::FramebufferTexture2D = FnPtr::new(metaloadfn(&mut loadfn, "glFramebufferTexture2D", &["glFramebufferTexture2DEXT"]));
211    storage::GetShaderiv = FnPtr::new(metaloadfn(&mut loadfn, "glGetShaderiv", &[]));
212    storage::GetProgramiv = FnPtr::new(metaloadfn(&mut loadfn, "glGetProgramiv", &[]));
213    storage::GetShaderInfoLog = FnPtr::new(metaloadfn(&mut loadfn, "glGetShaderInfoLog", &[]));
214    storage::GetProgramInfoLog = FnPtr::new(metaloadfn(&mut loadfn, "glGetProgramInfoLog", &[]));
215    storage::GetAttribLocation = FnPtr::new(metaloadfn(&mut loadfn, "glGetAttribLocation", &["glGetAttribLocationARB"]));
216    storage::GetUniformLocation = FnPtr::new(metaloadfn(&mut loadfn, "glGetUniformLocation", &["glGetUniformLocationARB"]));
217    storage::CreateShader = FnPtr::new(metaloadfn(&mut loadfn, "glCreateShader", &["glCreateShaderObjectARB"]));
218    storage::ShaderSource = FnPtr::new(metaloadfn(&mut loadfn, "glShaderSource", &["glShaderSourceARB"]));
219    storage::CompileShader = FnPtr::new(metaloadfn(&mut loadfn, "glCompileShader", &["glCompileShaderARB"]));
220    storage::CreateProgram = FnPtr::new(metaloadfn(&mut loadfn, "glCreateProgram", &["glCreateProgramObjectARB"]));
221    storage::AttachShader = FnPtr::new(metaloadfn(&mut loadfn, "glAttachShader", &["glAttachObjectARB"]));
222    storage::LinkProgram = FnPtr::new(metaloadfn(&mut loadfn, "glLinkProgram", &["glLinkProgramARB"]));
223    storage::DeleteShader = FnPtr::new(metaloadfn(&mut loadfn, "glDeleteShader", &[]));
224    storage::Uniform1fv = FnPtr::new(metaloadfn(&mut loadfn, "glUniform1fv", &["glUniform1fvARB"]));
225    storage::GenTextures = FnPtr::new(metaloadfn(&mut loadfn, "glGenTextures", &[]));
226    storage::TexParameteri = FnPtr::new(metaloadfn(&mut loadfn, "glTexParameteri", &[]));
227    storage::TexImage2D = FnPtr::new(metaloadfn(&mut loadfn, "glTexImage2D", &[]));
228    storage::DeleteTextures = FnPtr::new(metaloadfn(&mut loadfn, "glDeleteTextures", &[]));
229    storage::GenBuffers = FnPtr::new(metaloadfn(&mut loadfn, "glGenBuffers", &["glGenBuffersARB"]));
230    storage::BufferData = FnPtr::new(metaloadfn(&mut loadfn, "glBufferData", &["glBufferDataARB"]));
231    storage::Uniform1i = FnPtr::new(metaloadfn(&mut loadfn, "glUniform1i", &["glUniform1iARB"]));
232    storage::GetError = FnPtr::new(metaloadfn(&mut loadfn, "glGetError", &[]));
233    storage::Finish = FnPtr::new(metaloadfn(&mut loadfn, "glFinish", &[]));
234    storage::ClearDepthf = FnPtr::new(metaloadfn(&mut loadfn, "glClearDepthf", &["glClearDepthfOES"]));
235    storage::GetProgramBinary = FnPtr::new(metaloadfn(&mut loadfn, "glGetProgramBinary", &["glGetProgramBinaryOES"]));
236    storage::ProgramBinary = FnPtr::new(metaloadfn(&mut loadfn, "glProgramBinary", &["glProgramBinaryOES"]));
237    storage::DeleteRenderbuffers = FnPtr::new(metaloadfn(&mut loadfn, "glDeleteRenderbuffers", &["glDeleteRenderbuffersEXT"]));
238    storage::DeleteBuffers = FnPtr::new(metaloadfn(&mut loadfn, "glDeleteBuffers", &["glDeleteBuffersARB"]));
239    storage::DeleteFramebuffers = FnPtr::new(metaloadfn(&mut loadfn, "glDeleteFramebuffers", &["glDeleteFramebuffersEXT"]));
240    storage::DeleteVertexArrays = FnPtr::new(metaloadfn(&mut loadfn, "glDeleteVertexArrays", &["glDeleteVertexArraysAPPLE", "glDeleteVertexArraysOES"]));
241    storage::GenerateMipmap = FnPtr::new(metaloadfn(&mut loadfn, "glGenerateMipmap", &[]));
242}
243
244#[inline(never)]
245fn metaloadfn(loadfn: &mut dyn FnMut(&'static str) -> *const raw::c_void, symbol: &'static str, fallbacks: &[&'static str]) -> *const raw::c_void {
246    let mut ptr = loadfn(symbol);
247    if ptr.is_null() {
248        for &sym in fallbacks {
249            ptr = loadfn(sym);
250            if !ptr.is_null() {break;}
251        }
252    }
253    ptr
254}
255
256pub struct FnPtr {
257    f: *const raw::c_void,
258}
259
260impl FnPtr {
261    /// Creates a `FnPtr` from a load attempt.
262    pub fn new(ptr: *const raw::c_void) -> FnPtr {
263        if ptr.is_null() {
264            FnPtr {f: missing_fn_panic as *const raw::c_void}
265        } else {
266            FnPtr {f: ptr}
267        }
268    }
269}
270
271impl FnPtr{
272    const fn default()->Self{Self {f: missing_fn_panic as *const raw::c_void}}
273}
274
275fn missing_fn_panic() -> !{
276    panic!("gl function was not loaded")
277}
278