aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorPierre Krieger <pierre.krieger1708@gmail.com>2015-04-30 13:23:37 +0200
committerPierre Krieger <pierre.krieger1708@gmail.com>2015-04-30 16:57:07 +0200
commitaa58f4149a65783b07c0dc401b5854ed80c4915e (patch)
treedd5d06aa46a1e18f0b93c2960dacc2cea9c81982 /src/lib.rs
parenta08388bca1ca275fd1455ceae26ab06c02c81111 (diff)
downloadglutin-aa58f4149a65783b07c0dc401b5854ed80c4915e.tar.gz
glutin-aa58f4149a65783b07c0dc401b5854ed80c4915e.zip
Add a GlContext trait
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 50f998b..be66099 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -70,6 +70,34 @@ mod headless;
#[cfg(feature = "window")]
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);
+
+ /// Returns true if this context is the current one in this thread.
+ fn is_current(&self) -> bool;
+
+ /// Returns the address of an OpenGL function.
+ fn get_proc_address(&self, addr: &str) -> *const libc::c_void;
+
+ /// 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.
+ ///
+ /// **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);
+
+ /// Returns the OpenGL API being used.
+ fn get_api(&self) -> Api;
+
+ /// Returns the pixel format of the main framebuffer of the context.
+ fn get_pixel_format(&self) -> PixelFormat;
+}
+
/// Error that can happen while creating a window or a headless renderer.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum CreationError {