You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Filling a subset of a texture is sometimes useful, and would basically require something like:
///
/// Fills a region of this texture with the given data and generate mip maps if specified at construction.
///
/// # Panic
/// Will panic if the length of the data does not correspond to the width, height and format specified at construction.
/// Will panic if the specified region is out of bounds.
/// It is therefore necessary to create a new texture if the texture size or format has changed.
///
pub fn fill_subset<T: TextureDataType>(&self, x: u32, y: u32, w: u32, h: u32, data: &[T]) {
check_data_length::<T>(w, h, 1, self.data_byte_size, data.len());
assert!(x+w < self.width && y+h < self.height);
self.bind();
let mut data = data.to_owned();
flip_y(&mut data, self.width as usize, self.height as usize);
unsafe {
self.context.tex_sub_image_2d(
crate::context::TEXTURE_2D,
0,
x as i32,
y as i32,
w as i32,
h as i32,
format_from_data_type::<T>(),
T::data_type(),
crate::context::PixelUnpackData::Slice(Some(to_byte_slice(&data))),
);
}
self.generate_mip_maps();
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Filling a subset of a texture is sometimes useful, and would basically require something like:
--- to be added to all the various Texture types.
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions