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

Improved smoothness of updating the window #344

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading