pub struct Renderer { /* private fields */ }
Expand description
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn context(&self) -> RenderContext
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.
Sourcepub fn draw_layer(&self, layer: &Layer, component: u32) -> &Self
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.
Sourcepub fn rect<T>(&self, target_rect: T) -> DrawBuilder<'_, DrawBuilderRect>
pub fn rect<T>(&self, target_rect: T) -> DrawBuilder<'_, DrawBuilderRect>
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();
Sourcepub fn fill(&self) -> DrawBuilder<'_, DrawBuilderFill>
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();
Sourcepub fn render_to<F, T>(&self, target: &T, draw_func: F) -> &Selfwhere
F: FnMut(),
T: AsRenderTarget,
pub fn render_to<F, T>(&self, target: &T, draw_func: F) -> &Selfwhere
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);
});
Sourcepub fn postprocess<P, F>(
&self,
postprocessor: &P,
arg: &<P as Postprocessor>::T,
draw_func: F,
) -> &Selfwhere
F: FnMut(),
P: Postprocessor,
pub fn postprocess<P, F>(
&self,
postprocessor: &P,
arg: &<P as Postprocessor>::T,
draw_func: F,
) -> &Selfwhere
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);
});
Sourcepub fn copy_rect_from<R, S, T>(
&self,
source: &R,
source_rect: S,
target_rect: T,
filter: TextureFilter,
)
pub fn copy_rect_from<R, S, T>( &self, source: &R, source_rect: S, target_rect: T, filter: TextureFilter, )
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.
Sourcepub fn copy_from<R>(&self, source: &R, filter: TextureFilter)where
R: AsRenderTarget,
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.
Sourcepub fn default_program(&self) -> &Program
pub fn default_program(&self) -> &Program
Returns a reference to the default rendering program.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Renderer
impl !RefUnwindSafe for Renderer
impl !Send for Renderer
impl !Sync for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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