2022-11-30 16:39:42 +11:00
|
|
|
use crate::framebuffer::GLImage;
|
2023-01-16 03:08:13 +11:00
|
|
|
|
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-02-11 16:20:35 +11:00
|
|
|
pub(crate) 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,
|
|
|
|
}
|
2022-11-30 11:36:09 +11:00
|
|
|
|
2023-02-11 16:20:35 +11:00
|
|
|
/// An OpenGL texture bound as a shader resource.
|
2023-01-15 19:01:23 +11:00
|
|
|
impl InputTexture {
|
2022-11-30 11:36:09 +11:00
|
|
|
pub fn is_bound(&self) -> bool {
|
2022-11-30 17:38:05 +11:00
|
|
|
self.image.handle != 0
|
2022-11-30 11:36:09 +11:00
|
|
|
}
|
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() {
|
2023-01-16 03:08:13 +11:00
|
|
|
Some(self)
|
2023-01-15 19:01:23 +11:00
|
|
|
} 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
|
|
|
|
}
|
2023-01-15 19:06:09 +11:00
|
|
|
}
|