Struct radiant_rs::Renderer [−][src]
pub struct Renderer { /* fields omitted */ }
A renderer is used to render Layers
or Textures
to the
Display
.
The renderer itself is not thread-safe. Instead, draw or write onto layers (from any one or more threads) and present those layers using the renderer once your threads have concluded drawing.
Methods
impl Renderer
[src]
impl Renderer
pub fn new(display: &Display) -> Result<Self>
[src]
pub fn new(display: &Display) -> Result<Self>
Returns a new renderer instance.
pub fn context(&self) -> RenderContext
[src]
pub fn context(&self) -> RenderContext
Returns a reference to the renderers' context. The RenderContext
implements send+sync and is required by Font
, Sprite
and Texture
to create new instances.
ⓘImportant traits for &'a mut Rpub fn clear(&self, color: Color) -> &Self
[src]
pub fn clear(&self, color: Color) -> &Self
Clears the current target.
ⓘImportant traits for &'a mut Rpub fn draw_layer(&self, layer: &Layer, component: u32) -> &Self
[src]
pub fn draw_layer(&self, layer: &Layer, component: u32) -> &Self
Draws given layer to the current target. Component refers to the sprite component to draw. All sprites support at least component 0. Sprites that do not support the given component will not be drawn.
pub fn rect<T>(&self, target_rect: T) -> DrawBuilder<DrawBuilderRect> where
((f32, f32), (f32, f32)): From<T>,
[src]
pub fn rect<T>(&self, target_rect: T) -> DrawBuilder<DrawBuilderRect> where
((f32, f32), (f32, f32)): From<T>,
Draws a rectangle to the current target. See DrawBuilder
for available options.
Examples
renderer.rect(((0., 0.), (640., 480.))).blendmode(blendmodes::ALPHA).texture(&tex).draw();
pub fn fill(&self) -> DrawBuilder<DrawBuilderFill>
[src]
pub fn fill(&self) -> DrawBuilder<DrawBuilderFill>
Fills the current target. See DrawBuilder
for available options.
This is a specialization of rect()
that simply fills the entire target.
Examples
renderer.fill().blendmode(blendmodes::ALPHA).texture(&tex).draw();
ⓘImportant traits for &'a mut Rpub fn render_to<F, T>(&self, target: &T, draw_func: F) -> &Self where
F: FnMut(),
T: AsRenderTarget,
[src]
pub fn render_to<F, T>(&self, target: &T, draw_func: F) -> &Self where
F: FnMut(),
T: AsRenderTarget,
Reroutes draws issued within draw_func()
to given Texture.
Examples
// Create a texture to render to. let surface = Texture::new(&rendercontext, 640, 480); // Render something to it. renderer.render_to(&surface, || { renderer.rect(((0., 0.), (640., 480.))).texture(&some_texture).draw(); renderer.draw_layer(&some_layer, 0); });
ⓘImportant traits for &'a mut Rpub fn postprocess<P, F>(
&self,
postprocessor: &P,
arg: &<P as Postprocessor>::T,
draw_func: F
) -> &Self where
F: FnMut(),
P: Postprocessor,
[src]
pub fn postprocess<P, F>(
&self,
postprocessor: &P,
arg: &<P as Postprocessor>::T,
draw_func: F
) -> &Self where
F: FnMut(),
P: Postprocessor,
Reroutes draws issued within draw_func()
through the given postprocessor.
The following example uses the Basic
postprocessor provided by the library.
Examples
// Load a shader progam. let my_program = Program::from_string(&rendercontext, &program_source).unwrap(); // Create the postprocessor with the program. let my_postprocessor = postprocessors::Basic::new(&rendercontext, my_program); // ... in your renderloop... renderer.postprocess(&my_postprocessor, &blendmodes::ALPHA, || { renderer.clear(Color::BLACK); renderer.draw_layer(&my_layer, 0); });
pub fn copy_rect_from<R, S, T>(
&self,
source: &R,
source_rect: S,
target_rect: T,
filter: TextureFilter
) where
R: AsRenderTarget,
((i32, i32), (i32, i32)): From<S> + From<T>,
[src]
pub fn copy_rect_from<R, S, T>(
&self,
source: &R,
source_rect: S,
target_rect: T,
filter: TextureFilter
) where
R: AsRenderTarget,
((i32, i32), (i32, i32)): From<S> + From<T>,
Copies a rectangle from the source to the current target.
This is a blitting operation that uses integral pixel coordinates (top/left = 0/0). Coordinates must be entirely contained within their respective sources. No blending is performed.
pub fn copy_from<R>(&self, source: &R, filter: TextureFilter) where
R: AsRenderTarget,
[src]
pub fn copy_from<R>(&self, source: &R, filter: TextureFilter) where
R: AsRenderTarget,
Copies the entire source, overwriting the entire current target.
This is a blitting operation, no blending is performed.
pub fn default_program(&self) -> &Program
[src]
pub fn default_program(&self) -> &Program
Returns a reference to the default rendering program.
Trait Implementations
impl Clone for Renderer
[src]
impl Clone for Renderer
fn clone(&self) -> Renderer
[src]
fn clone(&self) -> Renderer
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl Debug for Renderer
[src]
impl Debug for Renderer