autocommit 2022-01-29 00:49:52 CET
This commit is contained in:
parent
b11a36729c
commit
85b019101a
41 changed files with 1322 additions and 61 deletions
27
src/render/renderer/image.rs
Normal file
27
src/render/renderer/image.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
use crate::render::egl::image::EglImage;
|
||||
use crate::render::gl::texture::GlTexture;
|
||||
use crate::render::{RenderContext, Texture};
|
||||
use crate::RenderError;
|
||||
use std::rc::Rc;
|
||||
|
||||
pub struct Image {
|
||||
pub(super) ctx: Rc<RenderContext>,
|
||||
pub(super) gl: Rc<EglImage>,
|
||||
}
|
||||
|
||||
impl Image {
|
||||
pub fn width(&self) -> i32 {
|
||||
self.gl.width
|
||||
}
|
||||
|
||||
pub fn height(&self) -> i32 {
|
||||
self.gl.height
|
||||
}
|
||||
|
||||
pub fn to_texture(self: &Rc<Self>) -> Result<Rc<Texture>, RenderError> {
|
||||
Ok(Rc::new(Texture {
|
||||
ctx: self.ctx.clone(),
|
||||
gl: GlTexture::import_img(&self.ctx.ctx, &self.gl)?,
|
||||
}))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue