diff options
Diffstat (limited to 'engine/src/renderer')
-rw-r--r-- | engine/src/renderer/opengl.rs | 42 |
1 files changed, 22 insertions, 20 deletions
diff --git a/engine/src/renderer/opengl.rs b/engine/src/renderer/opengl.rs index 292fd94..888f760 100644 --- a/engine/src/renderer/opengl.rs +++ b/engine/src/renderer/opengl.rs @@ -111,6 +111,7 @@ fn initialize(window: Single<Window>) enable(Capability::MultiSample); } +#[allow(clippy::too_many_arguments)] fn render( query: Query<RenderableEntity, Not<With<NoDraw>>>, point_light_query: Query<(PointLight,)>, @@ -166,21 +167,18 @@ fn render( let new_gl_objects; - let gl_objects = match gl_objects.as_deref() { - Some(gl_objects) => gl_objects, - None => { - // TODO: Account for when meshes are changed - let gl_objects = GlObjects::new(&*mesh); + let gl_objects = if let Some(gl_objects) = gl_objects.as_deref() { + gl_objects + } else { + // TODO: Account for when meshes are changed + let gl_objects = GlObjects::new(&mesh); - new_gl_objects = Some(gl_objects.clone()); + new_gl_objects = Some(gl_objects.clone()); - actions.add_components( - query.entity_uid(entity_index).unwrap(), - (gl_objects,), - ); + actions + .add_components(query.entity_uid(entity_index).unwrap(), (gl_objects,)); - &*new_gl_objects.unwrap() - } + &*new_gl_objects.unwrap() }; apply_transformation_matrices( @@ -229,10 +227,10 @@ fn render( crate::opengl::set_polygon_mode( draw_flags.polygon_mode_config.face, draw_flags.polygon_mode_config.mode, - ) + ); } - draw_mesh(&gl_objects); + draw_mesh(gl_objects); if draw_flags.is_some() { let default_polygon_mode_config = PolygonModeConfig::default(); @@ -240,7 +238,7 @@ fn render( crate::opengl::set_polygon_mode( default_polygon_mode_config.face, default_polygon_mode_config.mode, - ) + ); } } } @@ -332,7 +330,7 @@ fn create_gl_shader_program( struct GlObjects { /// Vertex and index buffer has to live as long as the vertex array - _vertex_buffer: Buffer<Vertex>, + vertex_buffer: Buffer<Vertex>, index_buffer: Option<Buffer<u32>>, index_cnt: u32, @@ -388,7 +386,7 @@ impl GlObjects vertex_arr.bind_element_buffer(&index_buffer); return Self { - _vertex_buffer: vertex_buffer, + vertex_buffer, index_buffer: Some(index_buffer), index_cnt: indices.len().try_into().unwrap(), vertex_arr, @@ -396,7 +394,7 @@ impl GlObjects } Self { - _vertex_buffer: vertex_buffer, + vertex_buffer, index_buffer: None, index_cnt: 0, vertex_arr, @@ -407,7 +405,7 @@ impl GlObjects { NeverDrop::new(Self { // SAFETY: The vertex buffer will never become dropped (NeverDrop ensures it) - _vertex_buffer: unsafe { self._vertex_buffer.clone_weak() }, + vertex_buffer: unsafe { self.vertex_buffer.clone_weak() }, index_buffer: self .index_buffer .as_ref() @@ -488,6 +486,8 @@ fn apply_light<PointLightHolder>( ); } + // There probably won't be more than 2147483648 directional lights + #[allow(clippy::cast_possible_wrap, clippy::cast_possible_truncation)] gl_shader_program.set_uniform_1i( cstr!("directional_light_cnt"), directional_lights.len() as i32, @@ -514,6 +514,8 @@ fn apply_light<PointLightHolder>( ); } + // There probably won't be more than 2147483648 point lights + #[allow(clippy::cast_possible_wrap, clippy::cast_possible_truncation)] gl_shader_program.set_uniform_1i(cstr!("point_light_cnt"), point_lights.len() as i32); gl_shader_program.set_uniform_vec_3fv( @@ -521,7 +523,7 @@ fn apply_light<PointLightHolder>( &if material_flags.use_ambient_color { material.ambient.clone() } else { - global_light.ambient.clone().into() + global_light.ambient.clone() } .into(), ); |