pub trait GlContext {
// Required methods
unsafe fn make_current(&self) -> Result<(), ContextError>;
fn is_current(&self) -> bool;
fn get_proc_address(&self, addr: &str) -> *const ();
fn swap_buffers(&self) -> Result<(), ContextError>;
fn get_api(&self) -> Api;
fn get_pixel_format(&self) -> PixelFormat;
fn resize(&self, width: u32, height: u32);
}
Expand description
A trait for types associated with a GL context.
Required Methods§
sourceunsafe fn make_current(&self) -> Result<(), ContextError>
unsafe fn make_current(&self) -> Result<(), ContextError>
Sets the context as the current context.
sourcefn is_current(&self) -> bool
fn is_current(&self) -> bool
Returns true if this context is the current one in this thread.
sourcefn get_proc_address(&self, addr: &str) -> *const ()
fn get_proc_address(&self, addr: &str) -> *const ()
Returns the address of an OpenGL function.
sourcefn swap_buffers(&self) -> Result<(), ContextError>
fn swap_buffers(&self) -> Result<(), ContextError>
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.
sourcefn get_pixel_format(&self) -> PixelFormat
fn get_pixel_format(&self) -> PixelFormat
Returns the pixel format of the main framebuffer of the context.
sourcefn resize(&self, width: u32, height: u32)
fn resize(&self, width: u32, height: u32)
Resize the GL context.
Some platforms (macos, wayland) require being manually updated when their window or surface is resized.
The easiest way of doing this is to call this method for each Resized
window event that
is received with the width and height given by the event.