aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-06-16 10:15:31 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-06-16 10:44:44 +0200
commitf6c26ec593ba96d89cb3476c815d6f33a915bfdd (patch)
treecc204a0cdfed5c3431f1e26cc2da10048d8c3474 /src/lib.rs
parente48c853b9c7a617bf8ba5f31b5fb2088c90c0ee7 (diff)
downloadglutin-f6c26ec593ba96d89cb3476c815d6f33a915bfdd.tar.gz
glutin-f6c26ec593ba96d89cb3476c815d6f33a915bfdd.zip
Handle errors from MakeCurrent and SwapBuffers
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 784ea95..b567916 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -63,6 +63,8 @@ pub use window::{AvailableMonitorsIter, MonitorID, get_available_monitors, get_p
#[cfg(feature = "window")]
pub use native_monitor::NativeMonitorId;
+use std::io;
+
mod api;
mod platform;
mod events;
@@ -73,7 +75,7 @@ mod window;
/// Trait that describes objects that have access to an OpenGL context.
pub trait GlContext {
/// Sets the context as the current context.
- unsafe fn make_current(&self);
+ unsafe fn make_current(&self) -> Result<(), ContextError>;
/// Returns true if this context is the current one in this thread.
fn is_current(&self) -> bool;
@@ -84,12 +86,12 @@ pub trait GlContext {
/// Swaps the buffers in case of double or triple buffering.
///
/// You should call this function every time you have finished rendering, or the image
- /// may not be displayed on the screen.
+ /// may not be displayed on the screen.
///
/// **Warning**: if you enabled vsync, this function will block until the next time the screen
/// is refreshed. However drivers can choose to override your vsync settings, which means that
/// you can't know in advance whether `swap_buffers` will block or not.
- fn swap_buffers(&self);
+ fn swap_buffers(&self) -> Result<(), ContextError>;
/// Returns the OpenGL API being used.
fn get_api(&self) -> Api;
@@ -126,6 +128,13 @@ impl std::error::Error for CreationError {
}
}
+/// Error that can happen when manipulating an OpenGL context.
+#[derive(Debug)]
+pub enum ContextError {
+ IoError(io::Error),
+ ContextLost,
+}
+
/// All APIs related to OpenGL that you can possibly get while using glutin.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Api {