Struct gl_utils::render::Render [−][src]
pub struct Render<R: Resource> { pub glium_display: Display, pub resource: R, pub frame_fun: fn(_: &mut Render<R>), pub clear_color: (f32, f32, f32, f32), pub viewports: VecMap<Viewport>, }
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
The glium
context represented by a glium::backend::Context
and a
glutin::GlWindow
resource: R
A function for rendering a single frame
frame_fun: fn(_: &mut Render<R>)
clear_color: (f32, f32, f32, f32)
viewports: VecMap<Viewport>
Methods
impl Render<DefaultResource>
[src]
impl Render<DefaultResource>
pub fn camera3d_position_set(&mut self, position: &Point3<f32>)
[src]
pub fn camera3d_position_set(&mut self, position: &Point3<f32>)
pub fn camera3d_move_local_xy(&mut self, dx: f32, dy: f32, dz: f32)
[src]
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>)
[src]
pub fn camera3d_rotate(&mut self, dyaw: Rad<f32>, dpitch: Rad<f32>)
pub fn camera3d_orthographic_zoom_scale(&mut self, scale: f32)
[src]
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.
pub fn camera3d_perspective_fovy_scale(&mut self, scale: f32)
[src]
pub fn camera3d_perspective_fovy_scale(&mut self, scale: f32)
pub fn camera2d_zoom_set(&mut self, zoom: f32)
[src]
pub fn camera2d_zoom_set(&mut self, zoom: f32)
pub fn camera2d_zoom_shift(&mut self, shift: f32)
[src]
pub fn camera2d_zoom_shift(&mut self, shift: f32)
Modifies the 2D zoom by the given amount for all viewports.
pub fn window_resized(&mut self, width: u32, height: u32)
[src]
pub fn window_resized(&mut self, width: u32, height: u32)
pub fn demo_init(&mut self)
[src]
pub fn demo_init(&mut self)
Initializes "demo" state such as example mesh instances and viewport text tiles.
This should normally be called immediately after render context creation
as some assumptions are made about the current state (see Panics below).
The renderer can be returned to this state with the reset
method.
After demo_init
, demo_handle_glutin_event
can be called on incoming
events to interact with the demo.
A usage example is provided in ./examples/demo.rs
.
Panics
A prerequisite is that the first four viewport_tile_data
entries are
empty.
The currently allocated per-instance buffers should be empty.
pub fn demo_handle_glutin_event(&mut self, running: &mut bool, event: Event)
[src]
pub fn demo_handle_glutin_event(&mut self, running: &mut bool, event: Event)
pub fn demo_toggle_quad_viewports(&mut self)
[src]
pub fn demo_toggle_quad_viewports(&mut self)
Switch between single (perspective) and quad viewport modes (perspective
- three ortho viewports).
Generally should be called from a render context that was initialized
with demo_init
.
Panics
If there is a single viewport it must be MAIN_VIEWPORT
.
If there are multiple viewports, they must be exactly the first four viewports only.
impl<R: Resource> Render<R>
[src]
impl<R: Resource> Render<R>
pub fn new(glium_display: Display) -> Self
[src]
pub fn new(glium_display: Display) -> Self
Creates a new renderer with default viewport and resources.
pub fn reset(&mut self)
[src]
pub fn reset(&mut self)
Restore the renderer to the newly created state
pub fn do_frame(&mut self)
[src]
pub fn do_frame(&mut self)
Convenience method to call the current frame function on self
pub fn screenshot(&self)
[src]
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()
[src]
pub fn report_sizes()