Skip to content

Commit

Permalink
Improved smoothness of updating the window (#344)
Browse files Browse the repository at this point in the history
* Fix error in documentation

* Improved udpdate smoothness when target fps is set
  • Loading branch information
StefanoIncardone authored Jan 31, 2024
1 parent 61af248 commit ef07f55
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,11 @@ impl Window {
width: usize,
height: usize,
) -> Result<()> {
let update_result = self
.0
.update_with_buffer_stride(buffer, width, height, width);
self.0.update_rate();
self.0
.update_with_buffer_stride(buffer, width, height, width)
update_result
}

/// Updates the window (this is required to call in order to get keyboard/mouse input, etc)
Expand All @@ -404,8 +406,8 @@ impl Window {
/// ```
#[inline]
pub fn update(&mut self) {
self.0.update();
self.0.update_rate();
self.0.update()
}

/// Checks if the window is still open. A window can be closed by the user (by for example
Expand Down Expand Up @@ -545,7 +547,7 @@ impl Window {
/// Is that lots of CPU time will be spent calling system functions to check for new events in a tight loop making the CPU time go up.
/// Using `set_target_fps` minifb will check how many frames are left to reach the target FPS and if there are any it will sleep for that amount of frames.
/// This means that if more frames than the target happened (external code taking longer) minifb will not do any waiting at all so there is no loss in CPU performance with this feature.
/// By default it's set to 250 FPS. Setting this value to None and no waiting will be done
/// By default it's set to 250 FPS. Setting this value to 0 and no waiting will be done
///
/// # Examples
///
Expand Down

0 comments on commit ef07f55

Please sign in to comment.