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]
pub fn new(display: &Display) -> Result<Self>
[src]
Returns a new renderer instance.
pub fn context(&self) -> RenderContext
[src]
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 Wpub fn clear(&self, color: Color) -> &Self
[src]
Clears the current target.
ⓘImportant traits for &'a mut Wpub fn draw_layer(&self, layer: &Layer, component: u32) -> &Self
[src]
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]
((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]
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 Wpub fn render_to<F, T>(&self, target: &T, draw_func: F) -> &Self where
F: FnMut(),
T: AsRenderTarget,
[src]
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 Wpub fn postprocess<P, F>(
&self,
postprocessor: &P,
arg: &<P as Postprocessor>::T,
draw_func: F
) -> &Self where
F: FnMut(),
P: Postprocessor,
[src]
&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]
&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]
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]
Returns a reference to the default rendering program.