mirror of
https://github.com/italicsjenga/rust_minifb.git
synced 2024-12-23 11:21:30 +11:00
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:
parent
a2633f78ad
commit
5772cc5380
14
CHANGELOG.md
14
CHANGELOG.md
|
@ -2,6 +2,20 @@
|
|||
|
||||
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)
|
||||
|
||||
- [changed] unix: replaced scale functions with macro and added missing invocations (Thanks Johannes Stölp!)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "minifb"
|
||||
version = "0.13.0"
|
||||
version = "0.14.0"
|
||||
license = "MIT/Apache-2.0"
|
||||
authors = ["Daniel Collin <daniel@collin.com>"]
|
||||
description = "Cross-platform window setup with optional bitmap rendering"
|
||||
|
|
|
@ -13,7 +13,7 @@ Usage
|
|||
```toml
|
||||
# Cargo.toml
|
||||
[dependencies]
|
||||
minifb = "0.13"
|
||||
minifb = "0.14"
|
||||
```
|
||||
|
||||
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
|
||||
window.update_with_buffer(&buffer).unwrap();
|
||||
window.update_with_buffer_size(&buffer, WIDTH, HEIGHT).unwrap();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
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
|
||||
|
|
|
@ -58,7 +58,7 @@ fn main() {
|
|||
angle += 0.1;
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ fn main() {
|
|||
WIDTH,
|
||||
HEIGHT,
|
||||
WindowOptions {
|
||||
resize: true,
|
||||
scale: Scale::X2,
|
||||
..WindowOptions::default()
|
||||
},
|
||||
|
@ -113,6 +112,6 @@ fn main() {
|
|||
});
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,6 +65,6 @@ fn main() {
|
|||
});
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,8 @@ fn main() {
|
|||
&& !orig.is_key_down(Key::Escape)
|
||||
&& !double.is_key_down(Key::Escape)
|
||||
{
|
||||
orig.update_with_buffer(&buffer).unwrap();
|
||||
double.update_with_buffer(&buffer).unwrap();
|
||||
orig.update_with_buffer_size(&buffer, width, height).unwrap();
|
||||
double.update_with_buffer_size(&buffer, width, height).unwrap();
|
||||
pos += 7;
|
||||
pos *= 13;
|
||||
pos %= buffer.len();
|
||||
|
|
|
@ -32,12 +32,10 @@ fn main() {
|
|||
let mut size = (0, 0);
|
||||
|
||||
while window.is_open() && !window.is_key_down(Key::Escape) {
|
||||
{
|
||||
let new_size = window.get_size();
|
||||
if new_size != size {
|
||||
size = new_size;
|
||||
buffer.resize(size.0 * size.1 / 2 / 2, 0);
|
||||
}
|
||||
let new_size = window.get_size();
|
||||
if new_size != size {
|
||||
size = new_size;
|
||||
buffer.resize(size.0 * size.1 / 2 / 2, 0);
|
||||
}
|
||||
|
||||
for i in buffer.iter_mut() {
|
||||
|
@ -63,6 +61,6 @@ fn main() {
|
|||
});
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,6 +130,6 @@ fn main() {
|
|||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
40
src/lib.rs
40
src/lib.rs
|
@ -145,7 +145,7 @@ pub struct WindowOptions {
|
|||
pub title: bool,
|
||||
/// If it should be possible to resize the window (default: false)
|
||||
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,
|
||||
}
|
||||
|
||||
|
@ -243,10 +243,48 @@ impl Window {
|
|||
/// window.update_with_buffer(&buffer).unwrap();
|
||||
/// ```
|
||||
#[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<()> {
|
||||
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)
|
||||
///
|
||||
|
|
Loading…
Reference in a new issue