librashader_runtime_gl/
framebuffer.rs

1use crate::texture::InputTexture;
2use librashader_common::{FilterMode, GetSize, Size, WrapMode};
3
4/// A handle to an OpenGL texture with format and size information.
5///
6/// Generally for use as shader resource inputs.
7#[derive(Default, Debug, Copy, Clone)]
8pub struct GLImage {
9    /// A GLuint to the texture.
10    pub handle: Option<glow::Texture>,
11    /// The format of the texture.
12    pub format: u32,
13    /// The size of the texture.
14    pub size: Size<u32>,
15}
16
17impl GLImage {
18    pub(crate) fn as_texture(&self, filter: FilterMode, wrap_mode: WrapMode) -> InputTexture {
19        InputTexture {
20            image: *self,
21            filter,
22            mip_filter: filter,
23            wrap_mode,
24        }
25    }
26}
27
28impl GetSize<u32> for GLImage {
29    type Error = std::convert::Infallible;
30
31    fn size(&self) -> Result<Size<u32>, Self::Error> {
32        Ok(self.size)
33    }
34}
35
36impl GetSize<u32> for &GLImage {
37    type Error = std::convert::Infallible;
38
39    fn size(&self) -> Result<Size<u32>, Self::Error> {
40        Ok(self.size)
41    }
42}