Skip to content

Commit

Permalink
Make Frame::get_mask easier to understand
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanzab committed Feb 24, 2015
1 parent bb652dd commit 6b4be74
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/render/target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,13 @@ impl<R: Resources> Frame<R> {
/// Return a mask of contained planes.
pub fn get_mask(&self) -> Mask {
use device::target as t;
let mut mask = [t::COLOR0, t::COLOR1, t::COLOR2, t::COLOR3]
.iter().zip(self.colors.iter())
.fold(Mask::empty(), |u, (&m, _)| (u | m));
let mut mask = match self.colors.len() {
0 => Mask::empty(),
1 => t::COLOR0,
2 => t::COLOR0 | t::COLOR1,
3 => t::COLOR0 | t::COLOR1 | t::COLOR2,
_ => t::COLOR0 | t::COLOR1 | t::COLOR2 | t::COLOR3,
};
if self.depth.is_some() {
mask.insert(t::DEPTH);
}
Expand All @@ -89,7 +93,7 @@ impl<R: Resources> Frame<R> {
if mask.is_empty() {
// hack: assuming the default FBO has all planes
t::COLOR | t::DEPTH | t::STENCIL
}else {
} else {
mask
}
}
Expand Down

0 comments on commit 6b4be74

Please sign in to comment.