Implement create_texture()
This commit is contained in:
parent
92e5ff1082
commit
f0ab184ea8
@ -94,10 +94,15 @@ impl Canvas {
|
|||||||
unimplemented!();
|
unimplemented!();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_texture(&mut self, _size: Size, _background: Option<Pixel>)
|
pub fn create_texture(&mut self, size: Size, background: Option<Pixel>)
|
||||||
-> Rc<RefCell<Texture>>
|
-> Result<TextureHandle, &'static str>
|
||||||
{
|
{
|
||||||
unimplemented!();
|
let buffer = vec!(background.unwrap_or_else(|| Pixel::from(Color::NONE));
|
||||||
|
(size.w * size.h).try_into().unwrap());
|
||||||
|
let texture = Texture::create(&self.renderer, &Vec::from(bytemuck::cast_slice(&buffer)),
|
||||||
|
size);
|
||||||
|
|
||||||
|
Ok(TextureHandle::from_texture(texture))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_texture_from_file(&mut self,
|
pub fn create_texture_from_file(&mut self,
|
||||||
|
|||||||
@ -17,6 +17,7 @@ pub struct Texture {
|
|||||||
|
|
||||||
impl Texture {
|
impl Texture {
|
||||||
|
|
||||||
|
//TODO: take buffer's ownership
|
||||||
pub fn create(renderer: &WgpuRenderer,
|
pub fn create(renderer: &WgpuRenderer,
|
||||||
buffer: &[u8],
|
buffer: &[u8],
|
||||||
size: Size)
|
size: Size)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user