use std::{error::Error, fmt};
use crate::{gl, image_format::FormatNotSupportedError, memory_object::MemoryObjectCreationError};
pub enum ExternalTilingMode {
Optimal,
Linear
}
impl Into<crate::gl::types::GLenum> for ExternalTilingMode {
fn into(self) -> crate::gl::types::GLenum {
match self {
ExternalTilingMode::Optimal => gl::OPTIMAL_TILING_EXT,
ExternalTilingMode::Linear => gl::LINEAR_TILING_EXT,
}
}
}
pub struct ImportParameters {
pub dedicated_memory: bool,
pub size: u64,
pub offset: u64,
pub tiling: ExternalTilingMode,
}
#[derive(Debug, Clone, Copy)]
pub enum TextureImportError {
FormatNotPresent,
MemoryObjectCreation(MemoryObjectCreationError),
FormatNotSupported(FormatNotSupportedError),
}
impl fmt::Display for TextureImportError {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
use self::TextureImportError::*;
match *self {
FormatNotPresent => write!(fmt, "A specific format for the texture was not given."),
MemoryObjectCreation(e) => e.fmt(fmt),
FormatNotSupported(e) => e.fmt(fmt),
}
}
}
impl From<MemoryObjectCreationError> for TextureImportError {
fn from(e: MemoryObjectCreationError) -> Self {
Self::MemoryObjectCreation(e)
}
}
impl Error for TextureImportError {}