| Name | Date | Size | #Lines | LOC | ||
|---|---|---|---|---|---|---|
| .. | - | - | ||||
| examples/ | 04-Jul-2025 | - | 250 | 164 | ||
| out/ | 04-Jul-2025 | - | 21,339 | 18,144 | ||
| patches/ | 04-Jul-2025 | - | 208 | 207 | ||
| src/ | 04-Jul-2025 | - | 80 | 3 | ||
| .android-checksum.json | D | 04-Jul-2025 | 1.3 KiB | 1 | 1 | |
| .cargo-checksum.json | D | 04-Jul-2025 | 662 | 1 | 1 | |
| Android.bp | D | 04-Jul-2025 | 976 | 40 | 35 | |
| Cargo.lock | D | 04-Jul-2025 | 36 KiB | 793 | 707 | |
| Cargo.toml | D | 04-Jul-2025 | 1.1 KiB | 30 | 28 | |
| LICENSE | D | 04-Jul-2025 | 11.1 KiB | 201 | 169 | |
| METADATA | D | 04-Jul-2025 | 334 | 18 | 17 | |
| MODULE_LICENSE_APACHE2 | D | 04-Jul-2025 | 0 | |||
| README.md | D | 04-Jul-2025 | 2.1 KiB | 84 | 59 | |
| build.rs | D | 04-Jul-2025 | 1 KiB | 30 | 12 | |
| cargo_embargo.json | D | 04-Jul-2025 | 90 | 8 | 8 |
README.md
1# gl-rs 2 3[](https://crates.io/crates/gl) 4[](https://github.com/brendanzab/gl-rs/blob/master/LICENSE) 5[](https://crates.io/crates/gl) 6 7An OpenGL function pointer loader for the Rust Programming Language. 8 9```toml 10[dependencies] 11gl = "0.6.0" 12``` 13 14## Basic usage 15 16You can import the pointer style loader and type aliases like so: 17 18```rust 19extern crate gl; 20// include the OpenGL type aliases 21use gl::types::*; 22``` 23 24You must load the function pointers into their respective function pointers 25using the `load_with` function. You must supply a loader function from your 26context library, This is how it would look using [glfw-rs] 27(https://github.com/PistonDevelopers/glfw-rs): 28 29```rust 30// the supplied function must be of the type: 31// `&fn(symbol: &'static str) -> *const std::os::raw::c_void` 32// `window` is a glfw::Window 33gl::load_with(|s| window.get_proc_address(s) as *const _); 34 35// loading a specific function pointer 36gl::Viewport::load_with(|s| window.get_proc_address(s) as *const _); 37``` 38 39Calling a function that has not been loaded will result in a failure like: 40`panic!("gl::Viewport was not loaded")`, which avoids a segfault. This feature 41does not cause any run time overhead because the failing functions are 42assigned only when `load_with` is called. 43 44```rust 45// accessing an enum 46gl::RED_BITS; 47 48// calling a function 49gl::DrawArrays(gl::TRIANGLES, 0, 3); 50 51// functions that take pointers are unsafe 52unsafe { gl::ShaderSource(shader, 1, &c_str, std::ptr::null()) }; 53``` 54 55Each function pointer has an associated boolean value allowing you to 56check if a function has been loaded at run time. The function accesses a 57corresponding global boolean that is set when `load_with` is called, so there 58shouldn't be much overhead. 59 60```rust 61if gl::Viewport::is_loaded() { 62 // do something... 63} 64``` 65 66## Changelog 67 68### v0.6.0 69 70- Upgrade to `gl_generator` v0.5.0 71 72### v0.5.2 73 74- Update crate metadata 75 76### v0.5.1 77 78- Upgrade `khronos_api` to v1.0.0 79 80### v0.5.0 81 82- Use `glutin` for examples 83- Use `raw::c_void` for `GLvoid` 84