Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Fixed a bug with the delta update. Before it would be updating the te…
Browse files Browse the repository at this point in the history
…xture from only the start of the insertion and not as a sub-rect of the texture.
  • Loading branch information
jacobsky committed May 26, 2022
1 parent adb694f commit 2d795eb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions godot_egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,18 @@ impl GodotEgui {
}
};
let pixels = if let Some(pos) = texture_pos {
let insertion_start = pos[0] as i32 * pos[1] as i32;
assert_eq!(delta.image.width() * delta.image.height() * 4, pixel_delta.len() as usize, "delta is not compatible with the pixels");
// let insertion_start = pos[0] * pos[1];
let image = texture.get_data().expect("this must exist");

let mut data = unsafe { image.assume_safe().get_data() };
for idx in 0 .. pixel_delta.len() {
data.set(insertion_start, pixel_delta.get(idx));
// width is multiplied by 4 as a magic number due as these are bytes.

for x in pos[0]..delta.image.width() * 4 {
for y in pos[1]..delta.image.height() {
let idx = x * y;
data.set(idx as i32, pixel_delta.get(idx as i32));
}
}
data
} else {
Expand Down

0 comments on commit 2d795eb

Please sign in to comment.