Skip to content

Commit a52b4f9

Browse files
committed
Flip cursor y coordinate.
1 parent 2c15149 commit a52b4f9

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

shaders/src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,22 @@ pub fn fs(constants: &ShaderConstants, mut frag_coord: Vec2) -> Vec4 {
6060
0.0,
6161
);
6262
let time = constants.time;
63-
let mouse = vec4(
63+
let mut mouse = vec4(
6464
constants.drag_end_x / COLS as f32,
6565
constants.drag_end_y / ROWS as f32,
66-
constants.drag_start_x / COLS as f32
67-
* if constants.mouse_left_pressed {
68-
1.0
69-
} else {
70-
-1.0
71-
},
72-
constants.drag_start_y / ROWS as f32
73-
* if constants.mouse_left_clicked {
74-
1.0
75-
} else {
76-
-1.0
77-
},
66+
constants.drag_start_x / COLS as f32,
67+
constants.drag_start_y / ROWS as f32,
7868
);
69+
if mouse != Vec4::zero() {
70+
mouse.y = resolution.y - mouse.y;
71+
mouse.w = resolution.y - mouse.w;
72+
}
73+
if !constants.mouse_left_pressed {
74+
mouse.z *= -1.0;
75+
}
76+
if !constants.mouse_left_clicked {
77+
mouse.w *= -1.0;
78+
}
7979

8080
let col = (frag_coord.x / resolution.x) as usize;
8181
let row = (frag_coord.y / resolution.y) as usize;

0 commit comments

Comments
 (0)