Handle errors from MakeCurrent and SwapBuffers
This commit is contained in:
parent
e48c853b9c
commit
f6c26ec593
20 changed files with 123 additions and 62 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#![cfg(any(target_os = "windows"))]
|
||||
|
||||
use BuilderAttribs;
|
||||
use ContextError;
|
||||
use CreationError;
|
||||
use GlContext;
|
||||
use GlRequest;
|
||||
|
|
@ -156,9 +157,12 @@ impl Context {
|
|||
}
|
||||
|
||||
impl GlContext for Context {
|
||||
unsafe fn make_current(&self) {
|
||||
// TODO: check return value
|
||||
gl::wgl::MakeCurrent(self.hdc as *const _, self.context.0 as *const _);
|
||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||
if gl::wgl::MakeCurrent(self.hdc as *const _, self.context.0 as *const _) != 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ContextError::IoError(io::Error::last_os_error()))
|
||||
}
|
||||
}
|
||||
|
||||
fn is_current(&self) -> bool {
|
||||
|
|
@ -176,9 +180,11 @@ impl GlContext for Context {
|
|||
}
|
||||
}
|
||||
|
||||
fn swap_buffers(&self) {
|
||||
unsafe {
|
||||
gdi32::SwapBuffers(self.hdc);
|
||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||
if unsafe { gdi32::SwapBuffers(self.hdc) } != 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(ContextError::IoError(io::Error::last_os_error()))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue