Skip to content

Commit

Permalink
Fix two warnings
Browse files Browse the repository at this point in the history
One about read's result not being used,
second one about an unused doc comment.
This commit does a breaking API change.
  • Loading branch information
est31 committed Apr 15, 2019
1 parent 91563ec commit bc9d0cf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,19 +517,17 @@ impl Context {
/// let pixels: Vec<Vec<(u8, u8, u8, u8)>> = display.read_front_buffer();
/// # }
/// ```
pub fn read_front_buffer<T>(&self) -> T
pub fn read_front_buffer<T>(&self) -> Result<T, ops::ReadError>
where T: texture::Texture2dDataSink<(u8, u8, u8, u8)>
{
let mut ctxt = self.make_current();
let dimensions = self.get_framebuffer_dimensions();
let rect = ::Rect { left: 0, bottom: 0, width: dimensions.0, height: dimensions.1 };

// FIXME: See https://github.com/glium/glium/pull/1682#issuecomment-375596152
// Leave it unchecked for now, it will generate warning as a reminder it needs fixing.
let mut data = Vec::with_capacity(0);
ops::read(&mut ctxt, ops::Source::DefaultFramebuffer(gl::FRONT_LEFT), &rect,
&mut data, false);
T::from_raw(Cow::Owned(data), dimensions.0, dimensions.1)
&mut data, false)?;
Ok(T::from_raw(Cow::Owned(data), dimensions.0, dimensions.1))
}

/// Execute an arbitrary closure with the OpenGL context active. Useful if another
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ pub use program::ProgramCreationError::{CompilationError, LinkingError, ShaderTy
pub use sync::{LinearSyncFence, SyncFence};
pub use texture::Texture2d;
pub use version::{Api, Version, get_supported_glsl_version};
pub use ops::ReadError;

use std::rc::Rc;
use std::thread;
Expand Down
4 changes: 2 additions & 2 deletions src/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ pub fn is_subroutine_supported<C: ?Sized>(ctxt: &C) -> bool where C: Capabilitie
ctxt.get_version() >= &Version(Api::Gl, 4, 0) || ctxt.get_extensions().gl_arb_shader_subroutine
}

/// Some shader compilers have race-condition issues, so we lock this mutex
/// in the GL thread every time we compile a shader or link a program.
// Some shader compilers have race-condition issues, so we lock this mutex
// in the GL thread every time we compile a shader or link a program.
// TODO: replace by a StaticMutex
lazy_static! {
static ref COMPILER_GLOBAL_LOCK: Mutex<()> = Mutex::new(());
Expand Down

0 comments on commit bc9d0cf

Please sign in to comment.