diff options
| author | HampusM <hampus@hampusmat.com> | 2026-08-28 15:48:16 +0200 |
|---|---|---|
| committer | HampusM <hampus@hampusmat.com> | 2026-08-28 15:48:16 +0200 |
| commit | cb467dc2a9a9c9ac438a68c3bd03ec201b6f75d6 (patch) | |
| tree | d2c59421baf26a7ae5a090456722bb60057c09da /opengl-bindings/src | |
| parent | 01ccfc06e3f6b7f9e7698837f313bf101a8902b7 (diff) | |
refactor(opengl-bindings): make texture::Builder create* fns take images as byte slices
Diffstat (limited to 'opengl-bindings/src')
| -rw-r--r-- | opengl-bindings/src/texture.rs | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/opengl-bindings/src/texture.rs b/opengl-bindings/src/texture.rs index b0b729f..6bb576f 100644 --- a/opengl-bindings/src/texture.rs +++ b/opengl-bindings/src/texture.rs @@ -28,15 +28,13 @@ impl Builder pub fn create_2d<'image>( &self, current_context: &MaybeCurrentContextWithFns, - image: Option<impl Into<Cow<'image, [u8]>>>, + image: Option<&[u8]>, pixel_data_format: PixelDataFormat, ) -> Result<Texture, Error> { - let image = image.map(Into::into); - if let Some(image) = &image { check_image_buffer_len_correct_for_size( - image.as_ref(), + image, [self.size.width, self.size.height, 1], pixel_data_format, )?; @@ -48,14 +46,14 @@ impl Builder texture.alloc_2d(current_context, self.mipmap_levels, pixel_data_format, size); - if let Some(image) = &image { + if let Some(image) = image { texture.sub_image_2d( current_context, 0, [0, 0], size, pixel_data_format, - image.as_ref(), + image, ); texture.generate_mipmap(current_context); @@ -65,18 +63,13 @@ impl Builder } #[must_use] - pub fn create_cube_map<'image, Image>( + pub fn create_cube_map<'image>( &self, current_context: &MaybeCurrentContextWithFns, - images: Option<[(CubeMapFace, Image); 6]>, + images: Option<[(CubeMapFace, &[u8]); 6]>, pixel_data_format: PixelDataFormat, ) -> Result<Texture, Error> - where - Image: Into<Cow<'image, [u8]>>, { - let images = - images.map(|images| images.map(|(face, image)| (face, image.into()))); - for (_, image) in images.iter().flatten() { check_image_buffer_len_correct_for_size( image.as_ref(), @@ -98,7 +91,7 @@ impl Builder [0, 0, *face as crate::sys::types::GLint], [size[0], size[1], 1], pixel_data_format, - image.as_ref(), + *image, ); } |
