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:

  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

The glium context represented by a glium::backend::Context and a glutin::GlWindow

A function for rendering a single frame

Methods

impl Render<DefaultResource>
[src]

Scales 3D zoom of viewports 1-3.

Does nothing in single viewport mode.

Panics

Panics if scale is negative.

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

Panics

Panics if scale is negative.

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

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.

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]

Creates a new renderer with default viewport and resources.

Restore the renderer to the newly created state

Convenience method to call the current frame function on 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.

Trait Implementations

impl<R: Resource> Drop for Render<R>
[src]

Executes the destructor for this type. Read more

Auto Trait Implementations

impl<R> !Send for Render<R>

impl<R> !Sync for Render<R>