librashader/librashader-runtime-gl/src/texture.rs

34 lines
732 B
Rust
Raw Normal View History

2022-11-30 00:39:42 -05:00
use crate::framebuffer::GLImage;
2023-01-15 11:08:13 -05:00
2022-11-30 01:38:05 -05:00
use librashader_common::{FilterMode, WrapMode};
2022-11-27 02:10:11 -05:00
#[derive(Default, Debug, Copy, Clone)]
pub(crate) struct InputTexture {
2022-11-30 00:39:42 -05:00
pub image: GLImage,
2022-11-27 02:10:11 -05:00
pub filter: FilterMode,
pub mip_filter: FilterMode,
pub wrap_mode: WrapMode,
}
/// An OpenGL texture bound as a shader resource.
2023-01-15 03:01:23 -05:00
impl InputTexture {
pub fn is_bound(&self) -> bool {
2022-11-30 01:38:05 -05:00
self.image.handle != 0
}
2023-01-15 03:01:23 -05:00
/// Returns a reference to itself if the texture is bound.
pub fn bound(&self) -> Option<&Self> {
if self.is_bound() {
2023-01-15 11:08:13 -05:00
Some(self)
2023-01-15 03:01:23 -05:00
} else {
None
}
}
2022-11-30 01:38:05 -05:00
}
2023-01-15 03:01:23 -05:00
impl AsRef<InputTexture> for InputTexture {
fn as_ref(&self) -> &InputTexture {
self
}
2023-01-15 03:06:09 -05:00
}