Merge dev -> master (#111)

* Deprecated update_with_buffer and added a temporary (update_with_buffer_size) for now. This will later be removed and the update_with_buffer is requiring the size to bu suplied

* Reparation for 0.14 release

* Missed one case
This commit is contained in:
Daniel Collin 2019-12-03 15:24:03 +01:00 committed by GitHub
parent a2633f78ad
commit 5772cc5380
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 68 additions and 19 deletions

View file

@ -2,6 +2,20 @@
This project follows semantic versioning. This project follows semantic versioning.
### v0.14 (2019-12-03)
- [changed] Deprecated update_with_buffer on favor of update_with_buffer_size. The idea is that a size in of the buffer will be more robust and allow for aspect scaling as well.
- [changed] Improved macOS resizing support.
- [changed] Better modifier handling on macOS.
- [changed] Moved CI over to Github Actions
- [changed] Formatted all code with rustfmt
- [changed] Documentation improvments (Thanks Gary Guo & Arif Roktim!)
- [fixed] 'attempt to subtract with overflow' bug (Thanks Venceslas!)
- [fixed] Window close handling & missing Alt keys for X11 (Thanks Gary Guo!)
- [added] Juila example added (Thanks mishazawa!)
- [added] Add support for raspberry pi (Thanks Florian Blasius!)
- [added] Added support for raw-window-handle trait
### v0.13 (2019-08-30) ### v0.13 (2019-08-30)
- [changed] unix: replaced scale functions with macro and added missing invocations (Thanks Johannes Stölp!) - [changed] unix: replaced scale functions with macro and added missing invocations (Thanks Johannes Stölp!)

View file

@ -1,6 +1,6 @@
[package] [package]
name = "minifb" name = "minifb"
version = "0.13.0" version = "0.14.0"
license = "MIT/Apache-2.0" license = "MIT/Apache-2.0"
authors = ["Daniel Collin <daniel@collin.com>"] authors = ["Daniel Collin <daniel@collin.com>"]
description = "Cross-platform window setup with optional bitmap rendering" description = "Cross-platform window setup with optional bitmap rendering"

View file

@ -13,7 +13,7 @@ Usage
```toml ```toml
# Cargo.toml # Cargo.toml
[dependencies] [dependencies]
minifb = "0.13" minifb = "0.14"
``` ```
Example Example
@ -43,14 +43,14 @@ fn main() {
} }
// We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way // We unwrap here as we want this code to exit if it fails. Real applications may want to handle this in a different way
window.update_with_buffer(&buffer).unwrap(); window.update_with_buffer_size(&buffer, WIDTH, HEIGHT).unwrap();
} }
} }
``` ```
Status Status
------ ------
Currently Mac, Redox, Linux and Windows (64-bit and 32-bit) are the current supported platforms. X11 (Linux/FreeBSD/etc) support has been tested on Ubuntu (x64). Bug report(s) for other OSes/CPUs are welcome! Currently macOS, Redox, Linux and Windows (64-bit and 32-bit) are the current supported platforms. X11 (Linux/FreeBSD/etc) support has been tested on Ubuntu (x64). Bug report(s) for other OSes/CPUs are welcome!
Build instructions Build instructions

View file

@ -58,7 +58,7 @@ fn main() {
angle += 0.1; angle += 0.1;
// We unwrap here as we want this code to exit if it fails // We unwrap here as we want this code to exit if it fails
window.update_with_buffer(&buffer).unwrap(); window.update_with_buffer_size(&buffer, WIDTH, HEIGHT).unwrap();
} }
} }

View file

@ -29,7 +29,6 @@ fn main() {
WIDTH, WIDTH,
HEIGHT, HEIGHT,
WindowOptions { WindowOptions {
resize: true,
scale: Scale::X2, scale: Scale::X2,
..WindowOptions::default() ..WindowOptions::default()
}, },
@ -113,6 +112,6 @@ fn main() {
}); });
// We unwrap here as we want this code to exit if it fails // We unwrap here as we want this code to exit if it fails
window.update_with_buffer(&buffer).unwrap(); window.update_with_buffer_size(&buffer, WIDTH, HEIGHT).unwrap();
} }
} }

View file

@ -65,6 +65,6 @@ fn main() {
}); });
// We unwrap here as we want this code to exit if it fails // We unwrap here as we want this code to exit if it fails
window.update_with_buffer(&buffer).unwrap(); window.update_with_buffer_size(&buffer, width, height).unwrap();
} }
} }

View file

