Struct moon_engine::renderer::Renderer
source · [−]pub struct Renderer {
pub gl: GL,
pub program: Shader,
pub camera: Camera,
pub components: BTreeMap<&'static str, Box<dyn Component>>,
/* private fields */
}
Expand description
Fields
gl: GL
The WebGl2RenderingContext
used by the Renderer
.
program: Shader
camera: Camera
components: BTreeMap<&'static str, Box<dyn Component>>
Components
that can be added to the Renderer
.
Implementations
sourceimpl Renderer
impl Renderer
sourcepub fn new_with_camera(camera: Camera) -> Self
pub fn new_with_camera(camera: Camera) -> Self
sourcepub fn new_with_camera_and_program(camera: Camera, program: Shader) -> Self
pub fn new_with_camera_and_program(camera: Camera, program: Shader) -> Self
sourcepub fn set_camera(&mut self, camera: Camera)
pub fn set_camera(&mut self, camera: Camera)
sourcepub fn set_shader(&mut self, program: Shader)
pub fn set_shader(&mut self, program: Shader)
sourcepub fn init_shader(&mut self)
pub fn init_shader(&mut self)
Initialise the uniforms for the current Shader
.
sourcepub fn add_texture(&mut self, key: &'static str, texture: Texture)
pub fn add_texture(&mut self, key: &'static str, texture: Texture)
sourcepub fn use_texture(&self, key: &str)
pub fn use_texture(&self, key: &str)
sourcepub fn get_texture(&mut self, key: &str) -> Rc<Texture>
pub fn get_texture(&mut self, key: &str) -> Rc<Texture>
Get the requested Texture
, or MAGENTA if none is found.
sourcepub fn begin_draw(&mut self)
pub fn begin_draw(&mut self)
Clear the batch queue and start a new batch.
sourcepub fn begin_layer(&mut self)
pub fn begin_layer(&mut self)
Begin a new layer.
A new mesh is added to the batches and subsequent calls are made on this layer.
sourcepub fn delete_layer(&mut self) -> Option<Mesh>
pub fn delete_layer(&mut self) -> Option<Mesh>
Remove the last layer.
sourcepub fn draw_layer(&self)
pub fn draw_layer(&self)
Draw the current layer.
sourcepub fn add_component(&mut self, name: &'static str, component: Box<dyn Component>)
pub fn add_component(&mut self, name: &'static str, component: Box<dyn Component>)
sourcepub fn init_components(&mut self)
pub fn init_components(&mut self)
(Re)Initialize the Components
of the Renderer
.
sourcepub fn update_components(&mut self, delta_time: f32)
pub fn update_components(&mut self, delta_time: f32)
Update the Components
of the Renderer
.
sourcepub fn get_component<T: 'static + Component>(
&self,
key: &'static str
) -> Result<&T, String>
pub fn get_component<T: 'static + Component>(
&self,
key: &'static str
) -> Result<&T, String>
Get a Components
using a key, and ty to cast it to a given type.
sourcepub fn get_mut_component<T: 'static + Component>(
&mut self,
key: &'static str
) -> Result<&mut T, String>
pub fn get_mut_component<T: 'static + Component>(
&mut self,
key: &'static str
) -> Result<&mut T, String>
Get a mutable Components
using a key, and ty to cast it to a given type.
sourcepub fn draw_components(&mut self)
pub fn draw_components(&mut self)
Draw the Components
of the Renderer
.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Renderer
impl !Send for Renderer
impl !Sync for Renderer
impl Unpin for Renderer
impl !UnwindSafe for Renderer
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.