Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suppress alignment padding from glReadPixels #58

Merged
merged 2 commits into from Nov 2, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Clean up read_pixels

  • Loading branch information
kmcallister committed Nov 2, 2013
commit 6a0ece9fb2970e9298fdf98de8c9b2909531d865
7 gl2.rs
@@ -928,16 +928,17 @@ pub fn read_pixels(x: GLint, y: GLint, width: GLsizei, height: GLsizei, format:
_ => fail!(~"unsupported pixel_type for read_pixels"),
};

let len = (width * height * colors * depth) as uint;
let mut pixels: ~[u8] = ~[];
pixels.reserve((width * height * colors * depth) as uint);
pixels.reserve(len);

do pixels.as_mut_buf |buf, _| {
unsafe {
glReadPixels(x, y, width, height, format, pixel_type, cast::transmute(buf));
glReadPixels(x, y, width, height, format, pixel_type, buf as *mut c_void);
}
}

unsafe { set_len(&mut pixels, (width * height * colors * depth) as uint); }
unsafe { set_len(&mut pixels, len); }

pixels
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.