-
-
Save emberian/e7535354210ef55f5185 to your computer and use it in GitHub Desktop.
This file contains 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
use std::os; | |
#[allow(unused_variables)] | |
fn main() { | |
let width = 2u8; | |
let height = 3u8; | |
let size = 4u8; | |
let pitch = width * size; | |
let (mut x_offset, mut y_offset) = (0u8, 0u8); | |
let chunk = match os::MemoryMap::new((width * height * size) as uint, &[ | |
os::MapOption::MapReadable, | |
os::MapOption::MapWritable | |
]) { | |
Ok(chunk) => chunk, | |
Err(msg) => panic!("{}", msg) | |
}; | |
let base = chunk.ptr as *mut u32; | |
for y in range(0u8, height) { | |
for x in range(0u8, width) { | |
let red: u8 = 0u8; | |
let green: u8 = y + y_offset; | |
let blue: u8 = x + x_offset; | |
*base.offset_mut(y * height + width) = (green << 8) | blue; | |
} | |
}; | |
} |
This file contains 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
internal void | |
RenderWeirdGradient(int BlueOffset, int GreenOffset) | |
{ | |
int Width = BitmapWidth; | |
int Height = BitmapHeight; | |
int Pitch = Width*BytesPerPixel; | |
uint8 *Row = (uint8 *)BitmapMemory; | |
for(int Y = 0; | |
Y < BitmapHeight; | |
++Y) | |
{ | |
uint32 *Pixel = (uint32 *)Row; | |
for(int X = 0; | |
X < BitmapWidth; | |
++X) | |
{ | |
uint8 Blue = (X + BlueOffset); | |
uint8 Green = (Y + GreenOffset); | |
*Pixel++ = ((Green << 8) | Blue); | |
} | |
Row += Pitch; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment