pub struct Renderer { /* private fields */ }Implementations§
Source§impl Renderer
impl Renderer
pub fn screen_vertex_shader(&self) -> &ScreenVertexShader
Sourcepub fn register_prepare<R: Module + Prepare>(&mut self, handle: Handle<R>)
pub fn register_prepare<R: Module + Prepare>(&mut self, handle: Handle<R>)
This is not ideal, but right now it is a simple way to prepare data using the command encoder of the frame.
Sourcepub fn settings_mut(&mut self) -> &mut RendererSettings
pub fn settings_mut(&mut self) -> &mut RendererSettings
Examples found in repository?
examples/bloom.rs (line 51)
29 fn new(_config: Self::Config, mut deps: Self::Dependencies) -> anyhow::Result<Self> {
30 let mut blue_cubes: Vec<Transform> = vec![];
31 let mut black_cubes: Vec<Transform> = vec![];
32
33 for x in 0..30 {
34 for y in 0..30 {
35 for z in 0..30 {
36 let pos = vec3(
37 x as f32 * 2.0 + 20.0 + (z as f32 * 0.1).sin() * 2.0,
38 y as f32 * 2.0 - 30.0 + (z as f32).sin() * 2.0,
39 z as f32 * 2.0 - 30.0 + ((x + y) % 2) as f32,
40 );
41 if (x + y) % 2 == 0 {
42 blue_cubes.push(pos.into());
43 } else {
44 black_cubes.push(pos.into());
45 };
46 }
47 }
48 }
49
50 // use a very high energy green to get a nice background bloom
51 deps.renderer.settings_mut().clear_color = Color::new(2.0, 8.0, 2.0);
52
53 Ok(MyState {
54 black_cubes,
55 blue_cubes,
56 camera_orthographic: false,
57 deps,
58 })
59 }pub fn register_main_pass_renderer<R: Module + MainPassRenderer>( &mut self, handle: Handle<R>, timing: Timing, )
pub fn register_post_processing_effect<R: Module + PostProcessingEffect>( &mut self, handle: Handle<R>, timing: Timing, )
pub fn register_tonemapping_effect<R: Module + PostProcessingEffect>( &mut self, handle: Handle<R>, )
Sourcepub fn register_surface_renderer<R: Module + SdrSurfaceRenderer>(
&mut self,
handle: Handle<R>,
timing: Timing,
)
pub fn register_surface_renderer<R: Module + SdrSurfaceRenderer>( &mut self, handle: Handle<R>, timing: Timing, )
registers a renderer that renders to the sdr surface after all post processing and tonemapping has been done. good for e.g. ui with egui.
Trait Implementations§
Source§impl Module for Renderer
impl Module for Renderer
Source§type Config = RendererSettings
type Config = RendererSettings
Some initial data that configures the module. Provided by the User when adding a module to an app.
Source§type Dependencies = RendererDependencies
type Dependencies = RendererDependencies
Other modules that are expected to be part of the app. Provided automatically during app setup, where the program
resolves which dependencies each module has.
Source§fn intialize(handle: Handle<Self>) -> Result<()>
fn intialize(handle: Handle<Self>) -> Result<()>
Is run once, after all modules have been initialized.
This function is optional, it is given a handle to the module itself.
other modules can be accessed if you cache the handles to them in the ) with a general Renderer module,
if a
new() function.
E.g. the LineRenderer could register its own handle (HandleHandle<Renderer> was part of the Self::Dependencies and cached in the new function.
E.g. LineRenderer could have a field renderer: Handle<Renderer> that is populated in new.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<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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.