diff options
author | 2022-11-03 04:35:16 +0100 | |
---|---|---|
committer | 2022-11-03 04:35:16 +0100 | |
commit | b95745340441835bd25b5cadc2342254631f8c05 (patch) | |
tree | 38f103e59a9decdc83ac5c7514fe89006bf0c7dd /glow | |
parent | 20a0577034b40a6bbabee9bbbfc085f3fd5016c0 (diff) | |
download | iced-b95745340441835bd25b5cadc2342254631f8c05.tar.gz iced-b95745340441835bd25b5cadc2342254631f8c05.tar.bz2 iced-b95745340441835bd25b5cadc2342254631f8c05.zip |
Run `cargo fmt`
Diffstat (limited to 'glow')
-rw-r--r-- | glow/src/backend.rs | 2 | ||||
-rw-r--r-- | glow/src/triangle/gradient.rs | 93 | ||||
-rw-r--r-- | glow/src/window/compositor.rs | 6 |
3 files changed, 54 insertions, 47 deletions
diff --git a/glow/src/backend.rs b/glow/src/backend.rs index 7333d513..21af2ecf 100644 --- a/glow/src/backend.rs +++ b/glow/src/backend.rs @@ -1,6 +1,6 @@ -use crate::{program, triangle}; use crate::quad; use crate::text; +use crate::{program, triangle}; use crate::{Settings, Transformation, Viewport}; use iced_graphics::backend; diff --git a/glow/src/triangle/gradient.rs b/glow/src/triangle/gradient.rs index 36e434e3..ad41dffd 100644 --- a/glow/src/triangle/gradient.rs +++ b/glow/src/triangle/gradient.rs @@ -57,52 +57,55 @@ impl Program { if &self.uniform_data.gradient != gradient { match gradient { - Gradient::Linear(linear) => { - unsafe { - gl.uniform_4_f32( - Some( - &self.uniform_data.uniform_locations.gradient_direction_location - ), - linear.start.x, - linear.start.y, - linear.end.x, - linear.end.y - ); - - gl.uniform_1_u32( - Some( - &self - .uniform_data - .uniform_locations - .color_stops_size_location, - ), - (linear.color_stops.len() * 2) as u32, - ); - - let mut stops = [0.0; 128]; - - for (index, stop) in linear.color_stops.iter().enumerate().take(16) { - stops[index*8] = stop.color.r; - stops[(index*8)+1] = stop.color.g; - stops[(index*8)+2] = stop.color.b; - stops[(index*8)+3] = stop.color.a; - stops[(index*8)+4] = stop.offset; - stops[(index*8)+5] = 0.; - stops[(index*8)+6] = 0.; - stops[(index*8)+7] = 0.; - } - - gl.uniform_4_f32_slice( - Some( - &self - .uniform_data - .uniform_locations - .color_stops_location, - ), - &stops, - ); + Gradient::Linear(linear) => unsafe { + gl.uniform_4_f32( + Some( + &self + .uniform_data + .uniform_locations + .gradient_direction_location, + ), + linear.start.x, + linear.start.y, + linear.end.x, + linear.end.y, + ); + + gl.uniform_1_u32( + Some( + &self + .uniform_data + .uniform_locations + .color_stops_size_location, + ), + (linear.color_stops.len() * 2) as u32, + ); + + let mut stops = [0.0; 128]; + + for (index, stop) in + linear.color_stops.iter().enumerate().take(16) + { + stops[index * 8] = stop.color.r; + stops[(index * 8) + 1] = stop.color.g; + stops[(index * 8) + 2] = stop.color.b; + stops[(index * 8) + 3] = stop.color.a; + stops[(index * 8) + 4] = stop.offset; + stops[(index * 8) + 5] = 0.; + stops[(index * 8) + 6] = 0.; + stops[(index * 8) + 7] = 0.; } - } + + gl.uniform_4_f32_slice( + Some( + &self + .uniform_data + .uniform_locations + .color_stops_location, + ), + &stops, + ); + }, } self.uniform_data.gradient = gradient.clone(); diff --git a/glow/src/window/compositor.rs b/glow/src/window/compositor.rs index 6459dbce..20756032 100644 --- a/glow/src/window/compositor.rs +++ b/glow/src/window/compositor.rs @@ -26,7 +26,11 @@ impl<Theme> iced_graphics::window::GLCompositor for Compositor<Theme> { log::info!("{:#?}", settings); let version = gl.version(); - log::info!("OpenGL version: {:?} (Embedded: {})", version, version.is_embedded); + log::info!( + "OpenGL version: {:?} (Embedded: {})", + version, + version.is_embedded + ); let renderer = gl.get_parameter_string(glow::RENDERER); log::info!("Renderer: {}", renderer); |