Struct Render

Source
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:

  1. Framebuffer clearing commands
  2. Framebuffer blitting commands
  3. Drawing commands (vertex rendering)
  4. 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>

Source

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>, )

Available on crate feature demo only.
Source§

impl Render<Default>

Source

pub fn camera3d_position_set(&mut self, position: Point3<f32>)

Source

pub fn camera3d_orientation_set(&mut self, orientation: Rotation3<f32>)

Source

pub fn camera3d_look_at(&mut self, target: Point3<f32>)

Source

pub fn camera3d_move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)

Source

pub fn camera3d_rotate( &mut self, dyaw: Rad<f32>, dpitch: Rad<f32>, droll: Rad<f32>, )

Source

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.

Source

pub fn camera3d_perspective_fovy_scale(&mut self, scale: f32)

Scales 3D zoom of viewport 0 (the main viewport) only.

§Panics

Panics if scale is negative.

Source

pub fn camera2d_zoom_set(&mut self, zoom: f32)

Source

pub fn camera2d_zoom_shift(&mut self, shift: f32)

Modifies the 2D zoom by the given amount for all viewports.

Source

pub fn camera2d_move_local(&mut self, dx: f32, dy: f32)

Source

pub fn camera2d_move_origin_to_bottom_left(&mut self)

Moves origin for all viewports to lower left

Source

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>

Source

pub fn new(glium_display: Display<WindowSurface>, window: Window) -> Self

Creates a new renderer with default viewport and resources.

Source

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

Source

pub fn viewports(&self) -> &VecMap<Viewport>

Source

pub fn viewports_mut(&mut self) -> &mut VecMap<Viewport>

Source

pub fn get_viewport(&self, key: usize) -> Option<&Viewport>

Source

pub fn get_viewport_mut(&mut self, key: usize) -> Option<&mut Viewport>

Source

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.

Source

pub fn do_frame(&mut self, frame: Option<&mut Frame>)

Convenience method to call the current frame function on self

Source

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.

Source

pub fn report_sizes()

Trait Implementations§

Source§

impl<R: Resource> Debug for Render<R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl<R: Resource> Drop for Render<R>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<Src, Dst> LosslessTryInto<Dst> for Src
where Dst: LosslessTryFrom<Src>,

Source§

fn lossless_try_into(self) -> Option<Dst>

Performs the conversion.
Source§

impl<Src, Dst> LossyInto<Dst> for Src
where Dst: LossyFrom<Src>,

Source§

fn lossy_into(self) -> Dst

Performs the conversion.
Source§

impl<T> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> MaybeSerDes for T