diff options
author | pommicket <pommicket@gmail.com> | 2022-12-16 22:00:01 -0500 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2022-12-16 22:00:01 -0500 |
commit | 7c8aac1bfb839a1aa4076a71fbc1dd70dd487e35 (patch) | |
tree | 628e24a9161015a0199c8a56d531961dbb8dc174 /src | |
parent | bac9af4139315daae65323c9cd84a5c867844399 (diff) |
Code Quality™
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 8 | ||||
-rw-r--r-- | src/sdf.rs | 4 | ||||
-rw-r--r-- | src/win.rs | 4 |
3 files changed, 7 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs index d3700bb..a2b7e88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -75,11 +75,11 @@ impl View { } fn yaw_by(&mut self, yaw: f32) { - self.rotation = self.rotation * Rot3::from_euler_angles(0.0, yaw, 0.0); + self.rotation *= Rot3::from_euler_angles(0.0, yaw, 0.0); } fn pitch_by(&mut self, pitch: f32) { - self.rotation = self.rotation * Rot3::from_euler_angles(pitch, 0.0, 0.0); + self.rotation *= Rot3::from_euler_angles(pitch, 0.0, 0.0); } fn translation(&self) -> Mat4 { @@ -235,7 +235,7 @@ void main() { ); //println!("{fshader_source}"); - println!("scene: {}", scene.to_string()); + println!("scene: {}", scene.export_string()); window .link_program(program, @@ -273,7 +273,7 @@ fn gen_program(window: &mut win::Window, program: &mut win::Program) -> Result<( #[allow(dead_code)] // @TODO @TEMPORARY fn gen_program_from_string(window: &mut win::Window, program: &mut win::Program, s: &str) -> Result<(), String> { - let scene = sdf::Scene::from_string(s).ok_or_else(|| "bad scene string".to_string())?; + let scene = sdf::Scene::import_string(s).ok_or_else(|| "bad scene string".to_string())?; gen_program_from_scene(window, program, &scene) } @@ -539,7 +539,7 @@ pub struct Scene { } impl Scene { - pub fn to_string(&self) -> String { + pub fn export_string(&self) -> String { let mut data: Vec<u8> = vec![]; // write errors should never happen // that said, we don't want to panic if for whatever reason this fails. @@ -548,7 +548,7 @@ impl Scene { } /// returns None if `s` is not a valid SDF string - pub fn from_string(s: &str) -> Option<Self> { + pub fn import_string(s: &str) -> Option<Self> { let bytes = decode_hex(s)?; serde_cbor::from_reader(&bytes[..]).ok()? } @@ -404,9 +404,7 @@ impl Shader { unsafe fn new_with_id(id: GLuint, r#type: GLenum, source: &str) -> Result<Self, String> { if id == 0 { - return Err(format!("couldn't create shader (GL error {})", unsafe { - gl::GetError() - })); + return Err(format!("couldn't create shader (GL error {})", gl::GetError())); } { |