fixes #14
This commit is contained in:
@@ -20,6 +20,7 @@ pub struct CompiledShaders {
|
|||||||
pub fragment: Vec<u32>,
|
pub fragment: Vec<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Loads and compiles the vertex and fragment GLSL shaders from files
|
||||||
pub fn load<T>(vertex: T, fragment: T) -> Result<CompiledShaders, Error>
|
pub fn load<T>(vertex: T, fragment: T) -> Result<CompiledShaders, Error>
|
||||||
where
|
where
|
||||||
T: AsRef<Path>,
|
T: AsRef<Path>,
|
||||||
@@ -29,6 +30,7 @@ where
|
|||||||
Ok(CompiledShaders{ vertex, fragment })
|
Ok(CompiledShaders{ vertex, fragment })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Parses the shaders and gives an entry point
|
||||||
pub fn parse(code: &CompiledShaders) -> Result<Entry, Error> {
|
pub fn parse(code: &CompiledShaders) -> Result<Entry, Error> {
|
||||||
reflection::create_entry(code)
|
reflection::create_entry(code)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,13 +25,16 @@ pub struct Message {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Watch {
|
impl Watch {
|
||||||
pub fn create<T>(vertex: T, fragment: T) -> Result<Self, Error>
|
/// Paths to the vertex and fragment shaders.
|
||||||
|
/// Frequency is how often the watcher will check the directory.
|
||||||
|
pub fn create<T>(vertex: T, fragment: T, frequency: Duration) -> Result<Self, Error>
|
||||||
where
|
where
|
||||||
T: AsRef<Path>,
|
T: AsRef<Path>,
|
||||||
{
|
{
|
||||||
let (handler, rx) = create_watch(
|
let (handler, rx) = create_watch(
|
||||||
vertex.as_ref().to_path_buf(),
|
vertex.as_ref().to_path_buf(),
|
||||||
fragment.as_ref().to_path_buf(),
|
fragment.as_ref().to_path_buf(),
|
||||||
|
frequency,
|
||||||
)?;
|
)?;
|
||||||
Ok(Watch {
|
Ok(Watch {
|
||||||
_handler: handler,
|
_handler: handler,
|
||||||
@@ -82,11 +85,12 @@ impl Drop for Handler {
|
|||||||
fn create_watch(
|
fn create_watch(
|
||||||
vert_path: PathBuf,
|
vert_path: PathBuf,
|
||||||
frag_path: PathBuf,
|
frag_path: PathBuf,
|
||||||
|
frequency: Duration
|
||||||
) -> Result<(Handler, mpsc::Receiver<Result<Message, Error>>), Error> {
|
) -> Result<(Handler, mpsc::Receiver<Result<Message, Error>>), Error> {
|
||||||
let (notify_tx, notify_rx) = mpsc::channel();
|
let (notify_tx, notify_rx) = mpsc::channel();
|
||||||
let (thread_tx, thread_rx) = mpsc::channel();
|
let (thread_tx, thread_rx) = mpsc::channel();
|
||||||
let mut watcher: RecommendedWatcher =
|
let mut watcher: RecommendedWatcher =
|
||||||
Watcher::new(notify_tx, Duration::from_millis(50)).map_err(Error::FileWatch)?;
|
Watcher::new(notify_tx, frequency).map_err(Error::FileWatch)?;
|
||||||
|
|
||||||
let mut vp = vert_path.clone();
|
let mut vp = vert_path.clone();
|
||||||
let mut fp = frag_path.clone();
|
let mut fp = frag_path.clone();
|
||||||
|
|||||||
Reference in New Issue
Block a user