| Crates.io | gl-capture |
| lib.rs | gl-capture |
| version | 0.0.2 |
| created_at | 2023-05-24 21:44:40.492872+00 |
| updated_at | 2023-05-25 01:12:11.087369+00 |
| description | Capture screenshot in OpenGL |
| homepage | |
| repository | https://github.com/vallentin/gl-capture |
| max_upload_size | |
| id | 873778 |
| size | 21,945 |
Library for capturing screenshots in OpenGL.
See examples/basic.rs for a complete example.
let img = unsafe { gl_capture::capture() };
// img.size: (u32, u32)
// img.data: Vec<capture_gl::Rgb>
// Now use e.g. `png` or `image` crate to save the image data to a file
Alternatively, use capture_into() to reuse the same image data, instead
of reallocating on every call.
let mut img = gl_capture::RgbImageData::new(size);
unsafe {
gl_capture::capture_into(&mut img);
}
// img.size: (u32, u32)
// img.data: Vec<capture_gl::Rgb>
Also supports other formats, e.g. RgbaImageData, BgrImageData, BgraImageData.
When manually using gl::ReadPixels(), instead it is also possible to use
read_pixels() or read_pixels_ptr(), which performs some additional checks
and setup.
let format = gl_capture::CaptureFormat::Rgb;
let mut data = format.allocate_pixel_data(size);
unsafe {
gl_capture::read_pixels((0, 0), size, format, &mut data);
}