Created
July 20, 2018 22:49
-
-
Save whistlegraph/fa4e74d39e1b3588a02d4c0d0474b37c to your computer and use it in GitHub Desktop.
WASM Pixel Manipulation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static mut PIXELS: [u8; 128 * 128 * 4] = [0; 128 * 128 * 4]; | |
#[no_mangle] | |
pub fn update_pixels() { | |
// How to remove this unsafe block? | |
unsafe { | |
PIXELS[0] = 255; | |
PIXELS[1] = 255; | |
PIXELS[2] = 0; | |
PIXELS[3] = 255; | |
} | |
} | |
#[no_mangle] | |
pub fn get_pixels() -> &'static [u8; 128 * 128 * 4] { | |
unsafe { &PIXELS } | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment