Implement create_texture()
This commit is contained in:
parent
92e5ff1082
commit
f0ab184ea8
@ -94,10 +94,15 @@ impl Canvas {
|
||||
unimplemented!();
|
||||
}
|
||||
|
||||
pub fn create_texture(&mut self, _size: Size, _background: Option<Pixel>)
|
||||
-> Rc<RefCell<Texture>>
|
||||
pub fn create_texture(&mut self, size: Size, background: Option<Pixel>)
|
||||
-> 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,
|
||||
|
||||
@ -17,6 +17,7 @@ pub struct Texture {
|
||||
|
||||
impl Texture {
|
||||
|
||||
//TODO: take buffer's ownership
|
||||
pub fn create(renderer: &WgpuRenderer,
|
||||
buffer: &[u8],
|
||||
size: Size)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user