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,3 +1,4 @@
|
|||
use ContextError;
|
||||
use CreationError;
|
||||
use CreationError::OsError;
|
||||
use BuilderAttribs;
|
||||
|
|
@ -61,7 +62,7 @@ impl HeadlessContext {
|
|||
}
|
||||
|
||||
impl GlContext for HeadlessContext {
|
||||
unsafe fn make_current(&self) {
|
||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||
self.context.makeCurrentContext();
|
||||
|
||||
gl::GenFramebuffersEXT(1, &mut framebuffer);
|
||||
|
|
@ -78,6 +79,8 @@ impl GlContext for HeadlessContext {
|
|||
if status != gl::FRAMEBUFFER_COMPLETE_EXT {
|
||||
panic!("Error while creating the framebuffer");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_current(&self) -> bool {
|
||||
|
|
@ -96,7 +99,8 @@ impl GlContext for HeadlessContext {
|
|||
symbol as *const libc::c_void
|
||||
}
|
||||
|
||||
fn swap_buffers(&self) {
|
||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_api(&self) -> ::Api {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ use libc;
|
|||
|
||||
use Api;
|
||||
use BuilderAttribs;
|
||||
use ContextError;
|
||||
use GlContext;
|
||||
use GlProfile;
|
||||
use GlRequest;
|
||||
|
|
@ -760,9 +761,10 @@ impl Window {
|
|||
}
|
||||
|
||||
impl GlContext for Window {
|
||||
unsafe fn make_current(&self) {
|
||||
unsafe fn make_current(&self) -> Result<(), ContextError> {
|
||||
let _: () = msg_send![*self.context, update];
|
||||
self.context.makeCurrentContext();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn is_current(&self) -> bool {
|
||||
|
|
@ -789,8 +791,9 @@ impl GlContext for Window {
|
|||
symbol as *const _
|
||||
}
|
||||
|
||||
fn swap_buffers(&self) {
|
||||
fn swap_buffers(&self) -> Result<(), ContextError> {
|
||||
unsafe { self.context.flushBuffer(); }
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_api(&self) -> ::Api {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue