Skip to content

Commit

Permalink
feat: add lose_context() / restore_context()
Browse files Browse the repository at this point in the history
  • Loading branch information
fand authored and grovesNL committed Oct 10, 2023
1 parent 9257bab commit 937b9a8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/web_sys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,23 @@ impl Context {
})
.unwrap_or(false)
}

/// Simulate losing WebGL rendering context.
/// Only works when "WEBGL_lose_context" extension is available.
pub fn lose_context(&self) {
if let Some(ext) = &self.extensions.webgl_lose_context {
ext.lose_context()
}
}

/// Simulate restoring WebGL rendering context.
/// Only works when "WEBGL_lose_context" extension is available.
/// This will panic when the context is not lost.
pub fn restore_context(&self) {
if let Some(ext) = &self.extensions.webgl_lose_context {
ext.restore_context()
}
}
}

new_key_type! { pub struct WebShaderKey; }
Expand Down

0 comments on commit 937b9a8

Please sign in to comment.