Skip to content

Commit

Permalink
Fix reading from life_out output buffer instead of life_in. (#2198)
Browse files Browse the repository at this point in the history
Co-authored-by: lloyd <digitalsentinel@gmail.com>
  • Loading branch information
dsentinel and digitalsentinel authored May 3, 2023
1 parent 25b1d7d commit 7741e00
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions examples/src/bin/multi_window_game_of_life/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,21 +242,21 @@ mod compute_life_cs {
ivec2 left = pos + ivec2(-1, 0);
int alive_count = 0;
if (life_out[get_index(up_left)] == 1) { alive_count += 1; }
if (life_out[get_index(up)] == 1) { alive_count += 1; }
if (life_out[get_index(up_right)] == 1) { alive_count += 1; }
if (life_out[get_index(right)] == 1) { alive_count += 1; }
if (life_out[get_index(down_right)] == 1) { alive_count += 1; }
if (life_out[get_index(down)] == 1) { alive_count += 1; }
if (life_out[get_index(down_left)] == 1) { alive_count += 1; }
if (life_out[get_index(left)] == 1) { alive_count += 1; }
if (life_in[get_index(up_left)] == 1) { alive_count += 1; }
if (life_in[get_index(up)] == 1) { alive_count += 1; }
if (life_in[get_index(up_right)] == 1) { alive_count += 1; }
if (life_in[get_index(right)] == 1) { alive_count += 1; }
if (life_in[get_index(down_right)] == 1) { alive_count += 1; }
if (life_in[get_index(down)] == 1) { alive_count += 1; }
if (life_in[get_index(down_left)] == 1) { alive_count += 1; }
if (life_in[get_index(left)] == 1) { alive_count += 1; }
// Dead becomes alive.
if (life_out[index] == 0 && alive_count == 3) {
if (life_in[index] == 0 && alive_count == 3) {
life_out[index] = 1;
}
// Becomes dead.
else if (life_out[index] == 1 && alive_count < 2 || alive_count > 3) {
else if (life_in[index] == 1 && alive_count < 2 || alive_count > 3) {
life_out[index] = 0;
}
// Else do nothing.
Expand Down

0 comments on commit 7741e00

Please # to comment.