gl-capture 0.0.2

Capture screenshot in OpenGL
Documentation
  • Coverage
  • 7.14%
    2 out of 28 items documented0 out of 9 items with examples
  • Size
  • Source code size: 21.44 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 3.26 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 19s Average build duration of successful builds.
  • all releases: 19s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • vallentin/gl-capture
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vallentin

gl-capture

Latest Version Docs License

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);
}