Struct glium_graphics::GliumWindow
[−]
[src]
pub struct GliumWindow<W = GlutinWindow> { pub window: Rc<RefCell<W>>, pub context: Rc<Context>, pub events: Events, }
A window struct for glium.
Fields
window: Rc<RefCell<W>>
Window.
context: Rc<Context>
Glium context.
events: Events
Event loop state.
Methods
impl<W> GliumWindow<W> where
W: OpenGLWindow + 'static,
[src]
W: OpenGLWindow + 'static,
fn new(window: &Rc<RefCell<W>>) -> Result<Self, GliumCreationError<()>>
Creates new GliumWindow.
fn draw(&self) -> Frame
Returns new frame.
fn next(&mut self) -> Option<Input>
Returns next event.
Methods from Deref<Target = Context>
fn get_framebuffer_dimensions(&self) -> (u32, u32)
Calls get_framebuffer_dimensions
on the backend object stored by this context.
unsafe fn rebuild<B, E>(
&self,
new_backend: B
) -> Result<(), GliumCreationError<E>> where
B: Backend + 'static,
&self,
new_backend: B
) -> Result<(), GliumCreationError<E>> where
B: Backend + 'static,
Changes the OpenGL context associated with this context.
The new context must have lists shared with the old one.
fn swap_buffers(&self) -> Result<(), SwapBuffersError>
Swaps the buffers in the backend.
fn get_version(&self) -> &Version
DEPRECATED. Use get_opengl_version
instead.
fn get_opengl_version(&self) -> &Version
Returns the OpenGL version detected by this context.
fn get_supported_glsl_version(&self) -> Version
Returns the GLSL version guaranteed to be supported.
fn is_glsl_version_supported(&self, version: &Version) -> bool
Returns true if the given GLSL version is supported.
fn get_opengl_version_string(&self) -> &str
Returns a string containing this GL version or release number used by this context.
Vendor-specific information may follow the version number.
fn get_opengl_vendor_string(&self) -> &str
Returns a string containing the company responsible for this GL implementation.
fn get_opengl_renderer_string(&self) -> &str
Returns a string containing the name of the GL renderer used by this context.
This name is typically specific to a particular configuration of a hardware platform.
fn is_debug(&self) -> bool
Returns true if the context is in debug mode.
Debug mode may provide additional error and performance issue reporting functionality.
fn is_forward_compatible(&self) -> bool
Returns true if the context is in "forward-compatible" mode.
Forward-compatible mode means that no deprecated functionality will be supported.
fn get_opengl_profile(&self) -> Option<Profile>
Returns this context's OpenGL profile if available.
The context profile is available from OpenGL 3.2 onwards. Returns None
if not supported.
fn is_robust(&self) -> bool
Returns true if out-of-bound buffer access from the GPU side (inside a program) cannot result in a crash.
You should take extra care if is_robust
returns false.
fn is_context_loss_possible(&self) -> bool
Returns true if a context loss is possible.
fn is_context_lost(&self) -> bool
Returns true if the context has been lost and needs to be recreated.
Implementation
If it has been determined that the context has been lost before, then the function
immediatly returns true. Otherwise, calls glGetGraphicsResetStatus
. If this function
is not available, returns false.
fn get_release_behavior(&self) -> ReleaseBehavior
Returns the behavior when the current OpenGL context is changed.
The most common value is Flush
. In order to get None
you must explicitely request it
during creation.
fn get_max_anisotropy_support(&self) -> Option<u16>
Returns the maximum value that can be used for anisotropic filtering, or None
if the hardware doesn't support it.
fn get_max_viewport_dimensions(&self) -> (u32, u32)
Returns the maximum dimensions of the viewport.
Glium will panic if you request a larger viewport than this when drawing.
fn release_shader_compiler(&self)
Releases the shader compiler, indicating that no new programs will be created for a while.
This method is a no-op if it's not available in the implementation.
fn get_free_video_memory(&self) -> Option<usize>
Returns an estimate of the amount of video memory available in bytes.
Returns None
if no estimate is available.
fn read_front_buffer<T>(&self) -> T where
T: Texture2dDataSink<(u8, u8, u8, u8)>,
T: Texture2dDataSink<(u8, u8, u8, u8)>,
Reads the content of the front buffer.
You will only see the data that has finished being drawn.
This function can return any type that implements Texture2dDataSink<(u8, u8, u8, u8)>
.
Example
let pixels: Vec<Vec<(u8, u8, u8, u8)>> = display.read_front_buffer();
unsafe fn exec_in_context<'a, T, F>(&self, action: F) -> T where
F: FnOnce() -> T + 'a,
T: Send + 'static,
F: FnOnce() -> T + 'a,
T: Send + 'static,
Execute an arbitrary closure with the OpenGL context active. Useful if another component needs to directly manipulate OpenGL state.
If action
manipulates any OpenGL state, it must be restored before action
completes.
fn assert_no_error(&self, user_msg: Option<&str>)
Asserts that there are no OpenGL errors pending.
This function should be used in tests.
fn synchronize(&self)
DEPRECATED. Renamed finish
.
fn finish(&self)
Calls glFinish()
. This waits until all the previously issued commands have finished
being executed.
When you execute OpenGL functions, they are not executed immediately. Instead they are put in a queue. This function flushes this queue, then waits until all commands have finished being executed.
You normally don't need to call this function manually, except for debugging purposes.
fn flush(&self)
Calls glFlush()
. This starts executing the commands that you have issued if it is not
yet the case.
When you execute OpenGL functions, they are not executed immediately. Instead they are put in a queue. This function flushes this queue so that commands start being executed.
You normally don't need to call this function manually. Swapping buffers automatically flushes the queue. This function can be useful if you want to benchmark the time it takes from your OpenGL driver to process commands.
fn insert_debug_marker(&self, marker: &str) -> Result<(), ()>
Inserts a debugging string in the commands queue. If you use an OpenGL debugger, you will be able to see that string.
This is helpful to understand where you are when you have big applications.
Returns Err
if the backend doesn't support this functionnality. You can choose whether
to call .unwrap()
if you want to make sure that it works, or .ok()
if you don't care.
fn debug_insert_debug_marker(&self, marker: &str) -> Result<(), ()>
Same as insert_debug_marker
, except that if you don't compile with debug_assertions
it is a no-op and returns Ok
.
Trait Implementations
impl<W> Deref for GliumWindow<W>
[src]
type Target = Context
The resulting type after dereferencing
fn deref(&self) -> &Context
The method called to dereference a value
impl<W> Clone for GliumWindow<W>
[src]
fn clone(&self) -> GliumWindow<W>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<W> BuildFromWindowSettings for GliumWindow<W> where
W: 'static + Window + OpenGLWindow + BuildFromWindowSettings,
[src]
W: 'static + Window + OpenGLWindow + BuildFromWindowSettings,
fn build_from_window_settings(
settings: &WindowSettings
) -> Result<GliumWindow<W>, String>
settings: &WindowSettings
) -> Result<GliumWindow<W>, String>
Builds the window from a WindowSettings
object. Read more
impl<W> Facade for GliumWindow<W>
[src]
fn get_context(&self) -> &Rc<Context>
Returns an opaque type that contains the OpenGL state, extensions, version, etc.
impl<W> Window for GliumWindow<W> where
W: Window,
[src]
W: Window,
fn should_close(&self) -> bool
Returns true if the window should close.
fn set_should_close(&mut self, value: bool)
Tells the window to close or stay open.
fn size(&self) -> Size
Gets the size of the window.
fn draw_size(&self) -> Size
Gets the draw size of the window. Read more
fn swap_buffers(&mut self)
Swaps render buffers. Read more
fn poll_event(&mut self) -> Option<Input>
Polls an input event from the window. Read more
fn wait_event(&mut self) -> Input
Wait indefinitely for an input event to be available from the window.
fn wait_event_timeout(&mut self, duration: Duration) -> Option<Input>
Wait for an input event to be available from the window or for the specified timeout to be reached. Read more
impl<W> AdvancedWindow for GliumWindow<W> where
W: AdvancedWindow,
[src]
W: AdvancedWindow,
fn get_title(&self) -> String
Gets a copy of the title of the window.
fn set_title(&mut self, title: String)
Sets the title of the window.
fn get_exit_on_esc(&self) -> bool
Gets whether to exit when pressing esc. Read more
fn set_exit_on_esc(&mut self, value: bool)
Sets whether to exit when pressing esc. Read more
fn set_capture_cursor(&mut self, value: bool)
Sets whether to capture/grab the cursor. Read more
fn show(&mut self)
Shows the window. Read more
fn hide(&mut self)
Hides the window. Read more
fn get_position(&self) -> Option<Position>
Gets the position of window. Read more
fn set_position<P: Into<Position>>(&mut self, pos: P)
Sets the position of window. Read more
fn title(self, value: String) -> Self
Sets title on window. Read more
fn exit_on_esc(self, value: bool) -> Self
Sets whether to exit when pressing the Esc button. Read more
fn capture_cursor(self, value: bool) -> Self
Sets whether to capture/grab the cursor. Read more
fn position<P>(self, val: P) -> Self where
P: Into<Position>,
P: Into<Position>,
Sets the position of window. Read more
impl<W> EventLoop for GliumWindow<W>
[src]
fn get_event_settings(&self) -> EventSettings
Returns event loop settings.
fn set_event_settings(&mut self, settings: EventSettings)
Sets event loop settings.
fn set_ups(&mut self, frames: u64)
The number of updates per second Read more
fn ups(self, frames: u64) -> Self
The number of updates per second Read more
fn set_ups_reset(&mut self, frames: u64)
The number of delayed updates before skipping them to catch up. When set to 0
, it will always try to catch up. Read more
fn ups_reset(self, frames: u64) -> Self
The number of delayed updates before skipping them to catch up. When set to 0
, it will always try to catch up. Read more
fn set_max_fps(&mut self, frames: u64)
The maximum number of frames per second Read more
fn max_fps(self, frames: u64) -> Self
The maximum number of frames per second Read more
fn set_swap_buffers(&mut self, enable: bool)
Enable or disable automatic swapping of buffers.
fn swap_buffers(self, enable: bool) -> Self
Enable or disable automatic swapping of buffers.
fn set_bench_mode(&mut self, enable: bool)
Enable or disable benchmark mode. When enabled, it will render and update without sleep and ignore input. Used to test performance by playing through as fast as possible. Requires lazy
to be set to false
. Read more
fn bench_mode(self, enable: bool) -> Self
Enable or disable benchmark mode. When enabled, it will render and update without sleep and ignore input. Used to test performance by playing through as fast as possible. Requires lazy
to be set to false
. Read more
fn set_lazy(&mut self, enable: bool)
Enable or disable rendering only when receiving input. When enabled, update events are disabled. Idle events are emitted while receiving input. Read more
fn lazy(self, enable: bool) -> Self
Enable or disable rendering only when receiving input. When enabled, update events are disabled. Idle events are emitted while receiving input. Read more