Change memory layout of Image, so it's not drawn upside-down by SDL

This commit is contained in:
Matthew Gordon 2019-11-12 16:47:56 -05:00
parent 2ec0c133a8
commit 9d47821062
1 changed files with 1 additions and 1 deletions

View File

@ -24,7 +24,7 @@ impl OutputImage {
pub fn set_color(&mut self, row: u32, column: u32, red: u8, green: u8, blue: u8) {
assert!(row < self.height && column < self.width);
let index = ((row * self.width + column) * self.channels) as usize;
let index = (((self.height - (row + 1)) * self.width + column) * self.channels) as usize;
self.pixel_data[index] = red;
self.pixel_data[index + 1] = green;
self.pixel_data[index + 2] = blue;