Struct nannou::window::Window [−][src]
pub struct Window { /* fields omitted */ }
An OpenGL window.
The Window
acts as a wrapper around the glium::Display
type, providing a more
nannou-friendly API.
Methods
impl Window
[src]
impl Window
pub fn set_title(&self, title: &str)
[src]
pub fn set_title(&self, title: &str)
Modifies the title of the window.
This is a no-op if the window has already been closed.
pub fn show(&self)
[src]
pub fn show(&self)
pub fn hide(&self)
[src]
pub fn hide(&self)
pub fn position(&self) -> (i32, i32)
[src]
pub fn position(&self) -> (i32, i32)
The position of the top-left hand corner of the window relative to the top-left hand corner of the desktop.
Note that the top-left hand corner of the desktop is not necessarily the same as the screen. If the user uses a desktop with multiple monitors, the top-left hand corner of the desktop is the top-left hand corner of the monitor at the top-left of the desktop.
The coordinates can be negative if the top-left hand corner of the window is outside of the visible screen region.
pub fn set_position(&self, x: i32, y: i32)
[src]
pub fn set_position(&self, x: i32, y: i32)
Modifies the position of the window.
See get_position
for more information about the returned coordinates.
pub fn inner_size_pixels(&self) -> (u32, u32)
[src]
pub fn inner_size_pixels(&self) -> (u32, u32)
The size in pixels of the client area of the window.
The client area is the content of the window, excluding the title bar and borders. These are the dimensions of the frame buffer, and the dimensions that you should use when you call glViewport.
pub fn inner_size_points(&self) -> (f32, f32)
[src]
pub fn inner_size_points(&self) -> (f32, f32)
The size in points of the client area of the window.
The client area is the content of the window, excluding the title bar and borders. To get
the dimensions of the frame buffer when calling glViewport
, multiply with hidpi factor.
This is the same as dividing the result of inner_size_pixels()
by hidpi_factor()
.
pub fn outer_size_pixels(&self) -> (u32, u32)
[src]
pub fn outer_size_pixels(&self) -> (u32, u32)
The size of the window in pixels.
These dimensions include title bar and borders. If you don't want these, you should use
inner_size_pixels
instead.
pub fn outer_size_points(&self) -> (f32, f32)
[src]
pub fn outer_size_points(&self) -> (f32, f32)
The size of the window in points.
These dimensions include title bar and borders. If you don't want these, you should use
inner_size_points
instead.
This is the same as dividing the result of outer_size_pixels()
by hidpi_factor()
.
pub fn set_inner_size_pixels(&self, width: u32, height: u32)
[src]
pub fn set_inner_size_pixels(&self, width: u32, height: u32)
Modifies the inner size of the window.
See the inner_size
methods for more informations about the values.
pub fn set_inner_size_points(&self, width: f32, height: f32)
[src]
pub fn set_inner_size_points(&self, width: f32, height: f32)
Modifies the inner size of the window using point values.
Internally, the given width and height are multiplied by the hidpi_factor
to get the
values in pixels before calling set_inner_size_pixels
internally.
pub fn set_cursor(&self, cursor: MouseCursor)
[src]
pub fn set_cursor(&self, cursor: MouseCursor)
pub fn hidpi_factor(&self) -> f32
[src]
pub fn hidpi_factor(&self) -> f32
The ratio between the backing framebuffer resolution and the window size in screen pixels.
This is typically 1.0
for a normal display, 2.0
for a retina display and higher on more
modern displays.
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()>
[src]
pub fn set_cursor_position(&self, x: i32, y: i32) -> Result<(), ()>
Changes the position of the cursor in window coordinates.
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String>
[src]
pub fn set_cursor_state(&self, state: CursorState) -> Result<(), String>
pub fn set_maximized(&self, maximized: bool)
[src]
pub fn set_maximized(&self, maximized: bool)
Sets the window to maximized or back.
pub fn set_fullscreen(&self, monitor: Option<MonitorId>)
[src]
pub fn set_fullscreen(&self, monitor: Option<MonitorId>)
Sets how winit handles the cursor.
See the documentation of CursorState
for details.
Platform-specific
Has no effect on Android.
pub fn current_monitor(&self) -> MonitorId
[src]
pub fn current_monitor(&self) -> MonitorId
The current monitor that the window is on or the primary monitor if nothing matches.
pub fn id(&self) -> Id
[src]
pub fn id(&self) -> Id
A unique identifier associated with this window.
pub fn is_current(&self) -> bool
[src]
pub fn is_current(&self) -> bool
True if this context is the current one in this thread.
pub fn proc_address(&self, addr: &str) -> *const ()
[src]
pub fn proc_address(&self, addr: &str) -> *const ()
The address of an OpenGL function.
pub fn opengl_api(&self) -> Api
[src]
pub fn opengl_api(&self) -> Api
The OpenGL API being used.
pub fn pixel_format(&self) -> PixelFormat
[src]
pub fn pixel_format(&self) -> PixelFormat
The pixel format of the main framebuffer of the context.
pub fn rebuild(
&self,
window: WindowBuilder,
context: ContextBuilder,
app: &App
) -> Result<(), DisplayCreationError>
[src]
pub fn rebuild(
&self,
window: WindowBuilder,
context: ContextBuilder,
app: &App
) -> Result<(), DisplayCreationError>
Rebuilds the inner Display
's GlWindow
with the given window and context builders.
This method ensures that the new OpenGL context will share the display lists of the original.
pub fn framebuffer_dimensions(&self) -> (u32, u32)
[src]
pub fn framebuffer_dimensions(&self) -> (u32, u32)
The dimensions of the framebuffer - often equivalent to the inner dimensions of a window.
pub fn opengl_version(&self) -> &Version
[src]
pub fn opengl_version(&self) -> &Version
The OpenGL version detected by this context.
pub fn supported_glsl_version(&self) -> Version
[src]
pub fn supported_glsl_version(&self) -> Version
The GLSL version guaranteed to be supported.
pub fn is_glsl_version_supported(&self, version: &Version) -> bool
[src]
pub fn is_glsl_version_supported(&self, version: &Version) -> bool
Returns true if the given GLSL version is supported.
pub fn opengl_version_string(&self) -> &str
[src]
pub fn opengl_version_string(&self) -> &str
A string containing this GL version or release number used by this context.
Vendor-specific information may follow the version number.
pub fn opengl_vendor_string(&self) -> &str
[src]
pub fn opengl_vendor_string(&self) -> &str
A string containing the company responsible for this GL implementation.
pub fn opengl_renderer_string(&self) -> &str
[src]
pub fn 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.
pub fn is_debug(&self) -> bool
[src]
pub 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.
pub fn is_forward_compatible(&self) -> bool
[src]
pub 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.
pub fn opengl_profile(&self) -> Option<Profile>
[src]
pub fn opengl_profile(&self) -> Option<Profile>
This context's OpenGL profile if available.
The context profile is available from OpenGL 3.2 onwards.
Returns None
if not supported.
pub fn is_robust(&self) -> bool
[src]
pub 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.
pub fn is_context_loss_possible(&self) -> bool
[src]
pub fn is_context_loss_possible(&self) -> bool
Returns true if context loss is possible.
pub fn is_context_lost(&self) -> bool
[src]
pub fn is_context_lost(&self) -> bool
Returnstrue if the context has been lost and needs to be recreated.
If it has been determined that the context has been lost before, then the function immediately returns true. Otherwise calls glGetGraphicsResetStatus. If this function is not available, returns false.
pub fn release_behavior(&self) -> ReleaseBehavior
[src]
pub fn release_behavior(&self) -> ReleaseBehavior
The behaviour when the current OpenGL context is changed.
The most common value is Flush
. In order to get None
you must explicitly request it
during creation.
pub fn max_anisotropy_support(&self) -> Option<u16>
[src]
pub fn max_anisotropy_support(&self) -> Option<u16>
Returns the maximum value that can be used for anisotropic filtering.
Returns None
if the hardware doesn't support it.
pub fn max_viewport_dimensions(&self) -> (u32, u32)
[src]
pub fn max_viewport_dimensions(&self) -> (u32, u32)
The maximum dimensions of the viewport.
Glium will panic if you request a larger viewport than this when drawing.
pub fn release_shader_compiler(&self)
[src]
pub fn release_shader_compiler(&self)
Provides a hint to the OpenGL implementation that it may free internal resources associated with its shader compiler.
This method is a no-op if it's not available in the implementation.
pub fn free_video_memory_bytes(&self) -> Option<usize>
[src]
pub fn free_video_memory_bytes(&self) -> Option<usize>
An estimate of the amount of video memory available in bytes.
None
if no estimate is available.
pub fn read_front_buffer<T>(&self) -> T where
T: Texture2dDataSink<(u8, u8, u8, u8)>,
[src]
pub fn read_front_buffer<T>(&self) -> T where
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)>
.
pub unsafe fn exec_in_context<'a, T, F>(&self, action: F) -> T where
T: Send + 'static,
F: FnOnce() -> T + 'a,
[src]
pub unsafe fn exec_in_context<'a, T, F>(&self, action: F) -> T where
T: Send + 'static,
F: FnOnce() -> T + 'a,
Execute an arbitrary closure with the OpenGL context active. Useful if another component needs to directly manipulate OpenGL state.
If action
maniuplates any OpenGL state, it must be restored before action
completes.
pub fn assert_no_error(&self, user_msg: Option<&str>)
[src]
pub fn assert_no_error(&self, user_msg: Option<&str>)
Asserts that there are no OpenGL errors pending.
This function should be used in tests.
pub fn insert_debug_marker(&self, marker: &str) -> Result<(), ()>
[src]
pub 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.
pub fn debug_insert_debug_marker(&self, marker: &str) -> Result<(), ()>
[src]
pub 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
.
pub fn inner_glium_display(&self) -> &Display
[src]
pub fn inner_glium_display(&self) -> &Display
Returns a reference to the inner glium::Display
.
Note: using this method (or more spefically, some methods on Display
) may break the
nannou API. It should be avoided if possible, but is provided for flexibility in case it is
needed or in case nannou's API does not suffice.
pub fn is_fullscreen(&self) -> bool
[src]
pub fn is_fullscreen(&self) -> bool
Attempts to determine whether or not the window is currently fullscreen.
TODO: This currently relies on comparing outer_size_pixels
to the dimensions of the
current_monitor
, which may not be exactly accurate on some platforms or even conceptually
correct in the case that a title bar is included or something. This should probably be a
method upstream within the winit
crate itself. Alternatively we could attempt to manually
track whether or not the window is fullscreen ourselves, however this could get quite
complicated quite quickly.
Trait Implementations
impl WinitWindow for Window
[src]
impl WinitWindow for Window
fn get_inner_size(&self) -> Option<(u32, u32)>
[src]
fn get_inner_size(&self) -> Option<(u32, u32)>
Return the inner size of the window in pixels.
fn hidpi_factor(&self) -> f32
[src]
fn hidpi_factor(&self) -> f32
Return the window's DPI factor so that we can convert from pixel values to scalar values.