-
-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Camera and Shadertoy examples #25
Conversation
examples/camera.rs
Outdated
} | ||
} | ||
|
||
#[macroquad::main(window_conf)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, I really like how it looks! :)
Cargo.toml
Outdated
@@ -23,3 +23,6 @@ glam = {version = "0.8", features = ["scalar-math"] } | |||
image = { version = "0.22", default-features = false, features = ["png_codec", "tga"] } | |||
megaui = { version = "=0.2.11" } | |||
macroquad_macro = { version = "0.1", path = "macroquad_macro" } | |||
|
|||
[patch.crates-io] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably should not be a part of this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will remove that. Just trying to make cross-compile, checks work correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed
async fn main() { | ||
let ferris = load_texture("rust.png").await; | ||
let ferris = load_texture("examples/rust.png").await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC examples/rust.png will not work on wasm - there is no examples folder for textures
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case have to run executables from examples directory.
Otherwise just run cargo run --example shadertoy
works correctly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also there an issue of this problem #26
macroquad_macro/src/lib.rs
Outdated
@@ -34,12 +34,19 @@ pub fn main(attr: TokenStream, item: TokenStream) -> TokenStream { | |||
} | |||
modified.extend(source); | |||
|
|||
let (method, ident) = match attr.into_iter().next() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make separate PR with just macro changes?
It would be way easier to review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved macro changes to #28 PR
examples/camera.rs
Outdated
let mut offset = (0., 0.); | ||
|
||
'main: loop { | ||
for &key in get_down_keys(&mut down_keys).iter() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not quite sold on the idea of get_down_keys
As for me, this example would be a bit more readable with just a number of
if is_key_down(Key::Whatever) {
target.1 -= 0.1;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was just to write more compact code. Which is easy to add new cases. See diff: 1bd4e3e#diff-6a6a8253e0291eb499839f6f1f4c15c3L35
However, I removed it.
examples/camera.rs
Outdated
(_x, y) if y != 0.0 => { | ||
// Normalise mouse wheel values is browser (chromium: 53, firefox: 3) | ||
#[cfg(target_arch = "wasm32")] | ||
let y = if y < 0.0 {-1.0} else if y > 0.0 {1.0} else {0.0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like rustfmt
would not be happy with this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatted with rustfmt be5cc78#diff-6a6a8253e0291eb499839f6f1f4c15c3R53
examples/camera.rs
Outdated
KeyCode::Up => offset.1 += 0.1, | ||
KeyCode::Down => offset.1 -= 0.1, | ||
#[cfg(not(target_arch = "wasm32"))] | ||
KeyCode::Q | KeyCode::Escape => break 'main, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we will need some exit
mechanism in macroquad.
Until it's done - I would try to avoid 'main on loops to not confuse people too much :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Label removed
examples/camera.rs
Outdated
|
||
match mouse_wheel() { | ||
(_x, y) if y != 0.0 => { | ||
// Normalise mouse wheel values is browser (chromium: 53, firefox: 3) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe do normalization on macroquad side, not on the user code side?
Not necessarily as a part of this PR though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe move normalization into mouse_wheel function?
Hi! |
This pull request looks promising, what can i do to help? |
@not-fl3 I moved new code to |
get_down_keys
for efficent handle down keysUpdated
camera
example for visualize transitions: target/rotation/zoom/offset inCamera2D
Updated
shadertoy
example for autocompile shader once it editedMerge after Add Tab/Shift+Tab key handlers to editbox megaui#12 been merged