1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! Contains all possible errors that may occur during rendering, initialization of
//! renderer structures, or GAPI.
use std::ffi::NulError;
/// Set of possible renderer errors.
#[derive(Debug)]
pub enum FrameworkError {
/// Compilation of a shader has failed.
ShaderCompilationFailed {
/// Name of shader.
shader_name: String,
/// Compilation error message.
error_message: String,
},
/// Means that shader link stage failed, exact reason is inside `error_message`
ShaderLinkingFailed {
/// Name of shader.
shader_name: String,
/// Linking error message.
error_message: String,
},
/// Shader source contains invalid characters.
FaultyShaderSource,
/// There is no such shader uniform (could be optimized out).
UnableToFindShaderUniform(String),
/// Texture has invalid data - insufficient size.
InvalidTextureData {
/// Expected data size in bytes.
expected_data_size: usize,
/// Actual data size in bytes.
actual_data_size: usize,
},
/// None variant was passed as texture data, but engine does not support it.
EmptyTextureData,
/// Means that you tried to draw element range from GeometryBuffer that
/// does not have enough elements.
InvalidElementRange {
/// First index.
start: usize,
/// Last index.
end: usize,
/// Total amount of triangles.
total: usize,
},
/// Means that attribute descriptor tries to define an attribute that does
/// not exists in vertex, or it does not match size. For example you have vertex:
/// pos: float2,
/// normal: float3
/// But you described second attribute as Float4, then you'll get this error.
InvalidAttributeDescriptor,
/// Framebuffer is invalid.
InvalidFrameBuffer,
/// OpenGL failed to construct framebuffer.
FailedToConstructFBO,
/// Custom error. Usually used for internal errors.
Custom(String),
}
impl From<NulError> for FrameworkError {
fn from(_: NulError) -> Self {
Self::FaultyShaderSource
}
}
#[cfg(not(target_arch = "wasm32"))]
impl From<glutin::ContextError> for FrameworkError {
fn from(err: glutin::ContextError) -> Self {
Self::Custom(format!("{:?}", err))
}
}
impl From<String> for FrameworkError {
fn from(v: String) -> Self {
Self::Custom(v)
}
}