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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! # `gl_loader` : A simple OpenGL function pointer loader.
//! This (small) package aim to do *only one thing*: Provide a `get_proc_address` function to load OpenGL function pointer.
//! It will not provide any form of window or OpenGL context creation. You will have to handle them by yourself.
//! The code is simply a binding to the pointer loading part of the glad library: [glad](https://glad.dav1d.de/)
//!
//! ## Usage:
//! ```
//! extern crate gl;
//! extern crate gl_loader;
//!
//! // Load OpenGL library.
//! gl_loader::init_gl();
//! // Load all the OpenGL function pointer using the `gl` crate.
//! gl::load_with(|symbol| gl_loader::get_proc_address(symbol) as *const _);
//! // Unload the OpenGL library.
//! gl_loader::end_gl();
//! ```
extern crate libc;
use CString;
extern "C"
/// Load the OpenGL system library.
/// It is usually necesseray to be able to load function pointer.
///
/// ```
/// let ret = init_gl();
/// assert_ne!(ret, 0);
/// ```
/// Close the OpenGL library.
/// This function does nothing if `init_gl()` has not been called.
/// Safe wrapper around Glad's `get_proc` function.
/// This function take an OpenGL function name and output its function pointer.
///
/// ```
/// let glCreateShader = get_proc_address("glCreateShader");
/// assert_ne!(glCreateShader, 0);
/// ```