glium/texture/
texture_import.rs1use std::{error::Error, fmt};
2
3use crate::{gl, image_format::FormatNotSupportedError, memory_object::MemoryObjectCreationError};
4
5pub enum ExternalTilingMode {
7 Optimal,
9 Linear
11}
12
13impl Into<crate::gl::types::GLenum> for ExternalTilingMode {
14 fn into(self) -> crate::gl::types::GLenum {
15 match self {
16 ExternalTilingMode::Optimal => gl::OPTIMAL_TILING_EXT,
17 ExternalTilingMode::Linear => gl::LINEAR_TILING_EXT,
18 }
19 }
20}
21
22pub struct ImportParameters {
25 pub dedicated_memory: bool,
27 pub size: u64,
29 pub offset: u64,
31 pub tiling: ExternalTilingMode,
33}
34
35
36#[derive(Debug, Clone, Copy)]
38pub enum TextureImportError {
39 FormatNotPresent,
41 MemoryObjectCreation(MemoryObjectCreationError),
43 FormatNotSupported(FormatNotSupportedError),
45}
46
47impl fmt::Display for TextureImportError {
48 fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
49 use self::TextureImportError::*;
50 match *self {
51 FormatNotPresent => write!(fmt, "A specific format for the texture was not given."),
52 MemoryObjectCreation(e) => e.fmt(fmt),
53 FormatNotSupported(e) => e.fmt(fmt),
54 }
55 }
56}
57
58impl From<MemoryObjectCreationError> for TextureImportError {
59 fn from(e: MemoryObjectCreationError) -> Self {
60 Self::MemoryObjectCreation(e)
61 }
62}
63
64impl Error for TextureImportError {}