diff --git a/src/lib.rs b/src/lib.rs index 16909fc..2dc6863 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -20,6 +20,7 @@ pub struct CompiledShaders { pub fragment: Vec, } +/// Loads and compiles the vertex and fragment GLSL shaders from files pub fn load(vertex: T, fragment: T) -> Result where T: AsRef, @@ -29,6 +30,7 @@ where Ok(CompiledShaders{ vertex, fragment }) } +/// Parses the shaders and gives an entry point pub fn parse(code: &CompiledShaders) -> Result { reflection::create_entry(code) } diff --git a/src/watch.rs b/src/watch.rs index 9d52c0d..ef92ebf 100644 --- a/src/watch.rs +++ b/src/watch.rs @@ -25,13 +25,16 @@ pub struct Message { } impl Watch { - pub fn create(vertex: T, fragment: T) -> Result + /// Paths to the vertex and fragment shaders. + /// Frequency is how often the watcher will check the directory. + pub fn create(vertex: T, fragment: T, frequency: Duration) -> Result where T: AsRef, { let (handler, rx) = create_watch( vertex.as_ref().to_path_buf(), fragment.as_ref().to_path_buf(), + frequency, )?; Ok(Watch { _handler: handler, @@ -82,11 +85,12 @@ impl Drop for Handler { fn create_watch( vert_path: PathBuf, frag_path: PathBuf, + frequency: Duration ) -> Result<(Handler, mpsc::Receiver>), Error> { let (notify_tx, notify_rx) = mpsc::channel(); let (thread_tx, thread_rx) = mpsc::channel(); 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 fp = frag_path.clone();