diff options
author | tomaka <pierre.krieger1708@gmail.com> | 2015-02-17 22:20:14 +0100 |
---|---|---|
committer | tomaka <pierre.krieger1708@gmail.com> | 2015-02-17 22:20:14 +0100 |
commit | eb330030de6d74c04b870f51351db0e67676f311 (patch) | |
tree | a37ce4e4cdf89a27f3688e367cf2f2dad4597586 /src/lib.rs | |
parent | 40591806dc7382ddb75d90f2289127f5f28f9825 (diff) | |
parent | 1a33c9ce9fa5f932d71e2eadf5b7f4ac29b187ee (diff) | |
download | glutin-eb330030de6d74c04b870f51351db0e67676f311.tar.gz glutin-eb330030de6d74c04b870f51351db0e67676f311.zip |
Merge pull request #279 from tomaka/win32-correct
Work on the win32 implementation
Diffstat (limited to 'src/lib.rs')
-rw-r--r-- | src/lib.rs | 53 |
1 files changed, 52 insertions, 1 deletions
@@ -170,6 +170,21 @@ pub enum MouseCursor { RowResize, } +/// Describes a possible format. Unused. +#[allow(missing_docs)] +pub struct PixelFormat { + pub red_bits: u8, + pub green_bits: u8, + pub blue_bits: u8, + pub alpha_bits: u8, + pub depth_bits: u8, + pub stencil_bits: u8, + pub stereoscopy: bool, + pub double_buffer: bool, + pub multisampling: Option<u16>, + pub srgb: bool, +} + /// Attributes struct BuilderAttribs<'a> { #[allow(dead_code)] @@ -239,5 +254,41 @@ impl<'a> BuilderAttribs<'a> { (new_attribs, sharing) } -} + fn choose_pixel_format<T, I>(&self, iter: I) -> (T, PixelFormat) + where I: Iterator<Item=(T, PixelFormat)>, T: Clone + { + let mut current_result = None; + + // TODO: do this more properly + for (id, format) in iter { + if format.red_bits + format.green_bits + format.blue_bits < self.color_bits.unwrap_or(0) { + continue; + } + + if format.alpha_bits < self.alpha_bits.unwrap_or(0) { + continue; + } + + if format.depth_bits < self.depth_bits.unwrap_or(0) { + continue; + } + + if format.stencil_bits < self.stencil_bits.unwrap_or(0) { + continue; + } + + if !format.stereoscopy && self.stereoscopy { + continue; + } + + if self.multisampling.is_some() && format.multisampling.is_none() { + continue; + } + + current_result = Some((id, format)); + } + + current_result.expect("Could not find compliant pixel format") + } +} |