diff --git a/Makefile b/Makefile index a3a3caa..e6a4f42 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,9 @@ EXAMPLE=fragment-shader # default: wasm-build # default: profile-startup # default: bitmob -# default: example -default: wasm-egui-scaling +default: example +# default: example-wasm +# default: wasm-egui-scaling # default: egui-demo # default: lint # default: test @@ -53,6 +54,9 @@ bitmob: example: $(ENV_VARS) cargo run --example $(EXAMPLE) $(FLAGS) +example-wasm: + $(ENV_VARS) cargo run --example $(EXAMPLE) $(FLAGS) --target wasm32-unknown-unknown + egui-demo: $(ENV_VARS) cargo run --bin egui-scaling diff --git a/comfy-wgpu/src/hot_reload.rs b/comfy-wgpu/src/hot_reload.rs index 2a85e0f..fe884f5 100644 --- a/comfy-wgpu/src/hot_reload.rs +++ b/comfy-wgpu/src/hot_reload.rs @@ -20,34 +20,6 @@ macro_rules! reloadable_shader_source { }; } -/// Similar to `create_shader` but automatically hot reloads the shader on change. -/// Note that `create_reloadable_sprite_shader` will automatically call -/// `sprite_shader_from_fragment`, meaning your source should only contain the fragment part. -/// -/// The user needs to provide a `ReloadableShaderSource` which contains the static source to be -/// embedded in the binary, as well as the path to the shader file path for hot reloading. -/// -/// The [fragment_shader -/// example](https://github.com/darthdeus/comfy/blob/master/comfy/examples/fragment-shader.rs#L24-L57) -/// contains a full working example of how works. -pub fn create_reloadable_sprite_shader( - shaders: &mut ShaderMap, - name: &str, - reloadable_source: ReloadableShaderSource, - uniform_defs: UniformDefs, -) -> Result { - let id = create_shader( - shaders, - name, - &sprite_shader_from_fragment(&reloadable_source.static_source), - uniform_defs, - )?; - - watch_shader_path(&reloadable_source.path, id)?; - - Ok(id) -} - pub fn watch_shader_path( path: &str, shader_id: ShaderId, diff --git a/comfy/src/lib.rs b/comfy/src/lib.rs index 59ece83..9d6b062 100644 --- a/comfy/src/lib.rs +++ b/comfy/src/lib.rs @@ -38,7 +38,7 @@ pub use crate::game_loop::*; // pub use crate::macros::*; pub use crate::particles::*; pub use crate::render::*; -// pub use crate::shaders::*; +pub use crate::shaders::*; pub use crate::timer::*; pub use crate::trail::*; pub use crate::update_stages::*; diff --git a/comfy/src/shaders.rs b/comfy/src/shaders.rs index c6e140b..749dc1b 100644 --- a/comfy/src/shaders.rs +++ b/comfy/src/shaders.rs @@ -1,4 +1,34 @@ // use miniquad::{BlendFactor, BlendState, BlendValue, Equation}; +use crate::*; + +/// Similar to `create_shader` but automatically hot reloads the shader on change. +/// Note that `create_reloadable_sprite_shader` will automatically call +/// `sprite_shader_from_fragment`, meaning your source should only contain the fragment part. +/// +/// The user needs to provide a `ReloadableShaderSource` which contains the static source to be +/// embedded in the binary, as well as the path to the shader file path for hot reloading. +/// +/// The [fragment_shader +/// example](https://github.com/darthdeus/comfy/blob/master/comfy/examples/fragment-shader.rs#L24-L57) +/// contains a full working example of how works. +pub fn create_reloadable_sprite_shader( + shaders: &mut ShaderMap, + name: &str, + reloadable_source: ReloadableShaderSource, + uniform_defs: UniformDefs, +) -> Result { + let id = create_shader( + shaders, + name, + &sprite_shader_from_fragment(&reloadable_source.static_source), + uniform_defs, + )?; + + #[cfg(not(target_arch = "wasm32"))] + watch_shader_path(&reloadable_source.path, id)?; + + Ok(id) +} // use crate::*; // use notify::{event::AccessKind, Event, EventKind, RecursiveMode, Watcher};