pub struct Render<R: Resource = Default> {
pub glium_display: Display<WindowSurface>,
pub window: Window,
pub resource: R,
pub frame_fun: fn(&mut Render<R>, Option<&mut Frame>),
pub clear_color: [f32; 4],
pub clear_depth: f32,
pub clear_stencil: i32,
/* private fields */
}
Expand description
State for Glium-based rendering.
Holds all the context information and resources required for rendering. A
frame function may be specified by the frame_fun
field which is a
function pointer that takes a mutable self reference for the purpose of
making Glium render commands.
OpenGL has four types of render commands:
- Framebuffer clearing commands
- Framebuffer blitting commands
- Drawing commands (vertex rendering)
- Compute dispatch commands (OpenGL 4.3+ only)
All resources (vertex and index buffers, textures and other uniforms)
should be in the user defined generic resource type R : Resource
.
Fields§
§glium_display: Display<WindowSurface>
The glium
context represented by a glium::backend::Context
and a
glutin::surface::WindowSurface
window: Window
§resource: R
A function for rendering a single frame
frame_fun: fn(&mut Render<R>, Option<&mut Frame>)
§clear_color: [f32; 4]
§clear_depth: f32
§clear_stencil: i32
Implementations§
Source§impl Render<Default>
impl Render<Default>
pub fn demo_handle_winit_window_event( &mut self, event: WindowEvent, running: &mut bool, mouse_position: &mut (f64, f64), mouse_button_event: &mut Option<ElementState>, )
demo
only.Source§impl Render<Default>
impl Render<Default>
pub fn camera3d_position_set(&mut self, position: Point3<f32>)
pub fn camera3d_orientation_set(&mut self, orientation: Rotation3<f32>)
pub fn camera3d_look_at(&mut self, target: Point3<f32>)
pub fn camera3d_move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
pub fn camera3d_rotate( &mut self, dyaw: Rad<f32>, dpitch: Rad<f32>, droll: Rad<f32>, )
Sourcepub fn camera3d_orthographic_zoom_scale(&mut self, scale: f32)
pub fn camera3d_orthographic_zoom_scale(&mut self, scale: f32)
Scales 3D zoom of viewports 1-3.
Does nothing in single viewport mode.
§Panics
Panics if scale is negative.
Sourcepub fn camera3d_perspective_fovy_scale(&mut self, scale: f32)
pub fn camera3d_perspective_fovy_scale(&mut self, scale: f32)
pub fn camera2d_zoom_set(&mut self, zoom: f32)
Sourcepub fn camera2d_zoom_shift(&mut self, shift: f32)
pub fn camera2d_zoom_shift(&mut self, shift: f32)
Modifies the 2D zoom by the given amount for all viewports.
pub fn camera2d_move_local(&mut self, dx: f32, dy: f32)
Sourcepub fn camera2d_move_origin_to_bottom_left(&mut self)
pub fn camera2d_move_origin_to_bottom_left(&mut self)
Moves origin for all viewports to lower left
Sourcepub fn window_resized(&mut self, physical_size: PhysicalSize<u32>)
pub fn window_resized(&mut self, physical_size: PhysicalSize<u32>)
Resize the viewport(s) based on the LogicalSize that was returned by a WindowEvent::Resized event
Source§impl<R: Resource> Render<R>
impl<R: Resource> Render<R>
Sourcepub fn new(glium_display: Display<WindowSurface>, window: Window) -> Self
pub fn new(glium_display: Display<WindowSurface>, window: Window) -> Self
Creates a new renderer with default viewport and resources.
Sourcepub fn clear_color_tuple(&self) -> (f32, f32, f32, f32)
pub fn clear_color_tuple(&self) -> (f32, f32, f32, f32)
Internally the clear color is stored as an array, but the glium clear command takes a tuple
pub fn viewports(&self) -> &VecMap<Viewport>
pub fn viewports_mut(&mut self) -> &mut VecMap<Viewport>
pub fn get_viewport(&self, key: usize) -> Option<&Viewport>
pub fn get_viewport_mut(&mut self, key: usize) -> Option<&mut Viewport>
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Restore the renderer to the newly created state.
Calls Resource::reset
on the current resource state which is allowed to
be overridden to keep some resources persistent.
Sourcepub fn do_frame(&mut self, frame: Option<&mut Frame>)
pub fn do_frame(&mut self, frame: Option<&mut Frame>)
Convenience method to call the current frame function on self
Sourcepub fn screenshot(&self)
pub fn screenshot(&self)
Read the content of the front buffer and save in a PNG file with unique
file name screenshot-N.png
in the current directory.
pub fn report_sizes()
Trait Implementations§
Auto Trait Implementations§
impl<R> Freeze for Render<R>where
R: Freeze,
impl<R = Default> !RefUnwindSafe for Render<R>
impl<R = Default> !Send for Render<R>
impl<R = Default> !Sync for Render<R>
impl<R> Unpin for Render<R>where
R: Unpin,
impl<R = Default> !UnwindSafe for Render<R>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more