@ -34,8 +34,8 @@ fn main() {
&& !orig.is_key_down(Key::Escape) && !orig.is_key_down(Key::Escape)
&& !double.is_key_down(Key::Escape) && !double.is_key_down(Key::Escape)
{ {
orig.update_with_buffer(&buffer).unwrap(); orig.update_with_buffer_size(&buffer, width, height).unwrap();
double.update_with_buffer(&buffer).unwrap(); double.update_with_buffer_size(&buffer, width, height).unwrap();
pos += 7; pos += 7;
pos *= 13; pos *= 13;
pos %= buffer.len(); pos %= buffer.len();

View file

@ -32,13 +32,11 @@ fn main() {
let mut size = (0, 0); let mut size = (0, 0);
while window.is_open() && !window.is_key_down(Key::Escape) { while window.is_open() && !window.is_key_down(Key::Escape) {
{
let new_size = window.get_size(); let new_size = window.get_size();
if new_size != size { if new_size != size {
size = new_size; size = new_size;
buffer.resize(size.0 * size.1 / 2 / 2, 0); buffer.resize(size.0 * size.1 / 2 / 2, 0);
} }
}
for i in buffer.iter_mut() { for i in buffer.iter_mut() {
noise = seed; noise = seed;
@ -63,6 +61,6 @@ fn main() {
}); });
// We unwrap here as we want this code to exit if it fails // We unwrap here as we want this code to exit if it fails
window.update_with_buffer(&buffer).unwrap(); window.update_with_buffer_size(&buffer, new_size.0, new_size.0).unwrap();
} }
} }

View file

@ -130,6 +130,6 @@ fn main() {
} }
// We unwrap here as we want this code to exit if it fails // We unwrap here as we want this code to exit if it fails
window.update_with_buffer(&buffer).unwrap(); window.update_with_buffer_size(&buffer, WIDTH, HEIGHT).unwrap();
} }
} }

View file

@ -145,7 +145,7 @@ pub struct WindowOptions {
pub title: bool, pub title: bool,
/// If it should be possible to resize the window (default: false) /// If it should be possible to resize the window (default: false)
pub resize: bool, pub resize: bool,
/// Scale of the window that used in conjunction with update_with_buffer (default: X1) /// Scale of the window that used in conjunction with update_with_buffer_size (default: X1)
pub scale: Scale, pub scale: Scale,
} }
@ -243,10 +243,48 @@ impl Window {
/// window.update_with_buffer(&buffer).unwrap(); /// window.update_with_buffer(&buffer).unwrap();
/// ``` /// ```
#[inline] #[inline]
#[deprecated(
since = "0.14.0",
note = "Please use the update_with_buffer_size instead. This function will be replaced with args given in update_with_buffer_size in the future."
)]
pub fn update_with_buffer(&mut self, buffer: &[u32]) -> Result<()> { pub fn update_with_buffer(&mut self, buffer: &[u32]) -> Result<()> {
self.0.update_with_buffer(buffer) self.0.update_with_buffer(buffer)
} }
///
/// Updates the window with a 32-bit pixel buffer. The encoding for each pixel is `0RGB`:
/// The upper 8-bits are ignored, the next 8-bits are for the red channel, the next 8-bits
/// afterwards for the green channel, and the lower 8-bits for the blue channel.
///
/// Notice that the buffer needs to be at least the size of the created window.
///
/// # Examples
///
/// ```no_run
/// # use minifb::*;
/// fn from_u8_rgb(r: u8, g: u8, b: u8) -> u32 {
/// let (r, g, b) = (r as u32, g as u32, b as u32);
/// (r << 16) | (g << 8) | b
/// }
/// let window_width = 600;
/// let window_height = 400;
/// let buffer_width = 600;
/// let buffer_height = 400;
///
/// let azure_blue = from_u8_rgb(0, 127, 255);
///
/// let mut buffer: Vec<u32> = vec![azure_blue; buffer_width * buffer_height];
///
/// let mut window = Window::new("Test", window_width, window_height, WindowOptions::default()).unwrap();
///
/// window.update_with_buffer_size(&buffer, buffer_width, buffer_height).unwrap();
/// ```
#[inline]
pub fn update_with_buffer_size(&mut self, buffer: &[u32], _width: usize, _height: usize) -> Result<()> {
// currently width / height isn't used but will be soon
self.0.update_with_buffer(buffer)
}
/// ///
/// Updates the window (this is required to call in order to get keyboard/mouse input, etc) /// Updates the window (this is required to call in order to get keyboard/mouse input, etc)
/// ///