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

Switch from accepting an &[u8] to exposing an &mut [u8] #19

Closed
parasyte opened this issue Oct 21, 2019 · 0 comments · Fixed by #22
Closed

Switch from accepting an &[u8] to exposing an &mut [u8] #19

parasyte opened this issue Oct 21, 2019 · 0 comments · Fixed by #22
Labels
enhancement New feature or request

Comments

@parasyte
Copy link
Owner

This is from a hint provided by Ralith:

you should arrange for your library to expose an &mut [u8] rather than taking a &[u8] as input; in the future this will allow you to save a copy

Two public API changes:

  • Pixels::render(&mut self, &[u8]) to Pixels::render(&mut self)
  • Add Pixels::get_frame(&mut self) -> &mut [u8]

Using the new API will look like this:

let mut pixels = Pixels::new(320, 240, surface_texture)?;

// ... in `EventsCleared` handler ...
invaders.update(&dt, &controls);
window.request_redraw();

// ... in `RedrawRequested` handler ...
invaders.draw(pixels.get_frame());
pixels.render();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant