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

32 lines
697 B
Rust
Raw Normal View History

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