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§
Source§impl 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 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<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
Mutably borrows from an owned value. Read more
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§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 moreSource§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).Source§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.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.