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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
pub mod audio;
pub mod console;
pub mod io;
pub mod prelude;
pub mod time;
pub mod window;
pub mod collections;
pub mod decoders;
mod parsers;
mod slice;
mod mem;
pub mod gui;
mod iterators;
pub mod math;
pub mod ogl;
pub mod text_writer;
#[cfg(feature="net")]
pub mod net;
#[cfg(feature = "extras")]
pub mod extras;
use glow::Context;
use std::{cell::RefCell, ops::Deref, rc::Rc, sync::Arc};
pub type GlowGL = Arc<Box<Context>>;
pub struct FlufflState<T> {
inner: Rc<RefCell<T>>,
}
impl<T> Clone for FlufflState<T> {
fn clone(&self) -> Self {
Self {
inner: self.inner.clone(),
}
}
}
impl<T> FlufflState<T> {
pub fn new(state: T) -> Self {
Self {
inner: Rc::new(RefCell::new(state)),
}
}
}
impl<T> Deref for FlufflState<T> {
type Target = Rc<RefCell<T>>;
fn deref(&self) -> &Self::Target {
&self.inner
}
}
#[derive(Debug)]
pub enum FlufflError {
GenericError(String),
FromUtf8ParseError(String),
WindowInitError(String),
IOError(String),
}
impl From<std::io::Error> for FlufflError {
fn from(err: std::io::Error) -> Self {
FlufflError::IOError(err.to_string())
}
}
impl From<std::string::FromUtf8Error> for FlufflError {
fn from(err: std::string::FromUtf8Error) -> Self {
Self::FromUtf8ParseError(err.to_string())
}
}